Revert last code drop.
authorPat Downey <patd@symbian.org>
Fri, 04 Jun 2010 10:27:39 +0100
changeset 35 9d8b04ca6939
parent 34 7858bc6ead78
child 38 218231f2b3b3
Revert last code drop.
group/bld.inf
layers.sysdef.xml
package_definition.xml
sysdef_1_5_1.dtd
tsrc/group/bld.inf
usbclasses/group/bld.inf
usbclasses/pictbridgeengine/BWINS/pictbridgeU.DEF
usbclasses/pictbridgeengine/EABI/pictbridgeU.DEF
usbclasses/pictbridgeengine/group/bld.inf
usbclasses/pictbridgeengine/group/pictbridge.mmp
usbclasses/pictbridgeengine/inc/dps.rh
usbclasses/pictbridgeengine/inc/dpsconnectnotifier.h
usbclasses/pictbridgeengine/inc/dpsconst.h
usbclasses/pictbridgeengine/inc/dpsdefs.h
usbclasses/pictbridgeengine/inc/dpsfile.h
usbclasses/pictbridgeengine/inc/dpsfile.inl
usbclasses/pictbridgeengine/inc/dpsoperation.h
usbclasses/pictbridgeengine/inc/dpsoperation.inl
usbclasses/pictbridgeengine/inc/dpsparam.h
usbclasses/pictbridgeengine/inc/dpsparam.inl
usbclasses/pictbridgeengine/inc/dpsptpnotifier.h
usbclasses/pictbridgeengine/inc/dpsscriptreceiver.h
usbclasses/pictbridgeengine/inc/dpsscriptsender.h
usbclasses/pictbridgeengine/inc/dpsstate.h
usbclasses/pictbridgeengine/inc/dpsstatemachine.h
usbclasses/pictbridgeengine/inc/dpsstatemachine.inl
usbclasses/pictbridgeengine/inc/dpstransaction.h
usbclasses/pictbridgeengine/inc/dpstransaction.inl
usbclasses/pictbridgeengine/inc/dpsusbnotifier.h
usbclasses/pictbridgeengine/inc/dpsxmlgenerator.h
usbclasses/pictbridgeengine/inc/dpsxmlparser.h
usbclasses/pictbridgeengine/inc/dpsxmlparser.inl
usbclasses/pictbridgeengine/inc/dpsxmlstring.h
usbclasses/pictbridgeengine/inc/pictbridge.h
usbclasses/pictbridgeengine/rom/pictbridge.iby
usbclasses/pictbridgeengine/src/dps.rss
usbclasses/pictbridgeengine/src/dpsconnectnotifier.cpp
usbclasses/pictbridgeengine/src/dpsfile.cpp
usbclasses/pictbridgeengine/src/dpsoperation.cpp
usbclasses/pictbridgeengine/src/dpsparam.cpp
usbclasses/pictbridgeengine/src/dpsptpnotifier.cpp
usbclasses/pictbridgeengine/src/dpsscriptreceiver.cpp
usbclasses/pictbridgeengine/src/dpsscriptsender.cpp
usbclasses/pictbridgeengine/src/dpsstate.cpp
usbclasses/pictbridgeengine/src/dpsstatemachine.cpp
usbclasses/pictbridgeengine/src/dpstransaction.cpp
usbclasses/pictbridgeengine/src/dpsusbnotifier.cpp
usbclasses/pictbridgeengine/src/dpsxmlgenerator.cpp
usbclasses/pictbridgeengine/src/dpsxmlparser.cpp
usbclasses/pictbridgeengine/src/dpsxmlstring.cpp
usbclasses/pictbridgeengine/src/pictbridge.cpp
usbclasses/usbbasicpersonality/group/UsbBasicPersonality.mmp
usbclasses/usbbasicpersonality/group/bld.inf
usbclasses/usbbasicpersonality/inc/CUsbActiveBasicHandler.h
usbclasses/usbbasicpersonality/inc/debug.h
usbclasses/usbbasicpersonality/rom/UsbBasicPersonality.iby
usbclasses/usbbasicpersonality/src/10274797.rss
usbclasses/usbbasicpersonality/src/CUsbActiveBasicHandler.cpp
usbclasses/usbbasicpersonality/src/UsbActiveBasicHandlerImp.cpp
usbclasses/usbmscpersonality/group/UsbMscPersonality.mmp
usbclasses/usbmscpersonality/group/bld.inf
usbclasses/usbmscpersonality/inc/CUsbActiveMscHandlerMdrv.h
usbclasses/usbmscpersonality/inc/CUsbMscPersonalityTimer.h
usbclasses/usbmscpersonality/inc/debug.h
usbclasses/usbmscpersonality/inc/usbms.rh
usbclasses/usbmscpersonality/rom/UsbMscPersonality.iby
usbclasses/usbmscpersonality/src/10274798.rss
usbclasses/usbmscpersonality/src/CUsbActiveMscHandlerMdrv.cpp
usbclasses/usbmscpersonality/src/CUsbMscPersonalityTimer.cpp
usbclasses/usbmscpersonality/src/UsbActiveMscHandlerImp.cpp
usbclasses/usbobexclasscontroller/data/10281F29.rss
usbclasses/usbobexclasscontroller/group/UsbObexClassController.mmp
usbclasses/usbobexclasscontroller/group/bld.inf
usbclasses/usbobexclasscontroller/inc/CUsbObexClassController.h
usbclasses/usbobexclasscontroller/inc/mobexsmwatcher.h
usbclasses/usbobexclasscontroller/inc/obexsmwatcher.h
usbclasses/usbobexclasscontroller/rom/UsbObexClassController.iby
usbclasses/usbobexclasscontroller/src/CUsbObexClassController.cpp
usbclasses/usbobexclasscontroller/src/CUsbObexClassImpCollection.cpp
usbclasses/usbobexclasscontroller/src/obexsmwatcher.cpp
usbclasses/usbphoneasmodem/classcontroller/conf/usbmanager_mscfile_2000fda8.crml
usbclasses/usbphoneasmodem/classcontroller/conf/usbphoneasmodem_mscfile_classcontroller.confml
usbclasses/usbphoneasmodem/classcontroller/data/2000fda8.rss
usbclasses/usbphoneasmodem/classcontroller/data/usbpammscfile.rss
usbclasses/usbphoneasmodem/classcontroller/group/bld.inf
usbclasses/usbphoneasmodem/classcontroller/group/usbmscfileclasscontroller.mmp
usbclasses/usbphoneasmodem/classcontroller/inc/usbmscfileclasscontroller.h
usbclasses/usbphoneasmodem/classcontroller/inc/usbmscfileclasscontroller_crkeys.h
usbclasses/usbphoneasmodem/classcontroller/inc/usbpammscfile.rh
usbclasses/usbphoneasmodem/classcontroller/rom/usbmscfileclasscontroller.iby
usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontroller.cpp
usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontrollerimp.cpp
usbclasses/usbphoneasmodem/classimplementation/atplugin/data/20026f61.rss
usbclasses/usbphoneasmodem/classimplementation/atplugin/group/bld.inf
usbclasses/usbphoneasmodem/classimplementation/atplugin/group/pamplugin.mmp
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/atcmdpam_debug.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamengine.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugin.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugindebug.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugindebugconfig.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pampluginprjconfig.h
usbclasses/usbphoneasmodem/classimplementation/atplugin/rom/usbpamatplugin.iby
usbclasses/usbphoneasmodem/classimplementation/atplugin/src/atcmdpam_debug.cpp
usbclasses/usbphoneasmodem/classimplementation/atplugin/src/main.cpp
usbclasses/usbphoneasmodem/classimplementation/atplugin/src/pamengine.cpp
usbclasses/usbphoneasmodem/classimplementation/atplugin/src/pamplugin.cpp
usbclasses/usbphoneasmodem/classimplementation/group/bld.inf
usbclasses/usbphoneasmodem/classimplementation/inc/debug.h
usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfile.h
usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfile.inl
usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfileshared.h
usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfileuids.hrh
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/group/bld.inf
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/group/usbmscfileserver.mmp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/bulkonlytransport.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/filesystemimage.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfilecontroller.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserver.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserver.inl
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserversecuritypolicy.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfilesession.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/protocol.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/scsiprot.h
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/rom/phone_as_modem.iso
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/rom/usbmscfileserver.iby
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/bulkonlytransport.cpp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/filesystemimage.cpp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfilecontroller.cpp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfileserver.cpp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfilesession.cpp
usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/scsiprot.cpp
usbclasses/usbphoneasmodem/group/bld.inf
usbengines/group/bld.inf
usbengines/usbdevcon/group/bld.inf
usbengines/usbdevcon/group/build_component.bat
usbengines/usbdevcon/group/usbdevcon.mmp
usbengines/usbdevcon/inc/cep0reader.h
usbengines/usbdevcon/inc/cep0writer.h
usbengines/usbdevcon/inc/crequestshandler.h
usbengines/usbdevcon/inc/cstatemachine.h
usbengines/usbdevcon/inc/cusbdevcon.h
usbengines/usbdevcon/inc/cusbstatewatcher.h
usbengines/usbdevcon/inc/debug.h
usbengines/usbdevcon/rom/usbdevcon.iby
usbengines/usbdevcon/src/cep0reader.cpp
usbengines/usbdevcon/src/cep0writer.cpp
usbengines/usbdevcon/src/crequestshandler.cpp
usbengines/usbdevcon/src/cstatemachine.cpp
usbengines/usbdevcon/src/cusbdevcon.cpp
usbengines/usbdevcon/src/cusbstatewatcher.cpp
usbengines/usblocodplugin/data/0x102823dd.rss
usbengines/usblocodplugin/group/bld.inf
usbengines/usblocodplugin/group/usblocodplugin.mmp
usbengines/usblocodplugin/inc/usblcdactive.h
usbengines/usblocodplugin/inc/usblcdplugin.h
usbengines/usblocodplugin/rom/UsbLocodPlugin.iby
usbengines/usblocodplugin/src/proxy.cpp
usbengines/usblocodplugin/src/usblcdactive.cpp
usbengines/usblocodplugin/src/usblcdplugin.cpp
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/Bmarm/USBLocodPluginTestU.DEF
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/Bwins/USBLocodPluginTestU.DEF
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/EABI/USBLocodPluginTestU.def
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/conf/USBLocodPluginTest.cfg
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest.mmp
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest_ats.pkg
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest_phone.pkg
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/bld.inf
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/build_sis_ats.bat
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/build_sis_phone.bat
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/inc/LocodBearerPluginObs.h
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/inc/USBLocodPluginTest.h
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/init/USBLocodPluginTest_ats.ini
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/init/USBLocodPluginTest_phone.ini
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/LocodBearerPluginObs.cpp
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/USBLocodPluginTest.cpp
usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/USBLocodPluginTestBlocks.cpp
usbengines/usbotgwatcher/bwins/usbotgwatcheru.def
usbengines/usbotgwatcher/eabi/usbotgwatcheru.def
usbengines/usbotgwatcher/group/bld.inf
usbengines/usbotgwatcher/group/usbotgwatcher.mmp
usbengines/usbotgwatcher/inc/cusbbusactivityobserver.h
usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.h
usbengines/usbotgwatcher/inc/cusbidpinobserver.h
usbengines/usbotgwatcher/inc/cusbindicatornotifier.h
usbengines/usbotgwatcher/inc/cusbmessagenotificationobserver.h
usbengines/usbotgwatcher/inc/cusbnotenotifier.h
usbengines/usbotgwatcher/inc/cusbnotifier.h
usbengines/usbotgwatcher/inc/cusbnotifmanager.h
usbengines/usbotgwatcher/inc/cusbotgstateobserver.h
usbengines/usbotgwatcher/inc/cusbotgwatcher.h
usbengines/usbotgwatcher/inc/cusbservicecontrol.h
usbengines/usbotgwatcher/inc/cusbstate.h
usbengines/usbotgwatcher/inc/cusbstatehostabase.h
usbengines/usbotgwatcher/inc/cusbstatehostahost.h
usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h
usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h
usbengines/usbotgwatcher/inc/cusbstatehostdelayattachedhandle.h
usbengines/usbotgwatcher/inc/cusbstatehostdelayhandle.h
usbengines/usbotgwatcher/inc/cusbstatehostdelaynotattachedhandle.h
usbengines/usbotgwatcher/inc/cusbstatehosthandle.h
usbengines/usbotgwatcher/inc/cusbstatehosthandledropping.h
usbengines/usbotgwatcher/inc/cusbstatehostundefined.h
usbengines/usbotgwatcher/inc/cusbtimer.h
usbengines/usbotgwatcher/inc/cusbvbusobserver.h
usbengines/usbotgwatcher/inc/cusbwaitnotifier.h
usbengines/usbotgwatcher/inc/cusbwarningnotifier.h
usbengines/usbotgwatcher/inc/debug.h
usbengines/usbotgwatcher/inc/definitions.h
usbengines/usbotgwatcher/inc/errors.h
usbengines/usbotgwatcher/inc/panic.h
usbengines/usbotgwatcher/rom/errrd
usbengines/usbotgwatcher/rom/usbotgwatcher.iby
usbengines/usbotgwatcher/src/cusbbusactivityobserver.cpp
usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp
usbengines/usbotgwatcher/src/cusbidpinobserver.cpp
usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp
usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp
usbengines/usbotgwatcher/src/cusbnotenotifier.cpp
usbengines/usbotgwatcher/src/cusbnotifier.cpp
usbengines/usbotgwatcher/src/cusbnotifmanager.cpp
usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp
usbengines/usbotgwatcher/src/cusbotgwatcher.cpp
usbengines/usbotgwatcher/src/cusbservicecontrol.cpp
usbengines/usbotgwatcher/src/cusbstate.cpp
usbengines/usbotgwatcher/src/cusbstatehostabase.cpp
usbengines/usbotgwatcher/src/cusbstatehostahost.cpp
usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp
usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp
usbengines/usbotgwatcher/src/cusbstatehostdelayattachedhandle.cpp
usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp
usbengines/usbotgwatcher/src/cusbstatehostdelaynotattachedhandle.cpp
usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp
usbengines/usbotgwatcher/src/cusbstatehosthandledropping.cpp
usbengines/usbotgwatcher/src/cusbstatehostundefined.cpp
usbengines/usbotgwatcher/src/cusbtimer.cpp
usbengines/usbotgwatcher/src/cusbvbusobserver.cpp
usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp
usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp
usbengines/usbremotepersonality/group/bld.inf
usbengines/usbremotepersonality/group/build_component.bat
usbengines/usbremotepersonality/group/usbremotepersonality.mmp
usbengines/usbremotepersonality/inc/cremotepersonalityhandler.h
usbengines/usbremotepersonality/inc/csetpersonality.h
usbengines/usbremotepersonality/inc/debug.h
usbengines/usbremotepersonality/rom/usbremotepersonality.iby
usbengines/usbremotepersonality/src/10283307.rss
usbengines/usbremotepersonality/src/cremotepersonalityhandler.cpp
usbengines/usbremotepersonality/src/cremotepersonalityhandlerplugin.cpp
usbengines/usbremotepersonality/src/csetpersonality.cpp
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/Bmarm/USBRemotePersonalityTestU.DEF
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/Bwins/USBRemotePersonalityTestU.DEF
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/EABI/USBRemotePersonalityTestU.def
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/conf/USBRemotePersonalityTest.cfg
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest.mmp
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_ats.pkg
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_exe.mmp
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_phone.pkg
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/bld.inf
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/build_sis_ats.bat
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/build_sis_phone.bat
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/inc/USBRemotePersonalityTest.h
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/init/USBRemotePersonalityTest_ats.ini
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/init/USBRemotePersonalityTest_phone.ini
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTest.cpp
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTestBlocks.cpp
usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTest_exe.cpp
usbengines/usbwatcher/EABI/usbpersonalityu.def
usbengines/usbwatcher/EABI/usbwatcheru.def
usbengines/usbwatcher/bwins/usbpersonalityu.def
usbengines/usbwatcher/bwins/usbwatcheru.def
usbengines/usbwatcher/conf/usbwatcher.confml
usbengines/usbwatcher/conf/usbwatcher_101F8801.crml
usbengines/usbwatcher/group/backup_registration.xml
usbengines/usbwatcher/group/bld.inf
usbengines/usbwatcher/group/usbpersonality.mmp
usbengines/usbwatcher/group/usbwatcher.mmp
usbengines/usbwatcher/group/usbwatcherserver.mmp
usbengines/usbwatcher/inc/cusbactivepersonalityhandler.h
usbengines/usbwatcher/inc/cusbactivestate.h
usbengines/usbwatcher/inc/cusbdevconstarter.h
usbengines/usbwatcher/inc/cusbdevicelock.h
usbengines/usbwatcher/inc/cusbglobalsystemstateobserver.h
usbengines/usbwatcher/inc/cusbwatcher.h
usbengines/usbwatcher/inc/cusbwatcher.inl
usbengines/usbwatcher/inc/cusbwatcherscheduler.h
usbengines/usbwatcher/inc/cusbwatcherserver.h
usbengines/usbwatcher/inc/cusbwatcherserver.inl
usbengines/usbwatcher/inc/cusbwatchersession.h
usbengines/usbwatcher/inc/debug.h
usbengines/usbwatcher/inc/musbwatchernotify.h
usbengines/usbwatcher/inc/rusbwatcher.h
usbengines/usbwatcher/inc/tusbindicatorhandler.h
usbengines/usbwatcher/inc/usbvariation.rh
usbengines/usbwatcher/inc/usbwatcherserversecuritypolicy.h
usbengines/usbwatcher/inc/usbwatchershared.h
usbengines/usbwatcher/loc/usbman.loc
usbengines/usbwatcher/rom/mtp_symbian_temp.iby
usbengines/usbwatcher/rom/usbmanrsc.iby
usbengines/usbwatcher/rom/usbwatcher.iby
usbengines/usbwatcher/rom/usbwatcher_resources.iby
usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp
usbengines/usbwatcher/src/cusbactivestate.cpp
usbengines/usbwatcher/src/cusbdevconstarter.cpp
usbengines/usbwatcher/src/cusbdevicelock.cpp
usbengines/usbwatcher/src/cusbglobalsystemstateobserver.cpp
usbengines/usbwatcher/src/cusbpersonality.cpp
usbengines/usbwatcher/src/cusbpersonalitynotifier.cpp
usbengines/usbwatcher/src/cusbpersonalityplugin.cpp
usbengines/usbwatcher/src/cusbwatcher.cpp
usbengines/usbwatcher/src/cusbwatcherscheduler.cpp
usbengines/usbwatcher/src/cusbwatcherserver.cpp
usbengines/usbwatcher/src/cusbwatchersession.cpp
usbengines/usbwatcher/src/rusbwatcher.cpp
usbengines/usbwatcher/src/tusbindicatorhandler.cpp
usbengines/usbwatcher/src/tusbpersonalityparams.cpp
usbengines/usbwatcher/src/usbman_pcs.rss
usbengines/usbwatcher/src/usbman_pcsmtp.rss
usbengines/usbwatcher/src/usbman_pcsmtppam.rss
usbengines/usbwatcher/src/usbman_pcspam.rss
usbengines/usbwatcher/src/usbwatcher.cpp
usbservices_plat/group/bld.inf
usbservices_plat/pictbridge_api/group/bld.inf
usbservices_plat/pictbridge_api/inc/dpsdefs.h
usbservices_plat/pictbridge_api/inc/dpsoperation.h
usbservices_plat/pictbridge_api/inc/dpsoperation.inl
usbservices_plat/pictbridge_api/inc/dpsparam.h
usbservices_plat/pictbridge_api/inc/dpsparam.inl
usbservices_plat/pictbridge_api/inc/pictbridge.h
usbservices_plat/pictbridge_api/pictbridge_api.metaxml
usbservices_plat/ptp_responder_api/group/bld.inf
usbservices_plat/ptp_responder_api/ptp_responder_api.metaxml
usbservices_plat/ptp_server_api/group/bld.inf
usbservices_plat/ptp_server_api/inc/rptp.h
usbservices_plat/ptp_server_api/ptp_server_api.metaxml
usbservices_plat/ptp_transport_api/group/bld.inf
usbservices_plat/ptp_transport_api/inc/ptpcallbacks.h
usbservices_plat/ptp_transport_api/inc/ptptransport.h
usbservices_plat/ptp_transport_api/ptp_transport_api.metaxml
usbservices_plat/usb_device_control_plugin_api/group/bld.inf
usbservices_plat/usb_device_control_plugin_api/inc/cusbdevicecontrolplugin.h
usbservices_plat/usb_device_control_plugin_api/inc/cusbdevicecontrolplugin.inl
usbservices_plat/usb_device_control_plugin_api/usb_device_control_plugin_api.metaxml
usbservices_plat/usb_notifier_api/group/bld.inf
usbservices_plat/usb_notifier_api/inc/usbuinotif.h
usbservices_plat/usb_notifier_api/usb_notifier_api.metaxml
usbservices_plat/usb_personality_api_header/group/bld.inf
usbservices_plat/usb_personality_api_header/inc/UsbWatcherInternalCRKeys.h
usbservices_plat/usb_personality_api_header/usb_personality_api_header.metaxml
usbservices_plat/usb_personality_plugin_api/group/bld.inf
usbservices_plat/usb_personality_plugin_api/inc/cusbpersonality.h
usbservices_plat/usb_personality_plugin_api/inc/cusbpersonalitynotifier.h
usbservices_plat/usb_personality_plugin_api/inc/cusbpersonalityplugin.h
usbservices_plat/usb_personality_plugin_api/inc/musbnotifiercallback.h
usbservices_plat/usb_personality_plugin_api/inc/tusbpersonalityparams.h
usbservices_plat/usb_personality_plugin_api/usb_personality_plugin_api.metaxml
usbservices_plat/usb_secondary_display_api/group/bld.inf
usbservices_plat/usb_secondary_display_api/inc/usbuinotifsecondarydisplay.h
usbservices_plat/usb_secondary_display_api/usb_secondary_display_api.metaxml
usbservices_plat/usb_watcher_api/group/bld.inf
usbservices_plat/usb_watcher_api/inc/usbpersonalityids.h
usbservices_plat/usb_watcher_api/inc/usbwatcher.h
usbservices_plat/usb_watcher_api/usb_watcher_api.metaxml
usbservices_plat/usb_watcher_info_api_header/group/bld.inf
usbservices_plat/usb_watcher_info_api_header/inc/UsbWatcherInternalPSKeys.h
usbservices_plat/usb_watcher_info_api_header/usb_watcher_info_api_header.metaxml
usbuis/group/bld.inf
usbuis/imageprintui/data/imageprintui.rss
usbuis/imageprintui/data/imageprintui_reg.rss
usbuis/imageprintui/data/phonecapability.rss
usbuis/imageprintui/group/bld.inf
usbuis/imageprintui/group/imageprintui.mmp
usbuis/imageprintui/group/imageprintui_icons_aif_bitmaps_dc.mk
usbuis/imageprintui/group/imageprintui_icons_aif_scalable_dc.mk
usbuis/imageprintui/inc/capabilitymanager.h
usbuis/imageprintui/inc/connectionmanager.h
usbuis/imageprintui/inc/emptycontainer.h
usbuis/imageprintui/inc/emptyview.h
usbuis/imageprintui/inc/eventmanager.h
usbuis/imageprintui/inc/imageprintui.hrh
usbuis/imageprintui/inc/imageprintuiapp.h
usbuis/imageprintui/inc/imageprintuiappui.h
usbuis/imageprintui/inc/imageprintuidebug.h
usbuis/imageprintui/inc/imageprintuidocument.h
usbuis/imageprintui/inc/notes.h
usbuis/imageprintui/inc/notetimer.h
usbuis/imageprintui/inc/phonecapability.rh
usbuis/imageprintui/inc/requestmanager.h
usbuis/imageprintui/inc/settingscontainer.h
usbuis/imageprintui/inc/settingsitems.h
usbuis/imageprintui/inc/settingstables.h
usbuis/imageprintui/inc/settingsview.h
usbuis/imageprintui/loc/imageprintui.loc
usbuis/imageprintui/rom/imageprintui.iby
usbuis/imageprintui/rom/imageprintuiresources.iby
usbuis/imageprintui/src/capabilitymanager.cpp
usbuis/imageprintui/src/connectionmanager.cpp
usbuis/imageprintui/src/emptycontainer.cpp
usbuis/imageprintui/src/emptyview.cpp
usbuis/imageprintui/src/eventmanager.cpp
usbuis/imageprintui/src/imageprintuiapp.cpp
usbuis/imageprintui/src/imageprintuiappui.cpp
usbuis/imageprintui/src/imageprintuidocument.cpp
usbuis/imageprintui/src/notes.cpp
usbuis/imageprintui/src/notetimer.cpp
usbuis/imageprintui/src/requestmanager.cpp
usbuis/imageprintui/src/settingscontainer.cpp
usbuis/imageprintui/src/settingsitems.cpp
usbuis/imageprintui/src/settingsview.cpp
usbuis/imageprintuiprovider/data/1020E471.rss
usbuis/imageprintuiprovider/data/imageprintuiprovider.rss
usbuis/imageprintuiprovider/group/bld.inf
usbuis/imageprintuiprovider/group/imageprintuiprovider.mmp
usbuis/imageprintuiprovider/inc/aiwprintingprovideruid.h
usbuis/imageprintuiprovider/inc/caiwimageprintif.h
usbuis/imageprintuiprovider/inc/caiwprintingprovider.h
usbuis/imageprintuiprovider/inc/imageprintuidebug.h
usbuis/imageprintuiprovider/loc/imageprintuiprovider.loc
usbuis/imageprintuiprovider/rom/imageprintuiprovider.iby
usbuis/imageprintuiprovider/rom/imageprintuiproviderresources.iby
usbuis/imageprintuiprovider/src/caiwimageprintIf.cpp
usbuis/imageprintuiprovider/src/caiwprintingprovider.cpp
usbuis/imageprintuiprovider/src/dllmain.cpp
usbuis/usbui/USBClassChangeUIPlugin/data/1020E472.rss
usbuis/usbui/USBClassChangeUIPlugin/data/USBClassChangeUIPlugin.rss
usbuis/usbui/USBClassChangeUIPlugin/group/USBClassChangeUIPlugin.mmp
usbuis/usbui/USBClassChangeUIPlugin/group/bld.inf
usbuis/usbui/USBClassChangeUIPlugin/group/usbuiplugin_icons_dc.mk
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPlugin.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPlugin.hrh
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginCRWatcher.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginContainer.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginDebug.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginInterface.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginInterface.inl
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginModel.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginView.h
usbuis/usbui/USBClassChangeUIPlugin/inc/USBDeviceStateWatcher.h
usbuis/usbui/USBClassChangeUIPlugin/inc/usbotghoststatewatcher.h
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginCRWatcher.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginContainer.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginImplementationTable.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginModel.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginView.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBDeviceStateWatcher.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/usbotghoststatewatcher.cpp
usbuis/usbui/aif/USBClassChangeUI_caption.rss
usbuis/usbui/aif/USBClassChangeUIaif.rss
usbuis/usbui/data/USBClassChangeUI.rss
usbuis/usbui/data/USBClassChangeUI_reg.rss
usbuis/usbui/group/USBClassChangeUI.mmp
usbuis/usbui/group/bld.inf
usbuis/usbui/group/usbui_Icons_aif_scalable_dc.mk
usbuis/usbui/group/usbui_icons_aif_bitmaps_dc.mk
usbuis/usbui/help/data/xhtml.zip
usbuis/usbui/help/group/bld.inf
usbuis/usbui/help/inc/usb.hlp.hrh
usbuis/usbui/help/rom/usbuihelps_variant.iby
usbuis/usbui/inc/USBClassChangeUI.h
usbuis/usbui/inc/USBClassChangeUIApp.h
usbuis/usbui/inc/USBClassChangeUIAppUi.h
usbuis/usbui/inc/USBClassChangeUIDebug.h
usbuis/usbui/inc/USBClassChangeUIDocument.h
usbuis/usbui/loc/USBClassChangeUI.loc
usbuis/usbui/rom/USBClassChangeUI.iby
usbuis/usbui/rom/USBClassChangeUIResources.iby
usbuis/usbui/src/USBClassChangeUIApp.cpp
usbuis/usbui/src/USBClassChangeUIAppui.cpp
usbuis/usbui/src/USBClassChangeUIDocument.cpp
usbuis/usbui/tsrc/usbuiapitest/bmarm/usbuiapitestu.def
usbuis/usbui/tsrc/usbuiapitest/bwins/usbuiapitestu.def
usbuis/usbui/tsrc/usbuiapitest/conf/ui_usbuiapitest.cfg
usbuis/usbui/tsrc/usbuiapitest/eabi/usbuiapitestu.def
usbuis/usbui/tsrc/usbuiapitest/group/Bld.inf
usbuis/usbui/tsrc/usbuiapitest/group/build_sis_ats.bat
usbuis/usbui/tsrc/usbuiapitest/group/build_sis_phone.bat
usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.mmp
usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.pkg
usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest_phone.pkg
usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitest.h
usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitestdebug.inl
usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest.ini
usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest_phone.ini
usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitest.cpp
usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitestblocks.cpp
usbuis/usbuinotif/BWINS/usbavkonnotifu.def
usbuis/usbuinotif/data/102068DC.rss
usbuis/usbuinotif/data/usbuinotif.rss
usbuis/usbuinotif/eabi/usbavkonnotifu.def
usbuis/usbuinotif/group/bld.inf
usbuis/usbuinotif/group/usbuinotif.mmp
usbuis/usbuinotif/inc/usbnotifier.h
usbuis/usbuinotif/inc/usbuincableconnectednotifier.h
usbuis/usbuinotif/inc/usbuinotif.hrh
usbuis/usbuinotif/inc/usbuinotifdebug.h
usbuis/usbuinotif/inc/usbuinotifmsmmerror.h
usbuis/usbuinotif/inc/usbuinotifotgerror.h
usbuis/usbuinotif/inc/usbuinotifotgwarning.h
usbuis/usbuinotif/inc/usbuinqueriesnotifier.h
usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h
usbuis/usbuinotif/loc/usbuinotif.loc
usbuis/usbuinotif/rom/usbuinotif.iby
usbuis/usbuinotif/rom/usbuinotifresources.iby
usbuis/usbuinotif/src/usbnotifier.cpp
usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp
usbuis/usbuinotif/src/usbuinmain.cpp
usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp
usbuis/usbuinotif/src/usbuinotifotgerror.cpp
usbuis/usbuinotif/src/usbuinotifotgwarning.cpp
usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp
usbuis/usbuinotif/tsrc/usbuinotifapitest/bmarm/usbuinotifapitestu.def
usbuis/usbuinotif/tsrc/usbuinotifapitest/bwins/usbuinotifapitestu.def
usbuis/usbuinotif/tsrc/usbuinotifapitest/conf/ui_usbuinotifapitest.cfg
usbuis/usbuinotif/tsrc/usbuinotifapitest/eabi/usbuinotifapitestu.def
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/bld.inf
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_ats.bat
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_phone.bat
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.mmp
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.pkg
usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest_phone.pkg
usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitest.h
usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitestdebug.inl
usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest.ini
usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest_phone.ini
usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitest.cpp
usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitestblocks.cpp
usbuis/usbuiqt/icons/usb_icon_mode_2.svg
usbuis/usbuiqt/icons/usb_icon_mode_4.svg
usbuis/usbuiqt/icons/usb_icon_mode_5.svg
usbuis/usbuiqt/inc/mydebug.h
usbuis/usbuiqt/inc/usbmainview.h
usbuis/usbuiqt/inc/usbuimodelactive.h
usbuis/usbuiqt/inc/usbuisettingmodel.h
usbuis/usbuiqt/inc/usbviewmanager.h
usbuis/usbuiqt/rom/usbsettings.iby
usbuis/usbuiqt/rom/usbsettingsresources.iby
usbuis/usbuiqt/src/main.cpp
usbuis/usbuiqt/src/usbapplication.qm
usbuis/usbuiqt/src/usbapplication.qrc
usbuis/usbuiqt/src/usbapplication.ts
usbuis/usbuiqt/src/usbapplication.xls
usbuis/usbuiqt/src/usbapplication_reg.rss
usbuis/usbuiqt/src/usbicons.qrc
usbuis/usbuiqt/src/usbmainview.cpp
usbuis/usbuiqt/src/usbuimodelactive.cpp
usbuis/usbuiqt/src/usbuisettingmodel.cpp
usbuis/usbuiqt/src/usbview.docml
usbuis/usbuiqt/src/usbviewmanager.cpp
usbuis/usbuiqt/usbapplication.pro
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for package usbservices
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+#include "../usbservices_plat/group/bld.inf"
+#include "../usbengines/group/bld.inf"
+#include "../usbclasses/group/bld.inf"
+#include "../usbuis/group/bld.inf"
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_5_1.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/usbservices" >
+]>
+
+<SystemDefinition name="usbservices" schema="1.5.1">
+  <systemModel>
+    <layer name="mw_layer">
+      <module name="usbservices">
+        <unit unitID="lcdo.usbservices" mrp="" bldFile="&layer_real_source_path;/group" name="usbservices" />
+      </module>
+      <module name="non_sf_components">
+        <unit unitID="lcdo.usbservices.usbclasses.usbosdescriptorhandler" mrp="" bldFile="&layer_real_source_path;/usbclasses/usbosdescriptorhandler/group" filter="!sf_build" name="usbservices_usbclasses_usbosdescriptorhandler" />
+        <unit unitID="lcdo.usbservices.usbclasses.msmmplugin" mrp="" bldFile="&layer_real_source_path;/usbclasses/msmmplugin/group" filter="!sf_build" name="usbservices_usbclasses_msmmplugin" />
+        <unit unitID="lcdo.usbservices.usbclasses.usbhidclassdriver" mrp="" bldFile="&layer_real_source_path;/usbclasses/usbhidclassdriver/group" filter="!sf_build" name="usbservices_usbclasses_usbhidclassdriver" />
+        <unit unitID="lcdo.usbservices.usbuis.rndisui" mrp="" bldFile="&layer_real_source_path;/usbuis/rndisui/group" filter="!sf_build" name="usbservices_usbuis_rndisui" />
+      </module>
+      <module name="usbuiqt">
+        <unit unitID="lcdo.usbservices.usbclasses.usbuiqt" mrp="" bldFile="&layer_real_source_path;/usbuis/usbuiqt" name="usbservices_usbuis_usbapplication" proFile="usbapplication.pro" qmakeArgs="" />
+      </module>
+    </layer>
+    <layer name="api_test_layer">
+      <module name="usbservices_test">
+        <unit unitID="lcdo.usbservices_test" mrp="" bldFile="&layer_real_source_path;/tsrc/group" name="usbservices_test" />
+      </module>
+    </layer>    
+  </systemModel>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="usbservices" name="USB Services" levels="framework server generic specific plugin">
+    <collection id="usbclasses" name="USB Classes" level="framework">
+      <component id="usbobexclasscontroller" filter="s60" name="USB OBEX Class Controller" class="plugin">
+        <unit bldFile="usbclasses/usbobexclasscontroller/group"/>
+      </component>
+      <component id="usbbasicpersonality" filter="s60" name="USB Basic Personality"  class="plugin">
+        <unit bldFile="usbclasses/usbbasicpersonality/group"/>
+      </component>
+      <component id="usbmscpersonality" filter="s60" name="USB MSC Personality" class="plugin">
+        <unit bldFile="usbclasses/usbmscpersonality/group"/>
+      </component>
+      <component id="pictbridgeengine" filter="s60" name="PictBridge Engine">
+        <unit bldFile="usbclasses/pictbridgeengine/group"/>
+      </component>
+      <component id="usbphoneasmodem" filter="s60" name="USB Phone as Modem" introduced="^3">
+        <unit bldFile="usbclasses/usbphoneasmodem/group"/>
+      </component>
+    </collection>
+    <collection id="usbengines" name="USB Engines" level="generic">
+      <component id="usbwatcher" filter="s60" name="USB Watcher">
+        <unit bldFile="usbengines/usbwatcher/group"/>
+      </component>
+      <component id="usblocodplugin" filter="s60" name="USB Local Connectivity Domain Plugin" class="plugin">
+        <unit bldFile="usbengines/usblocodplugin/group"/>
+      </component>
+      <component id="usbdevcon" filter="s60" name="USB Device Control">
+        <unit bldFile="usbengines/usbdevcon/group"/>
+      </component>
+      <component id="usbremotepersonality" filter="s60" name="USB Remote Personality">
+        <unit bldFile="usbengines/usbremotepersonality/group"/>
+      </component>
+      <component id="usbotgwatcher" filter="s60" name="USB OTG Watcher" introduced="^3">
+        <unit bldFile="usbengines/usbotgwatcher/group"/>
+      </component>
+    </collection>
+    <collection id="usbuis" name="USB UIs" level="specific">
+      <component id="usbui" filter="s60" name="USB UI">
+        <unit bldFile="usbuis/usbui/group"/>
+      </component>
+      <component id="usbuinotif" filter="s60" name="USB UI Notifiers">
+        <unit bldFile="usbuis/usbuinotif/group"/>
+      </component>
+      <component id="imageprintuiprovider" filter="s60" name="ImagePrint UI Provider" class="plugin">
+        <unit bldFile="usbuis/imageprintuiprovider/group"/>
+      </component>
+      <component id="usbimageprintui" filter="s60" name="ImagePrint UI">
+        <unit bldFile="usbuis/imageprintui/group"/>
+      </component>
+    </collection>
+    <collection id="usbservices_info" name="USB Services Info" level="plugin">
+      <component id="usbservices_plat" filter="s60" name="USB Services Platform Interfaces" class="api">
+        <unit bldFile="usbservices_plat/group"/>
+      </component>
+      <component id="usbservices_test" filter="s60,test,api_test" name="USB Services Tests">
+        <unit bldFile="tsrc/group"/>
+      </component>
+    </collection>        
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_5_1.dtd	Fri Jun 04 10:27:39 2010 +0100
@@ -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>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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 
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+//build files for shortlinkconn
+#include "../../../shortlinkconn/localconnectivityservice/generichid/tsrc/GenericHidTest/group/bld.inf"
+
+//build files for usb
+#include "../../usbclasses/msmmplugin/tsrc/MsmmPluginTest/group/bld.inf"
+#include "../../usbuis/usbui/tsrc/USBUiApiTest/group/bld.inf"
+#include "../../usbuis/usbuinotif/tsrc/USBUiNotifApiTest/group/bld.inf"
+#include "../../usbclasses/usbhidclassdriver/tsrc/UsbHidClassDriverTest/group/bld.inf"
+
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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 usbclasses
+*
+*/
+
+
+#include "../usbobexclasscontroller/group/bld.inf"
+#include "../usbbasicpersonality/group/bld.inf"
+#include "../usbmscpersonality/group/bld.inf"
+//#include "../ptpstack/group/bld.inf"
+//#include "../sicdusbplugin/group/bld.inf"
+//#include "../ptpserver/group/bld.inf"
+#include "../pictbridgeengine/group/bld.inf"
+#include "../usbphoneasmodem/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/pictbridgeengine/BWINS/pictbridgeU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/EABI/pictbridgeU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/group/pictbridge.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dps.rh	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsconnectnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsconst.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsdefs.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsfile.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsfile.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsoperation.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsoperation.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsparam.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsparam.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsptpnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsscriptreceiver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsscriptsender.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsstate.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsstatemachine.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsstatemachine.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpstransaction.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpstransaction.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsusbnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsxmlgenerator.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsxmlparser.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsxmlparser.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/dpsxmlstring.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/inc/pictbridge.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/rom/pictbridge.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dps.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsconnectnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsfile.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsoperation.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsparam.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsptpnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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: 10.1.4 % 
+*
+*/
+
+
+#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/usbclasses/pictbridgeengine/src/dpsscriptreceiver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsscriptsender.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsstate.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsstatemachine.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpstransaction.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsusbnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsxmlgenerator.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsxmlparser.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/dpsxmlstring.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbclasses/pictbridgeengine/src/pictbridge.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/group/UsbBasicPersonality.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Project definition file for project UsbBasicPersonality
+*
+*/
+
+#include <platform_paths.hrh>
+
+target usbbasicpersonality.dll
+UID              	0x10009d8d 0x10274797
+VENDORID      VID_DEFAULT
+
+CAPABILITY    LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ
+targettype plugin
+
+SOURCEPATH ../src
+SOURCE CUsbActiveBasicHandler.cpp UsbActiveBasicHandlerImp.cpp
+USERINCLUDE ../inc
+
+systeminclude ../../../inc
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/ecom
+
+start resource 10274797.rss
+target usbbasicpersonality.rsc
+end
+
+LIBRARY euser.lib
+LIBRARY usbpersonality.lib
+
+DEBUGLIBRARY  flogger.lib            // File logging
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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 UsbBasicPersonality
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+../group/UsbBasicPersonality.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+../rom/UsbBasicPersonality.iby CORE_MW_LAYER_IBY_EXPORT_PATH(UsbBasicPersonality.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/inc/CUsbActiveBasicHandler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* 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:  Header file for CUsbActiveBasicHandler
+*
+*/
+
+
+#ifndef C_CUSBACTIVEBASICHANDLER_H
+#define C_CUSBACTIVEBASICHANDLER_H
+
+#include "cusbpersonalityplugin.h"
+
+class RUsb;
+
+/**
+*  Class to handle basic personalities.
+*
+*  @lib euser.lib
+*  @since Series 60 3.0
+*/
+class CUsbActiveBasicHandler : public CUsbPersonalityPlugin
+    {
+public:  // Constructors and destructor
+        
+    /**
+     * Two-phased constructor.
+     * @param aPersonalityParams Reference to the container class.
+     * @return pointer to created object
+     */
+    static CUsbActiveBasicHandler* NewL(TUsbPersonalityParams& aPersonalityParams);
+        
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbActiveBasicHandler();
+
+public: // from base class CUsbPersonality        
+        
+    /**
+     * From CUsbPersonality
+     * Called when personality will be changed. In this personality 
+     * no actions is taken.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */        
+    virtual void ConfirmPersonalityUnload(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality start needs to be 
+     * prepared. Nothing is done in this personality.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void PreparePersonalityStart(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality start needs to be 
+     * finished. For this personality: Show infonote to user.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void FinishPersonalityStart(TRequestStatus& aStatus);
+                
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality stop needs to be 
+     * prepared. For this personality: Do nothing.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void PreparePersonalityStop(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality stop needs to be 
+     * finished. For this personality: Do nothing.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void FinishPersonalityStop(TRequestStatus& aStatus);
+        
+    /**
+     * From CUsbPersonality
+     * State change notify
+     *
+     * @since Series 60 3.0
+     * @param aState state of the device
+     */
+    virtual void StateChangeNotify( TUsbDeviceState aState );
+
+public: // from base class CActive
+
+    /**
+     * From CActive.
+     * Left empty in this implementation.
+     *
+     * @since Series 60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Left empty in this implementation.
+     *
+     * @since Series 60 3.0
+     * @param aError the error returned
+     * @return error
+     */
+    TInt RunError( TInt /*aError*/ );
+
+    /**
+     * From CActive
+     * Left empty in this implementation.
+     *
+     * @since Series 60 3.0        
+     */
+    void DoCancel();
+
+protected:
+
+    /**
+     * C++ default constructor (no implementation provided).
+     */
+    CUsbActiveBasicHandler(TUsbPersonalityParams& aPersonalityParams);
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+
+    // Prohibit copy constructor when not deriving from CBase.
+    CUsbActiveBasicHandler( const CUsbActiveBasicHandler& );
+    // Prohibit assigment operator when not deriving from CBase.
+    CUsbActiveBasicHandler& operator=( const CUsbActiveBasicHandler& );
+
+private:    // Data
+    /**
+     * Request to completed later
+     */
+    TRequestStatus* iRequestStatus;
+    };
+
+#endif   // USBACTIVECDCHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* 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:  Debug macros
+*
+*/
+
+
+#ifndef _USBWATCHER_DEBUG_H
+#define _USBWATCHER_DEBUG_H
+
+#ifdef _DEBUG
+
+// Enable this to enable memory tracing
+//#define MEMTRACE
+
+// Following define is to enable OOM
+// situations in SRCS
+// SHOULD NEVER BE IN RELEASES.
+//#define TEST_OOM
+
+#ifdef __WINS__
+
+// File logging for WINS
+#define __FLOGGING__
+
+#else
+
+// Logging with RDebug for target HW
+#define __CLOGGING__
+//#define __FLOGGING__
+
+
+#endif //__WINS__
+
+#endif
+
+#if defined ( __FLOGGING__ )
+
+_LIT( KLogFile,"UsbWatcher.txt" );
+_LIT( KLogDir,"usb" );
+
+#include <f32file.h>
+#include <flogger.h>
+
+#define FLOG( a ) { FPrint( a ); }
+
+#define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
+
+#define FTRACE( a ) { a; }
+// 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 );
+
+    // If memory tracing is activated.
+#ifdef MEMTRACE
+    TInt size;
+    User::Heap().AllocSize( size );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBWATCHER]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
+#endif
+}
+
+inline void FHex( const TUint8* aPtr, TInt aLen )
+{
+    RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
+}
+
+inline void FHex( const TDesC8& aDes )
+{
+    FHex( aDes.Ptr(), aDes.Length() );
+}
+
+// RDebug logging
+#elif defined(__CLOGGING__)
+
+#include <e32svr.h>
+
+#define FLOG( a ) { RDebug::Print( a ); }
+
+#define FLOGHEX( a )
+
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TInt tmpInt = VA_ARG( list, TInt );
+    TInt tmpInt2 = VA_ARG( list, TInt );
+    TInt tmpInt3 = VA_ARG( list, TInt );
+    VA_END( list );
+    RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
+}
+
+
+#else   // No loggings --> reduced code size
+#define FLOG( a )
+#define FLOGHEX( a )
+#define FTRACE( a )
+
+#endif //_DEBUG
+
+#endif // USBWATCHER_DEBUG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/rom/UsbBasicPersonality.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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:  Image description file for project UsbBasicPersonality
+*
+*/
+
+
+#ifndef USBBASICPERSONALITY_IBY__
+#define USBBASICPERSONALITY_IBY__
+
+#ifdef __USB_MULTIPERSONALITY
+ECOM_PLUGIN(usbbasicpersonality.dll, 10274797.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/src/10274797.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* 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:  Resource definitions for project UsbBasicPersonality
+*
+*/
+
+
+#include "registryinfo.rh"
+#include <bldvariant.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x10274797;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10274793;
+
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102068DF;
+					version_no = 1;
+					display_name = "PC Suite";
+					default_data = "80000001";
+					opaque_data = "";
+					}
+#ifdef __USB_PTP
+				,
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10274792; //
+					version_no = 1;
+					display_name = " PTP Personality ";
+					default_data = "80000003"; //
+					opaque_data = " ";
+					}    
+#endif //__USB_PTP
+				,
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10282C70; //
+					version_no = 1;
+					display_name = " Media Transfer ";
+					default_data = "80000004"; //
+					opaque_data = " ";
+					}    
+				,
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2000B5D2; 
+					version_no = 1;
+					display_name = "PC Suite";
+					default_data = "80000005"; //
+					opaque_data = " ";
+					}
+				,
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x20029E41; 
+					version_no = 1;
+					display_name = "Phone as Modem";
+					default_data = "80000006"; //
+					opaque_data = " ";
+					}
+				,
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0xA000EA04;
+					version_no = 1;
+					display_name = "RNDIS";
+					default_data = "80000008";
+					opaque_data = " ";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/src/CUsbActiveBasicHandler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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:  Basic personality implementation
+*
+*/
+
+
+#include <usbuinotif.h>
+#include "CUsbActiveBasicHandler.h"
+#include "cusbpersonalitynotifier.h"
+#include "debug.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveBasicHandler::CUsbActiveBasicHandler(TUsbPersonalityParams& aPersonalityParams)
+    : CUsbPersonalityPlugin(aPersonalityParams)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::ConstructL()
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler: ConstructL" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveBasicHandler* CUsbActiveBasicHandler::NewL(TUsbPersonalityParams& aPersonalityParams)
+    {
+    CUsbActiveBasicHandler* self 
+        = new ( ELeave ) CUsbActiveBasicHandler(aPersonalityParams);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+    
+// Destructor
+CUsbActiveBasicHandler::~CUsbActiveBasicHandler()
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler::~CUsbActiveBasicHandler" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// This function will not be called.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::RunL()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActiveBasicHandler::RunError( TInt /*aError*/ )
+    {
+    // Currently no leaving functions called in RunL, thus nothing should cause
+    // this to be called -> return.
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// This is called before personality change is done.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::ConfirmPersonalityUnload(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler::ConfirmPersonalityUnload" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    User::RequestComplete(iRequestStatus, KErrNone);        
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality start needs to be prepared.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::PreparePersonalityStart(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler: PreparePersonalityStart" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    User::RequestComplete(iRequestStatus, KErrNone);    
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality start needs to be finished. 
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::FinishPersonalityStart(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler: FinishPersonalityStart" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;    
+    User::RequestComplete(iRequestStatus, KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality stop needs to be prepared. 
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::PreparePersonalityStop(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler: PreparePersonalityStop" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    User::RequestComplete(iRequestStatus, KErrNone);    
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality stop needs to be finished. 
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::FinishPersonalityStop(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler: FinishPersonalityStop" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    User::RequestComplete(iRequestStatus, KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// Indicates USB device state change to personality when USB is started.
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveBasicHandler::StateChangeNotify( TUsbDeviceState /*aState*/ )
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler::StateChangeNotify" ) );    
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveBasicHandler::DoCancel()
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveBasicHandler::DoCancel" ) );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbbasicpersonality/src/UsbActiveBasicHandlerImp.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Implementations using basic personality
+*
+*/
+
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include <bldvariant.hrh>
+#include "CUsbActiveBasicHandler.h"
+
+/**
+ * Define the private interface UIDs
+ */
+const TImplementationProxy UsbPersonalityImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0x102068DF, CUsbActiveBasicHandler::NewL)
+	,IMPLEMENTATION_PROXY_ENTRY(0x10274792, CUsbActiveBasicHandler::NewL)
+	,IMPLEMENTATION_PROXY_ENTRY(0x10282C70, CUsbActiveBasicHandler::NewL)
+    ,IMPLEMENTATION_PROXY_ENTRY(0x2000B5D2, CUsbActiveBasicHandler::NewL) // PCS+MTP
+    ,IMPLEMENTATION_PROXY_ENTRY(0x20029E41, CUsbActiveBasicHandler::NewL) // PhoneAsModem
+    ,IMPLEMENTATION_PROXY_ENTRY(0xA000EA04, CUsbActiveBasicHandler::NewL) // RNDIS
+    };
+
+/**
+ * Return number of implementations
+ */
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(UsbPersonalityImplementationTable) / sizeof(TImplementationProxy);
+
+    return UsbPersonalityImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/group/UsbMscPersonality.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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 UsbMscPersonality
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+target usbmscpersonality.dll
+UID              	0x10009d8d 0x10274798
+VENDORID      VID_DEFAULT
+
+CAPABILITY    LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ
+targettype plugin
+
+SOURCEPATH ../src
+
+SOURCE CUsbActiveMscHandlerMdrv.cpp
+SOURCE UsbActiveMscHandlerImp.cpp
+SOURCE CUsbMscPersonalityTimer.cpp
+
+USERINCLUDE ../inc
+
+systeminclude ../../../inc
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/ecom
+
+start resource 10274798.rss
+target usbmscpersonality.rsc
+end
+
+LIBRARY euser.lib
+LIBRARY usbpersonality.lib
+LIBRARY usbman.lib
+LIBRARY       centralrepository.lib // Central Repository (USB Personality API)
+LIBRARY       efsrv.lib             // File Server Client Side API
+LIBRARY       ProfileEng.lib        // Profiles Engine API
+LIBRARY       msgs.lib              // Messaging API
+LIBRARY       featmgr.lib           // Feature Manager API
+
+DEBUGLIBRARY  flogger.lib            // File logging
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for project UsbMscPersonality
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+../group/UsbMscPersonality.mmp
+
+PRJ_EXPORTS
+../rom/UsbMscPersonality.iby CORE_MW_LAYER_IBY_EXPORT_PATH(UsbMscPersonality.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/inc/CUsbActiveMscHandlerMdrv.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,431 @@
+/*
+* 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:  Header file for class CUsbActiveMscHandler
+*
+*/
+
+
+#ifndef C_CUSBACTIVEMSCHANDLER_H
+#define C_CUSBACTIVEMSCHANDLER_H
+
+#include <usbmsshared.h>        // for P&S used in following MMC states
+#include <f32file.h> // for file system dismounting and mounting
+#include <usb.h>
+#include <e32property.h>
+#include <usbuinotif.h>
+#include <cusbpersonalitynotifier.h>
+#include <cusbpersonalityplugin.h>
+
+// FORWARD DECLARATIONS
+class CUsbActivePowerManager;
+class CUsbMscPersonalityTimer;
+class CRepository;
+class CDevEncSessionBase;
+
+/**
+* Define system state categories used internally by Msc personality plugin
+*/
+enum TUsbGlobalSystemState
+    {
+    EUsbGSStateUnknown = -1,
+    EUsbGSStateCategoryNormal, //rfOn, rfOff, BTSAP
+    EUsbGSStateCharging
+    };
+
+/**
+* The file system mounted to the drive. 
+*/
+enum TUsbFileSystem
+    {
+    EFsyNone = 0, //no file system mounted
+    EFsyMassStorage,
+    EFsyFat
+    };
+
+/**
+*  Class to handle Mass Storage personality (= MSDC).
+*
+*  @lib euser.lib c32.lib efsrv.lib
+*  @since Series 60 3.0
+*/
+class CUsbActiveMscHandler : public CUsbPersonalityPlugin
+    {
+public:  // Constructors and destructor
+        
+    /**
+     * Two-phased constructor.
+     *
+     * @param aPersonalityParams Reference to container class
+     * @return Pointer to created object.
+     */
+     static CUsbActiveMscHandler* NewL(TUsbPersonalityParams& aPersonalityParams);
+        
+     /**
+      * Destructor.
+      */
+    virtual ~CUsbActiveMscHandler();
+
+public: // From base classes CActive
+
+    /**
+     * From CActive.
+     * Implements state machine for this class.
+     *
+     * @since Series 60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Never called in this implementation.
+     *
+     * @since Series 60 3.0
+     * @param aError the error returned
+     * @return error
+     */
+    TInt RunError( TInt /*aError*/ );
+
+    /**
+     * From CActive.
+     * Cancel outstanding request.
+     *
+     * @since Series 60 3.0
+     */
+    void DoCancel();
+
+public: // From base class CUsbPersonality
+
+    /**
+     * From CUsbPersonality
+     * Confirm unload in case of personality change 
+     * if msc state is active.
+     *
+     * @since S60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void ConfirmPersonalityUnload(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality start needs to be
+     * prepared.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void PreparePersonalityStart(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality start needs to be
+     * finished. Calls DoFinishPersonalityStartL() and provides error
+     * handling for it.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void FinishPersonalityStart(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality stop needs to be 
+     * prepared. For this personality: Remounts FAT File System and 
+     * dismounts Mass Storage File System, Switch back from offline mode.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+    virtual void PreparePersonalityStop(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbPersonality
+     * Called by personality handler when personality stop needs to be 
+     * finished. Calls DoFinishPersonalityStopL() and provides error
+     * handling for it.
+     *
+     * @since Series 60 3.0
+     * @param aStatus Status of the ended operation.
+     */
+     virtual void FinishPersonalityStop(TRequestStatus& aStatus);
+        
+    /**
+     * From CUsbPersonality
+     * State change notify
+     *
+     * @since Series 60 3.0
+     * @param aState state of the device
+     */
+    virtual void StateChangeNotify( TUsbDeviceState aState );
+        
+public:
+
+    /**
+     * If dismount timer expires, this callback is called.
+     *
+     * @since Series 60 3.2
+     * @param aPtr Pointer to this class
+     * @return KErrNone is always returned
+     */
+    static TInt DismountFatCallBack(TAny* aPtr);
+                            
+private:
+
+    /**
+     * Does the forced dismount.
+     *
+     * @since Series 60 3.2
+     */
+    void ForciblyDismountFat();
+
+    /**
+     * Complete owner class request if any.
+     *
+     * @since Series 60 3.2
+     */
+    void CompleteRequest(TInt aError);
+                
+    /**
+     * Start dismounting FAT from the drives
+     * Also mounts mass storage file system, when all FATs dismounted.
+     *
+     * @since Series 60 5.0
+     */
+    void StartDismountFat();
+
+    /**
+     * Add mass storage file system.
+     *
+     * @return KErrNone if successful or already added
+     * @since Series 60 3.2
+     */
+    TInt AddMassStorageFileSystem();
+                        
+    /**
+     * Remove mass storage file system.
+     *
+     * @since Series 60 5.0
+     */
+    void RemoveMassStorageFileSystem();
+                        
+    /**
+     * Mount mass storage to all the drives
+     * The mass storage is mounted to all the drives in normal global
+     * system state. If device is not locked, the drives are mounted also in 
+     * charging global system state. 
+     */
+    void MountMassStorage();
+                        
+    /**
+     * Returns drives with available MMC card.
+     * @param aDrivesWithMmcInserted Array to which result should be written
+     */
+    TInt GetDrives();
+
+    /**
+     * Dismounts FAT File System from the drive.
+     * @param aDrive Drive from which dismounting should be done
+     */
+    void DismountFat( TInt aDrive );
+
+    /**
+     * Mounts Mass Storage File System into the drive.
+     * @param aDrive Drive to which mounting should be done
+     * @return error
+     */
+    TInt TryMountMassStorage( TInt aDrive );
+
+    /**
+     * Dismounts Mass Storage File System from the drive.
+     * @param aDrive The drive for the dismount
+     * @return error
+     */
+    TInt TryDismountMassStorage( TInt aDrive );
+
+    /**
+     * Mounts FAT File System to the drive.
+     * @param aDrive The drive for the mount
+     * @return error
+     */
+    TInt TryMountFat( TInt aDrive );
+
+    /**
+     * C++ constructor
+     */
+    CUsbActiveMscHandler(TUsbPersonalityParams& aPersonalityParams);
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+        
+    /**
+     * Get global system state
+     * @return state
+     */     
+    TUsbGlobalSystemState GlobalSystemState();
+    
+    /**
+     * Check if device is (scheduled to be) locked or not
+     * @return ETrue/EFalse
+     */     
+    TBool DeviceLocked();
+    
+    /**
+     * Get Lock Time setting
+     * @return time
+     */     
+    TInt AutoLockTime();
+    
+    /**
+     * Get lock status setting
+     * @return status
+     */     
+    TInt AutoLockStatus();
+
+    /**
+     * Unmount Mass storage
+     * This is the reverse of StartMountMassStorage.
+     *
+     * @since Series 60 5.0
+     */
+    void UnmountMassStorage();
+
+    /**
+     * Get the file system mounted to the drive
+     *
+     * @param aDrive The drive which file system is required.
+     * @return The file system. 
+     * @since Series 60 5.0
+     */
+    TUsbFileSystem GetDriveFileSystem( TInt aDrive );
+
+    /**
+     * Tells whether device encryption is supported on device or not.
+     *
+     * @param None
+     * @return TBool 
+     * @since TimeBox 9.2
+     */
+    TBool IsDeviceEncryptionSupportedL();
+    
+	/**
+     * Tells whether device encryption is supported on device or not.
+     *
+     * @param  aDriveLetter pass in the drive that need to be checked
+     * @return TBool
+     * @since TimeBox 9.2
+     */
+	TBool IsEncProtectionRequired(const TInt& aDriveLetter);
+	
+	/**
+     * Dynamic load devenccommonutils.dll.
+     *
+     * @param  None
+     * @since TimeBox9.2
+     */
+	void LoadDevEncSessionL();
+	
+	/**
+     * Unload devenccommonutils.dll.
+     *
+     * @param  None
+     * @since TimeBox9.2
+     */
+	void UnloadDevEncSession();
+
+	 
+private: // Data
+    /**
+     * define the states of Mass Storage personality
+     */
+    enum TUsbMscState
+        {
+        EUsbMscStateIdle,
+        EUsbMscStateStarting,
+        EUsbMscStateMounting,
+        EUsbMscStateFileTransfer,
+        EUsbMscStateStopping,
+        EUsbMscStateForciblyDismounting
+        };
+
+    /**
+     * state of Mass Storage Class
+     */
+    TUsbMscState iMscState;
+
+    /**
+     * File server session handle
+     */
+    RFs iFs;
+    
+    /** 
+     * Indicates whether MSFS has already been added to file server
+     */
+    TBool iMsfsAdded;
+
+    /**
+     * Request to complete later
+     */
+    TRequestStatus* iRequestStatus;
+
+    /**
+     * removable drives in the system
+     */
+    RArray<TInt> iDrives;
+    
+    /**
+     * Needed for multiple drive support
+     */
+    TInt iDriveIndex;
+    
+    /**
+     * Dismount timer: If expired forced dismount used.
+     */
+    CUsbMscPersonalityTimer* iDismountFatTimer;
+    
+    /**
+     * Packages for queries
+     */
+    TUSBQueriesNotifierParamsPckg iQueryParams;
+    
+    /**
+     * Dummy stores for queries and notes
+     */
+    TBuf8<1> iDummy;
+    
+    /**
+     * Used to get device lock settings
+     */
+    CRepository* iRepository;
+    
+    /**
+     * FAT has been unmounted or MSC mounted.
+     */
+    TBool iMountChanged;
+
+    /**
+     * If query note shown by us
+     */
+    TBool iIsQueryNoteShown;
+    
+    /**
+     * Used to load devenccommonutils.dll and check the device encryption status
+     */
+    RLibrary iLibrary;
+    CDevEncSessionBase* iDevEncSession;
+    };
+
+#endif   // USBACTIVEMSCHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/inc/CUsbMscPersonalityTimer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:  MSC Personality timer class
+*
+*/
+
+
+#ifndef C_CUSBMSCPERSONALITYTIMER_H
+#define C_CUSBMSCPERSONALITYTIMER_H
+
+class CUsbMscPersonalityTimer : public CActive
+    {
+public:
+    CUsbMscPersonalityTimer(TCallBack aCallBack,
+                      TTimeIntervalMicroSeconds32 aTime);
+    ~CUsbMscPersonalityTimer();
+        
+    void Start();
+    
+private:        
+    void DoCancel();
+    void RunL();
+    TInt RunError( TInt /*aError*/ );
+        
+    RTimer iTimer;
+    TCallBack iCallBack;
+    TTimeIntervalMicroSeconds32 iTime;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* 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:  Debug macros
+*
+*/
+
+
+#ifndef _USBWATCHER_DEBUG_H
+#define _USBWATCHER_DEBUG_H
+
+#ifdef _DEBUG
+
+// Enable this to enable memory tracing
+//#define MEMTRACE
+
+// Following define is to enable OOM
+// situations in SRCS
+// SHOULD NEVER BE IN RELEASES.
+//#define TEST_OOM
+
+#ifdef __WINS__
+
+// File logging for WINS
+#define __FLOGGING__
+
+#else
+
+// Logging with RDebug for target HW
+#define __CLOGGING__
+//#define __FLOGGING__
+
+
+#endif //__WINS__
+
+#endif
+
+#if defined ( __FLOGGING__ )
+
+_LIT( KLogFile,"UsbWatcher.txt" );
+_LIT( KLogDir,"usb" );
+
+#include <f32file.h>
+#include <flogger.h>
+
+#define FLOG( a ) { FPrint( a ); }
+
+#define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
+
+#define FTRACE( a ) { a; }
+// 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 );
+
+    // If memory tracing is activated.
+#ifdef MEMTRACE
+    TInt size;
+    User::Heap().AllocSize( size );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBWATCHER]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
+#endif
+}
+
+inline void FHex( const TUint8* aPtr, TInt aLen )
+{
+    RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
+}
+
+inline void FHex( const TDesC8& aDes )
+{
+    FHex( aDes.Ptr(), aDes.Length() );
+}
+
+// RDebug logging
+#elif defined(__CLOGGING__)
+
+#include <e32svr.h>
+
+#define FLOG( a ) { RDebug::Print( a ); }
+
+#define FLOGHEX( a )
+
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TInt tmpInt = VA_ARG( list, TInt );
+    TInt tmpInt2 = VA_ARG( list, TInt );
+    TInt tmpInt3 = VA_ARG( list, TInt );
+    VA_END( list );
+    RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
+}
+
+
+#else   // No loggings --> reduced code size
+#define FLOG( a )
+#define FLOGHEX( a )
+#define FTRACE( a )
+
+#endif //_DEBUG
+
+#endif // USBWATCHER_DEBUG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/inc/usbms.rh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 header for usbman configuration.
+*
+*/
+
+STRUCT USBMASSSTORAGE_CONFIG
+	{
+	LTEXT	vendorId;           // no more than 8 characters
+	LTEXT	productId;          // no more than 16 characters
+	LTEXT	productRev;        	// no more than 4 characters
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/rom/UsbMscPersonality.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Image description file for project usbmscpersonality
+*
+*/
+
+
+#ifndef __USBMSCPERSONALITY_IBY__
+#define __USBMSCPERSONALITY_IBY__
+//file content
+
+#ifdef __USB_MULTIPERSONALITY
+ECOM_PLUGIN(usbmscpersonality.dll, 10274798.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/src/10274798.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Resource definitions for project UsbMscPersonality
+*
+*/
+
+
+#include "registryinfo.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x10274798;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10274793;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020DF7B;
+					version_no = 1;
+					display_name = "Msc Personality";
+					default_data = "80000002";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/src/CUsbActiveMscHandlerMdrv.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1024 @@
+/*
+* 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:  Main class for UsbMscPersonality
+*
+*/
+
+#include <centralrepository.h>
+#include <AknSkinsInternalCRKeys.h>
+#include <usbman.h>
+#include <e32property.h>
+#include <tusbpersonalityparams.h>
+#include <startupdomainpskeys.h>
+#include <settingsinternalcrkeys.h>
+#include "CUsbActiveMscHandlerMdrv.h"
+#include "CUsbMscPersonalityTimer.h"
+#include "debug.h"
+
+#include <featmgr.h> // for checking DE feature
+#include <DevEncSessionBase.h>
+#include <DevEncEngineConstants.h>
+
+// LITERALS
+_LIT( KMsFs,"MSFS.FSY" );
+_LIT( KMsFsyName, "MassStorageFileSystem" );
+_LIT( KFatFsyName, "Fat" );
+
+const TUint32 KDismountFatTimeoutValue = 5000000; // 5 seconds
+const TInt KMscDismountRetryCount = 3;
+const TUint32 KWaitMscToComplete = 50000; // 50 ms
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveMscHandler::CUsbActiveMscHandler(TUsbPersonalityParams& aPersonalityParams)
+    : CUsbPersonalityPlugin(aPersonalityParams), 
+      iMountChanged(EFalse),
+      iIsQueryNoteShown(EFalse)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::ConstructL()
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler: ConstructL" ) );
+                    
+    iDismountFatTimer = new (ELeave) CUsbMscPersonalityTimer(
+        TCallBack(DismountFatCallBack, this), KDismountFatTimeoutValue);
+    
+    iMscState = EUsbMscStateIdle;
+    User::LeaveIfError(iFs.Connect());
+    iRepository = CRepository::NewL(KCRUidSecuritySettings); 
+    LoadDevEncSessionL();
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveMscHandler* CUsbActiveMscHandler::NewL(TUsbPersonalityParams& aPersonalityParams)
+    {
+    CUsbActiveMscHandler* self 
+        = new ( ELeave ) CUsbActiveMscHandler(aPersonalityParams);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+    
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbActiveMscHandler::~CUsbActiveMscHandler()
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::~CUsbActiveMscHandler" ) );
+    
+    if ( iMountChanged ) 
+        {        
+        UnmountMassStorage();
+        }
+
+    RemoveMassStorageFileSystem();
+    
+    Cancel();
+    delete iDismountFatTimer;
+
+    iDrives.Close();
+    iFs.Close();
+
+    delete iRepository;
+    UnloadDevEncSession();    
+    }
+
+// ----------------------------------------------------------------------------
+// State machine for the class.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::RunL()
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL error = %d" ),
+        iStatus.Int() ) );
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL iMscState = %d" ),
+        iMscState ) );
+    switch (iMscState)
+        {
+        case EUsbMscStateMounting:
+            // DismountFatTimer is not exprired but RunL called with error
+            if (KErrNone!=iStatus.Int())
+              {
+              /* Print error code, drive name and wait for timer to be expired expired (5sec) 
+               * which will call forcibly dismount*/
+              if(KErrNone!=iStatus.Int() )
+               {
+               FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL*** Drive Dismounting failed ") );
+               FTRACE( FPrint(
+                   _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL*** Dismount failed on DriveIndex= %d" ),
+                   iDriveIndex));
+               FTRACE( FPrint(
+                   _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL*** Dismount failed on Drive = %d" ),
+                   iDrives[iDriveIndex]) );
+               }
+              }
+            else
+              {
+              //dismount FAT done for one drive
+              if (iDismountFatTimer)
+               {
+               iDismountFatTimer->Cancel();
+               } 
+              StartDismountFat();
+              }
+            break;
+        case EUsbMscStateForciblyDismounting:
+            // If Even ForciblyDismount failed with error we cannot do much here, and just print Error message 
+            if(KErrNone!=iStatus.Int() )
+              {
+              FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::RunL*** FS has seroius dismounting problem" ) );
+              }
+            // we change the state and continue with other drives 
+            iMscState = EUsbMscStateMounting;                 
+            StartDismountFat();
+            break; 
+        default:
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Not possible to come here.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActiveMscHandler::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// This method always confirms the personality unloading.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::ConfirmPersonalityUnload(TRequestStatus& aStatus)
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler: ConfirmPersonalityUnload iMscState = %d" ),
+        iMscState ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    CompleteRequest(KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality start needs to be
+// prepared. Adds mass storage file system. 
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::PreparePersonalityStart(TRequestStatus& aStatus)
+    {
+    TInt ret = KErrNone;
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler: PreparePersonalityStart" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    iMscState = EUsbMscStateStarting;
+    ret = AddMassStorageFileSystem();
+    CompleteRequest(ret);
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality start needs to be finished.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::FinishPersonalityStart(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler: FinishPersonalityStart" ) );
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    CompleteRequest(KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality stop needs to be prepared. 
+// Changes state of the personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::PreparePersonalityStop(TRequestStatus& aStatus)
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler: PreparePersonalityStop" ) );
+
+    //Mounting may be ongoing
+    iRequestStatus = NULL; //do not complete in DoCancel
+    Cancel(); 
+    
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+
+    iMscState = EUsbMscStateStopping;
+
+    CompleteRequest(KErrNone);
+    }
+    
+// ----------------------------------------------------------------------------
+// Called by personality handler when personality stop needs to be finished. 
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::FinishPersonalityStop(TRequestStatus& aStatus)
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler: FinishPersonalityStop"));
+
+    //Mounting may be ongoing
+    iRequestStatus = NULL; //do not complete in DoCancel
+    Cancel(); 
+    
+    //unmount in case device state not yet Undefined
+    if (iMountChanged)
+        {
+        UnmountMassStorage();
+        }
+        
+    RemoveMassStorageFileSystem();
+
+    if (iIsQueryNoteShown)
+        {
+        // Remove all queries shown by this personality
+        iPersonalityParams.PersonalityNotifier().CancelQuery(KQueriesNotifier);
+        iIsQueryNoteShown = EFalse;
+        }
+        
+    iMscState = EUsbMscStateIdle;
+
+    iRequestStatus = &aStatus;
+    aStatus = KRequestPending;
+    CompleteRequest(KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// Indicates USB device state change to personality. 
+// There is no need to Cancel, because Confirm unload can not be ongoing 
+// before Address state. 
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveMscHandler::StateChangeNotify( TUsbDeviceState aState )
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::StateChangeNotify aState = %d" ),
+        aState ) );
+    switch( aState )
+        {        
+        //Note that Address state may be caused also by cable disconnection.
+        case EUsbDeviceStateAddress: 
+            {
+            //Do not start mounting if already ongoing 
+            //e.g. fast state changes Address-->Suspended-->Address
+            if ( !iMountChanged && (GetDrives() == KErrNone) )
+                {
+                if (iDrives.Count())
+                    {
+                    iDriveIndex = iDrives.Count();
+                    StartDismountFat();
+                    }
+                else
+                    {
+                    if ( GlobalSystemState() == EUsbGSStateCategoryNormal )
+                        {
+                        iIsQueryNoteShown = ETrue;
+                        // if the error is something abnormal, note still needs to be shown
+                        iQueryParams().iQuery = EUSBStorageMediaFailure;
+                        iPersonalityParams.PersonalityNotifier().ShowQuery(
+                            KQueriesNotifier, iQueryParams, iDummy);
+                        }            
+                    }    
+                }
+            
+            }
+            break;
+        case EUsbDeviceStateUndefined: 
+            {
+            if (iMountChanged)
+                {
+                UnmountMassStorage();
+                iMscState = EUsbMscStateIdle;
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::StateChangeNotify completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// Start FAT dismounting sequence.
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveMscHandler::StartDismountFat()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::StartDismountFat"));
+    iMountChanged = ETrue;
+
+    if (!iDriveIndex)
+        {
+        //FAT dismounted from all the drives
+        MountMassStorage();            
+        //MSFS mounted to all the drives
+        iMscState = EUsbMscStateFileTransfer;
+        }
+    else
+        {
+        --iDriveIndex;
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::StartDismountFat iDriveIndex = %d " ),
+            iDriveIndex) );
+        // see if FAT file system exists in drive and if it does, try to dismount it
+        DismountFat(iDrives[iDriveIndex]);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Add mass storage file system
+// ----------------------------------------------------------------------------
+// 
+TInt CUsbActiveMscHandler::AddMassStorageFileSystem()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::AddMassStorageFileSystem"));
+
+    TInt ret = KErrNone;
+    
+    // To be done only once during the lifetime of this object:
+    // 5b. add Mass Storage File System to the file server.
+    // (done like this to avoid Symbian crash)
+    if (!iMsfsAdded)
+        {
+        FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::AddMassStorageFileSystem: Loading MSFS" ) );
+        ret = iFs.AddFileSystem(KMsFs);
+        if ((ret != KErrNone) && (ret != KErrAlreadyExists))
+            {
+            FTRACE( FPrint(
+                _L( "[USBWATCHER]\tCUsbActiveMscHandler::AddMassStorageFileSystem: ERROR: MSFS loading failed. Code: %d " ),
+                ret) );
+            }
+        else
+            {
+            iMsfsAdded = ETrue;
+            if (ret == KErrAlreadyExists)
+                {
+                ret = KErrNone;
+                }
+            }
+        }
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::AddMassStorageFileSystem: ret=%d"), ret));
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Remove mass storage file system (MSFS) from file server
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveMscHandler::RemoveMassStorageFileSystem()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::RemoveMassStorageFileSystem"));
+    if (iMsfsAdded)
+        {
+        if (iFs.RemoveFileSystem(KMsFsyName) != KErrNone)
+            {
+            FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler: RemoveMassStorageFileSystem: MSFS not removed from file server." ) );
+            }
+        else
+            {
+            iMsfsAdded = EFalse;
+            }
+        }    
+    }
+
+// ----------------------------------------------------------------------------
+// Mount mass storage to all drives. Does not mount in charging state if device 
+// locked.
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveMscHandler::MountMassStorage()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::MountMassStorage"));
+    TInt ret = KErrNone;
+    TBool locked = DeviceLocked();
+    TUsbGlobalSystemState state = GlobalSystemState();
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::MountMassStorage: locked=%d, state=%d"), locked, state));
+
+    if ( (state == EUsbGSStateCategoryNormal) || 
+       (!locked && (state==EUsbGSStateCharging)) )
+        {
+        for ( TInt driveIndex = iDrives.Count() - 1; driveIndex >= 0; driveIndex-- )
+            {
+            // Try mount Mass Storage File System into drive.
+            ret = TryMountMassStorage(iDrives[driveIndex]);
+            if (ret != KErrNone)
+                {
+                FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::MountMassStorage: driveIndex=%d ret=%d"), 
+                    driveIndex, ret));
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Return removable drives in system.
+// ----------------------------------------------------------------------------
+//  
+TInt CUsbActiveMscHandler::GetDrives()
+    {    
+    TInt i;
+    TInt ret = KErrNone;
+    
+    // go through drives A-Z except for C and Z
+    TDriveInfo driveInfo;
+    iDrives.Reset();
+    
+    for (i = EDriveA; i < EDriveZ; i++)
+        {
+        // skip drive C: and get drive info
+        if ( EDriveC == i ) 
+            {
+            continue;
+            }
+        
+    // unmounting FAT from the card when a decrypting/encrypting operation
+    // is ongoing will corrupt the card, so it must be prevented.      
+	if( ( i == EDriveE ) || ( i == EDriveF ) )
+		{
+        if(IsEncProtectionRequired(i))
+			{
+			FTRACE( FPrint( _L(" Skipping drive %d"), i));
+			continue;
+			}
+		}
+        iFs.Drive(driveInfo, i);
+        
+        // if drive is not removable and local, it can be skipped
+        if ((driveInfo.iDriveAtt & (KDriveAttRemovable | KDriveAttLocal))
+            != (KDriveAttRemovable | KDriveAttLocal))
+            {
+            continue;
+            }    
+        
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::GetDrives, removable drive %d: MediaAtt: %d" ),
+            i,driveInfo.iMediaAtt ) );
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::GetDrives, removable drive %d: Media info: %d" ),
+            i, driveInfo.iType ) );
+
+        // The memory card may be locked. No memory card password query is shown. 
+        
+        FTRACE(FPrint(
+               _L("[USBWATCHER]\tCUsbActiveMscHandler::GetDrives: MMC inserted into drive %d"),
+               i) );
+        ret = iDrives.Append(i);
+        }
+        
+    if (!iDrives.Count())
+        {
+        FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::GetDrives: No removable drives found." ) );
+
+        iIsQueryNoteShown = ETrue;
+        iQueryParams().iQuery = EUSBStorageMediaFailure;
+        iPersonalityParams.PersonalityNotifier().ShowQuery(KQueriesNotifier, iQueryParams, iDummy);
+
+        return KErrNotFound;
+        }
+        
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Dismounts FAT File System.
+// ----------------------------------------------------------------------------
+//   
+void CUsbActiveMscHandler::DismountFat( TInt aDrive )
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::DismountFat" ) );
+    
+    //nothing to do if FAT file system not in aDrive
+    if ( GetDriveFileSystem(aDrive) != EFsyFat )
+        {
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::DismountFat: FAT FSY not found in drive %d" ),
+            aDrive ) );
+        //continue to the next drive
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete(status, KErrNotFound);
+        SetActive();
+        }
+    else
+        {
+        //FAT file system exists in aDrive -> dismount it
+        iFs.NotifyDismount(iDrives[iDriveIndex], iStatus, EFsDismountNotifyClients);
+        SetActive();
+
+        //Give some time for applications before dismounting forcefully
+        iDismountFatTimer->Start();
+        }
+
+    iMscState = EUsbMscStateMounting;
+    }
+
+// ----------------------------------------------------------------------------
+// Mounts Mass Storage File System into drive.
+// ----------------------------------------------------------------------------
+//  
+TInt CUsbActiveMscHandler::TryMountMassStorage( TInt aDrive )
+    {
+    FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountMassStorage" ) );
+    
+    TInt ret(KErrNone);
+    
+    ret = iFs.MountFileSystem( KMsFsyName, aDrive );
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountMassStorage: fs mount ret %d" ),
+        ret ) );
+    
+    if ( ret == KErrNotSupported )
+        {
+        // there is an error in environment and MSFS has been mounted into
+        // drive but mounting has been unsuccessful -> remove it
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountMassStorage: MS FSY not supported in drive %d" ),
+            aDrive ) );
+        return ret;
+        }
+    else if ((ret != KErrNone) && (ret != KErrNotReady))
+        {
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountMassStorage: ERROR %d in MS FSY mounting in drive %d" ),
+            ret, aDrive ) );
+        return ret;
+        }
+
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountMassStorage: MS FSY mounted in drive %d" ),
+        aDrive ) );
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Dismounts Mass Storage File System from the drive.
+// ----------------------------------------------------------------------------
+//  
+TInt CUsbActiveMscHandler::TryDismountMassStorage( TInt aDrive )
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryDismountMassStorage: drive %d" ),
+        aDrive ) );
+
+    // initializations
+    TInt ret = KErrNone;
+    TInt numTry = KMscDismountRetryCount; // How many times to try to dismount the drive
+    
+    //only dismount if mass storage mounted
+    if ( GetDriveFileSystem(aDrive) == EFsyMassStorage )
+        {
+        while ( numTry-- )
+            {
+            ret = iFs.DismountFileSystem( KMsFsyName, aDrive );
+            if ( ret != KErrNone )
+                {
+                if ( ret == KErrInUse )
+                    {
+                    // It may be that USB mass storage transfer is still in use 
+                    // when USB File transfer mode is tried to be distangled (this
+                    // method is entered). Wait for a while and try again.
+                    FTRACE( FPrint(
+                         _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryDismountMassStorage: Waiting MSFS dismounting for drive %d" ),
+                         aDrive ) );
+                    RTimer timer;
+                    TRequestStatus timerStatus;
+                    timer.CreateLocal(); // Create for this thread
+                    timer.After(timerStatus, KWaitMscToComplete);
+                    User::WaitForRequest( timerStatus );
+                    if ( timerStatus != KErrNone )
+                        {
+                        FTRACE( FPrint(
+                                _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryDismountMassStorage: ERROR: %d wait timer fails." ), 
+                                timerStatus.Int() ) );
+                        }
+                    timer.Close();
+                    }
+                else
+                    {
+                    FTRACE( FPrint(
+                        _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryDismountMassStorage: ERROR %d in dismounting MSFS from drive %d" ),
+                        ret, aDrive ) );
+                    break;
+                    }
+                }
+            else
+                {
+                FTRACE( FPrint(
+                    _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryDismountMassStorage: MSFS dismounted from drive %d" ),
+                    aDrive ) );
+                break;
+                }
+            } //while
+            
+            if ( ret == KErrInUse )
+                {
+                FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::TryDismountMassStorage using force"));
+                TRequestStatus dismountStatus;
+                iFs.NotifyDismount(aDrive, dismountStatus, EFsDismountForceDismount);
+                User::WaitForRequest(dismountStatus);
+                ret = dismountStatus.Int();
+                }
+            
+        }
+        else 
+            {
+            FTRACE( FPrint(
+                _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryDismountMassStorage: No MSFS on drive %d" ),
+                aDrive ) );
+            }
+
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryDismountMassStorage: returning %d" ),
+        ret ) );
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Mounts FAT File System to the drive
+// ----------------------------------------------------------------------------
+//  
+TInt CUsbActiveMscHandler::TryMountFat( TInt aDrive )
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::TryMountFat: drive %d" ),
+        aDrive ) );
+
+    // initializations
+    TInt ret = KErrNone;
+
+    // Mount back FAT only if there is no mounted file system
+    if ( GetDriveFileSystem(aDrive) == EFsyNone )
+        {
+        ret = iFs.MountFileSystem( KFatFsyName, aDrive );
+
+        FTRACE( FPrint(
+            _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryMountFat: return %d in mounting FAT into drive %d" ),
+            ret, aDrive ) );
+
+        if (ret != KErrNone)
+            {
+            FTRACE( FPrint(
+                _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryMountFat: ERROR %d in mounting FAT into drive %d" ),
+                ret, aDrive ) );
+            }
+        else
+            {
+            FTRACE( FPrint(
+                _L( "[USBWATCHER]\tCUsbActiveMscHandler: TryMountFat: FAT mounted into drive %d" ),
+                aDrive ) );
+            }
+        }
+
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::DoCancel()
+    {
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler: DoCancel iMscState=%d" ),
+        iMscState ) );
+
+    //Remove all notes. The state may have changed after the confirm unload
+    //is started.
+    if (iMscState != EUsbMscStateForciblyDismounting)
+        {
+        iPersonalityParams.PersonalityNotifier().CancelAll();
+        }
+
+    switch (iMscState)
+        {
+        case EUsbMscStateStarting:
+        case EUsbMscStateStopping:
+            break;
+
+        case EUsbMscStateMounting:
+        case EUsbMscStateForciblyDismounting:
+            if (iDismountFatTimer)
+                {
+                iDismountFatTimer->Cancel();
+                }
+            iFs.NotifyDismountCancel();
+            break;
+                        
+        default:
+            FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::DoCancel: ERROR"));        
+            break;
+        }
+
+    CompleteRequest(KErrCancel);
+    }
+    
+// ----------------------------------------------------------------------------
+// Complete request.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::CompleteRequest(TInt aError)
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::CompleteRequest"));
+
+    if (iRequestStatus)
+        {
+        User::RequestComplete(iRequestStatus, aError);
+        iRequestStatus = NULL;
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// If client doesn't allow us to do dismount, let's force it.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActiveMscHandler::DismountFatCallBack(TAny* aPtr)
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::DismountFatCallBack"));        
+    
+    CUsbActiveMscHandler* handler = static_cast<CUsbActiveMscHandler *>(aPtr);
+    
+    handler->ForciblyDismountFat();
+    
+    return KErrNone;
+    }
+    
+// ----------------------------------------------------------------------------
+// Forced dismount is done over here.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveMscHandler::ForciblyDismountFat()
+    {    
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::ForciblyDismountFat"));
+    
+    //cancel won't complete, since there is no client request ongoing
+    iMscState = EUsbMscStateForciblyDismounting; //do not close mode query
+    Cancel();
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::ForciblyDismountFat DriveIndex= %d" ),
+        iDriveIndex));
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler::ForciblyDismountFat on Drive = %d" ),
+        iDrives[iDriveIndex]) );
+    iFs.NotifyDismount(iDrives[iDriveIndex], iStatus, EFsDismountForceDismount);
+    SetActive();
+    }
+
+
+TUsbGlobalSystemState CUsbActiveMscHandler::GlobalSystemState()
+    {
+    TInt state = EUsbGSStateUnknown;
+    TUsbGlobalSystemState usbGlobalSysState = EUsbGSStateUnknown;
+    TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::GlobalSystemState: error %d, state %d"), error, state));
+    if ( (state == ESwStateNormalRfOn) || 
+         (state == ESwStateNormalRfOff) || 
+         (state == ESwStateNormalBTSap) )
+        {
+        usbGlobalSysState = EUsbGSStateCategoryNormal;
+        }
+    else if ( state == ESwStateCharging )
+        {
+        usbGlobalSysState = EUsbGSStateCharging;
+        }
+        
+    return usbGlobalSysState;;
+    }
+
+
+// ----------------------------------------------------------------------------
+// Determine whether the device is locked or not
+// ----------------------------------------------------------------------------
+//
+TBool CUsbActiveMscHandler::DeviceLocked()
+    {
+    TBool locked(EFalse);
+    if ( GlobalSystemState() == EUsbGSStateCharging )
+        {
+        if (AutoLockTime()>0 || AutoLockStatus()>0 )
+            {
+            locked=ETrue;
+            }
+        }
+    
+    return locked;
+    }
+
+// ----------------------------------------------------------------------------
+// Read Lock time settings
+// Meant to be used only in Charging mode
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActiveMscHandler::AutoLockTime()
+    {
+    TInt lockTime(0);
+    
+    TInt ret = iRepository->Get(KSettingsAutoLockTime, lockTime);
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::LockeTime: ret=%d. LockTime=%d"), ret, lockTime));
+
+    return lockTime;
+    }
+
+// ----------------------------------------------------------------------------
+// Read Lock status settings
+// Meant to be used only in Charging mode
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActiveMscHandler::AutoLockStatus()
+    {    
+    TInt lockStatus(0);
+    
+    TInt ret = iRepository->Get(KSettingsAutolockStatus, lockStatus);
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::AutoLockStatus: ret=%d. lockStatus=%d"), ret, lockStatus));
+    
+    return lockStatus;    
+    }
+    
+// ----------------------------------------------------------------------------
+// Unmount mass storage dismounts mass storage and mounts FAT for all drives. 
+// ----------------------------------------------------------------------------
+// 
+void CUsbActiveMscHandler::UnmountMassStorage()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::UnmountMassStorage"));        
+    //Mounting may be ongoing. Note that the confirm unload query and the mode
+    //query are closed. 
+    Cancel();
+
+    TInt index = iDrives.Count();
+    while ( index > 0 )
+        {
+        --index;
+        TInt drive = iDrives[index];
+        // First dismount mounted Mass Storage File System
+        TryDismountMassStorage(iDrives[index]);
+        // Then mount back previously dismounted FAT File System
+        TryMountFat(iDrives[index]);
+        }
+    iMountChanged = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// Return the mounted file system. 
+// ----------------------------------------------------------------------------
+// 
+TUsbFileSystem CUsbActiveMscHandler::GetDriveFileSystem( TInt aDrive )
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::GetDriveFileSystem"));
+    TUsbFileSystem fileSystem = EFsyNone;
+    TBuf<KMaxFullName> name;
+    TInt err = iFs.FileSystemName( name, aDrive );
+    if ( (err == KErrNone) && (name.Length() > 0) )
+        {
+
+        FTRACE( FPrint(_L( "[USBWATCHER]\tCUsbActiveMscHandler: GetDriveFileSystem: aDrive=%d name=%S" ),
+                         aDrive, &name ) );
+        
+        if (name.CompareF( KMsFsyName ) == 0)
+            {
+            fileSystem = EFsyMassStorage;
+            }
+        else if (name.CompareF( KFatFsyName ) == 0)
+            {
+            fileSystem = EFsyFat;
+            }        
+        }
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\tCUsbActiveMscHandler: GetDriveFileSystem: filesystem %d on drive %d" ),
+        fileSystem, aDrive ) );
+                
+    return fileSystem;
+    }
+
+// ----------------------------------------------------------------------------
+// Return whether device encryption is supported or not.
+// ----------------------------------------------------------------------------
+// 
+TBool CUsbActiveMscHandler::IsDeviceEncryptionSupportedL()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::IsDeviceEncryptionSupportedL >>"));
+    
+    TBool ret(EFalse);
+    
+    FeatureManager::InitializeLibL();
+    ret = FeatureManager::FeatureSupported(KFeatureIdFfDeviceEncryptionFeature);
+    FeatureManager::UnInitializeLib();
+ 
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::IsDeviceEncryptionSupportedL, ret = %d <<"), ret));
+    return ret;
+    }
+	
+// ----------------------------------------------------------------------------
+// Return device encryption info for further protection
+// ----------------------------------------------------------------------------
+// 
+TBool CUsbActiveMscHandler::IsEncProtectionRequired(const TInt& aDriveLetter)
+    {
+	TBool ret = ETrue;
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::GetEncProtectionInfo >>"));
+	
+    // Is device encryption feature supported?
+    TRAPD( r, ret = ( IsDeviceEncryptionSupportedL() ) );    
+    if(r)
+		{
+		ret = EFalse;
+		}
+	
+    // Get the enctrytion operation code
+    if(ret)
+        {
+        FLOG(_L("Check drives for busy status"));
+	
+        TInt encDriverStatus;
+		
+        if(!iDevEncSession)
+            {
+            FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::IsEncProtectionRequired: iDevEncSession is NULL")));
+            User::Panic(_L("[USBWATCHER]DevEncCommonUtil Not Found"), KErrNotSupported);
+            }    
+        else
+            {
+            iDevEncSession->SetDrive( (TDriveNumber)aDriveLetter );
+            TInt errCode = iDevEncSession->Connect();
+            if( !errCode )
+                {
+                errCode = iDevEncSession->DiskStatus( encDriverStatus );
+                }
+            iDevEncSession->Close();
+            FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::GetDrives: error %d, state %d"), errCode, encDriverStatus));
+
+            ret = ( ( errCode == KErrNone ) && 
+                              ( ( encDriverStatus == EEncrypting ) || ( encDriverStatus == EDecrypting ) ) );
+            }
+        }
+
+    FTRACE(FPrint(_L("[USBWATCHER]\tCUsbActiveMscHandler::GetEncProtectionInfo, aDriveLetter= %d, ret= <<"), aDriveLetter,ret));
+	
+	return ret;
+	}
+void CUsbActiveMscHandler::LoadDevEncSessionL()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::LoadDevEncSessionL >> "));
+    
+    if (!iDevEncSession)
+        {
+	      TInt err = iLibrary.Load(KDevEncCommonUtils);	 
+        if (err != KErrNone)
+            {
+            FTRACE(FPrint(_L("Error in finding the library... %d"), err));
+            return;
+            }
+        TLibraryFunction entry = iLibrary.Lookup(1);
+         
+        if (!entry)
+            {
+            FLOG(_L("Error in loading the library..."));
+            User::Leave(KErrBadLibraryEntryPoint);
+            }
+        iDevEncSession = (CDevEncSessionBase*) entry();
+        }
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::LoadDevEncSessionL << "));
+    }
+
+void CUsbActiveMscHandler::UnloadDevEncSession()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::UnloadDevEncSession >> "));
+    
+    if (iDevEncSession)
+        {
+        delete iDevEncSession;
+        iDevEncSession = NULL;
+        iLibrary.Close();
+        }
+    
+    FLOG(_L("[USBWATCHER]\tCUsbActiveMscHandler::UnloadDevEncSession << "));
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/src/CUsbMscPersonalityTimer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* 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:  Common timer class for UsbMscPersonality
+*
+*/
+
+
+#include <e32base.h>
+#include "CUsbMscPersonalityTimer.h"
+#include "CUsbActiveMscHandlerMdrv.h"
+#include "debug.h"
+
+CUsbMscPersonalityTimer::CUsbMscPersonalityTimer(TCallBack aCallBack,
+                                                 TTimeIntervalMicroSeconds32 aTime)
+    : CActive( EPriorityStandard ),
+      iCallBack(aCallBack),
+      iTime(aTime)
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::CUsbMscPersonalityTimer"));        
+    iTimer.CreateLocal();
+    CActiveScheduler::Add(this);
+    }
+    
+CUsbMscPersonalityTimer::~CUsbMscPersonalityTimer()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::~CUsbMscPersonalityTimer"));        
+    Cancel();
+    iTimer.Close();
+    }
+    
+void CUsbMscPersonalityTimer::Start()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::Start"));        
+    iTimer.After(iStatus, iTime);
+    SetActive();
+    }
+    
+void CUsbMscPersonalityTimer::RunL()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::RunL"));        
+    
+    if (iStatus == KErrNone)
+        {
+        iCallBack.CallBack();
+        }
+    }
+    
+void CUsbMscPersonalityTimer::DoCancel()
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::DoCancel"));        
+    iTimer.Cancel();
+    }
+    
+TInt CUsbMscPersonalityTimer::RunError(TInt /*aError*/)
+    {
+    FLOG(_L("[USBWATCHER]\tCUsbMscPersonalityTimer::RunError"));                
+    return KErrNone;
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbmscpersonality/src/UsbActiveMscHandlerImp.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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:  Implementation proxy
+*
+*/
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "CUsbActiveMscHandlerMdrv.h"
+
+/**
+ * Define the private interface UIDs
+ */
+const TImplementationProxy UsbPersonalityImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY(0x1020DF7B, CUsbActiveMscHandler::NewL),
+    };
+
+/**
+ * Return number of implementation proxies
+ */
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(UsbPersonalityImplementationTable) / sizeof(TImplementationProxy);
+
+    return UsbPersonalityImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/data/10281F29.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:  Resource definitions for project UsbObexClassController
+*
+*/
+
+#include "registryinfo.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+  {
+  dll_uid = 0x10281F29;
+  interfaces =
+    {
+    INTERFACE_INFO
+      {
+      interface_uid = 0x101fbf21;
+      implementations =
+        {
+        IMPLEMENTATION_INFO
+          {
+          implementation_uid = 0x10281F2A;
+          version_no = 1;
+          display_name = "Obex";
+          default_data = "";
+          opaque_data = "";
+          }
+        };
+      }
+    };
+  }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/group/UsbObexClassController.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* 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:  Project definition file for project UsbObexClassController
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET      UsbObexClassController.DLL
+TARGETTYPE    plugin 
+
+CAPABILITY NetworkControl LocalServices NetworkServices CommDD ProtServ
+
+UID             0x10009d8d 0x10281F29
+
+SOURCEPATH      ../src
+SOURCE          CUsbObexClassImpCollection.cpp
+SOURCE          CUsbObexClassController.cpp
+SOURCE          obexsmwatcher.cpp
+
+USERINCLUDE     ../inc
+
+SYSTEMINCLUDE   ../../../inc
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../data
+START RESOURCE  10281F29.rss
+TARGET          usbobexclasscontroller.rsc
+END //RESOURCE
+
+LIBRARY         euser.lib //Kernel API
+LIBRARY         ecom.lib  // ECOM API
+LIBRARY         usbclasscontroller.lib //General Class Controller API
+LIBRARY         obexusbapi.lib // Obex Service Manager Client API
+
+#include <usb/usblogger.mmh>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:  Build information file for project UsbObexClassController
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_EXPORTS
+../rom/UsbObexClassController.iby CORE_MW_LAYER_IBY_EXPORT_PATH(UsbObexClassController.iby)
+
+PRJ_MMPFILES
+../group/UsbObexClassController.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/inc/CUsbObexClassController.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2002-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:  Adheres to the UsbMan USB Class API and manages the class.
+*
+*/
+
+
+#ifndef CUSBOBEXCLASSCONTROLLER_H
+#define CUSBOBEXCLASSCONTROLLER_H
+
+#include <e32std.h>
+#include <cusbclasscontrollerplugin.h>
+#include <usbobex.h>
+#include <usb/usblogger.h>
+#include "obexsmwatcher.h"
+
+const TInt KObexClassPriority = 2;
+const TInt KObexNumInterfaces = 2;
+
+_LIT(KUsbObexLddName, "eusbc");
+_LIT(KUsbObexIfc, "OBEX");
+
+/**
+ *  This class implements OBEX class controller
+ *
+ *  @since S60 V3.1
+ */
+NONSHARABLE_CLASS(CUsbObexClassController) : public CUsbClassControllerPlugIn, public MObexSMObserver
+    {
+public:
+    /**
+     * Constructs a CUsbObexClassController object.
+     *
+     * @since S60 V3.1
+     * @param aOwner USB Device that owns and manages the class.
+     * @return A new CUsbObexClassController object
+     */
+    static CUsbObexClassController* NewL(MUsbClassControllerNotify& aOwner);
+
+// from base class CActive.
+
+    virtual void RunL();
+    virtual void DoCancel();
+    virtual TInt RunError(TInt aError);
+
+// from MObexSMObserver    
+    void MosmError(TInt aError);
+
+// from base class CUsbClassControllerBase
+    
+    /**
+     * From CUsbClassControllerBase.
+     * Destructor
+     *
+     */ 
+    virtual ~CUsbObexClassController();
+
+    /**
+     * From CUsbClassControllerBase.
+     * Usbman starts class controller with this method.
+     *
+     * @param aStatus Will be completed either success or failure.
+     */ 
+    virtual void Start(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbClassControllerBase.
+     * Usbman stops class controller with this method.
+     *
+     * @param aStatus Will be completed either success or failure.
+     */ 
+    virtual void Stop(TRequestStatus& aStatus);
+
+    /**
+     * From CUsbClassControllerBase.
+     * Returns information about the interfaces supported by this class.
+     *
+     * @param aDescriptorInfo Will be filled in with interface information.
+     */ 
+    virtual void GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const;
+
+
+protected:
+    CUsbObexClassController(MUsbClassControllerNotify& aOwner);
+    void DoGetDescriptorInfoL(TUsbDescriptor& aDescriptorInfo) const;
+    void ConstructL();
+
+private: // data
+    TRequestStatus* iRequestStatus;
+    CObexUSB* iObexSM; 
+    CObexSMWatcher *iObexSMWatcher;
+    };
+
+#endif // CUSBOBEXCLASSCONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/inc/mobexsmwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* 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:  Monitors Obex ServiceMan errors.
+*
+*/
+
+#ifndef MOBEXSMWATCHER_H
+#define MOBEXSMWATCHER_H
+
+class MObexSMObserver
+    {
+public:
+    virtual void MosmError(TInt aError) = 0;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/inc/obexsmwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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:  Monitors Obex ServiceMan errors.
+*
+*/
+
+#ifndef COBEXSMWATCHER_H
+#define COBEXSMWATCHER_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32def.h>
+#include <e32property.h> //Publish & Subscribe header
+#include "mobexsmwatcher.h"
+
+/**
+ * CObexSMWatcher class
+ * Subscribes to ObexServiceMan property changes to monitor initialization errors
+ */
+class CObexSMWatcher : public CActive
+    {
+public:
+    static CObexSMWatcher* NewL(MObexSMObserver& aObserver);
+    virtual ~CObexSMWatcher();
+
+    // From CActive
+    virtual void RunL();
+    virtual void DoCancel();
+    
+protected:
+    CObexSMWatcher(MObexSMObserver& aObserver);
+    void ConstructL();
+    
+private:
+    // An observer object for obexseviceman P&S keys
+    MObexSMObserver& iObserver;
+    // A property object for obexseviceman P&S keys
+    RProperty iObexSMPostInit;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/rom/UsbObexClassController.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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:  Image description file for project UsbObexClassCOntroller
+*
+*/
+
+
+#ifndef USBOBEXCLASSCONTROLLER_IBY
+#define USBOBEXCLASSCONTROLLER_IBY
+
+#ifdef __USB
+USB_PLUGIN(usbobexclasscontroller.dll,10281F29.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/src/CUsbObexClassController.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,273 @@
+/*
+* Copyright (c) 2002 - 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:  Implements OBEX class controller
+*
+*/
+
+
+#include "CUsbObexClassController.h"
+#include <usb_std.h>
+#include <obex.h>
+#include <SrcsInterface.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h> //for CleanupResetAndDestroyPushL
+#include <musbclasscontrollernotify.h>
+
+// Panic category only used in debug builds
+#ifdef _DEBUG
+_LIT( KObexCcPanicCategory, "OBEXCC" );
+#endif
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "UsbObexCc");
+#endif
+
+/**
+ * Panic codes for the USB OBEX Class Controller.
+ */
+enum TObexCCPanic
+  {
+  /** Illigal calling of asynchronous function */
+  EBadAsynchronousCall = 0,
+  /** Start() called while in an illegal state */
+  EBadApiCallStart = 1,
+  /** Stop() called while in an illegal state */
+  EBadApiCallStop = 2,
+  };
+
+// ---------------------------------------------------------------------------
+// Constructs a CUsbObexClassController object.
+// ---------------------------------------------------------------------------
+//
+CUsbObexClassController* CUsbObexClassController::NewL(
+  MUsbClassControllerNotify& aOwner)
+  {
+  LOG_STATIC_FUNC_ENTRY
+
+  CUsbObexClassController* self = new (ELeave) CUsbObexClassController(aOwner);
+  CleanupStack::PushL(self);
+  self->ConstructL();
+  CleanupStack::Pop(self);
+  return self;
+  }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CUsbObexClassController::CUsbObexClassController(
+    MUsbClassControllerNotify& aOwner)
+  : CUsbClassControllerPlugIn(aOwner, KObexClassPriority)
+  {
+  LOG_FUNC
+  iState = EUsbServiceIdle;
+  }
+
+// ---------------------------------------------------------------------------
+// Method to perform second phase construction.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::ConstructL()
+  {
+  LOG_FUNC
+  iObexSM = CObexUSB::NewL();
+  iObexSMWatcher = CObexSMWatcher::NewL(*this);
+  }
+
+// ---------------------------------------------------------------------------
+// From class CUsbClassControllerPlugIn.
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbObexClassController::~CUsbObexClassController()
+  {
+  LOG_FUNC
+  Cancel();
+  delete iObexSM;
+  delete iObexSMWatcher;
+  }
+
+// ---------------------------------------------------------------------------
+// From class CUsbClassControllerPlugIn.
+// Called by UsbMan to start this class.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::Start(TRequestStatus& aStatus)
+  {
+
+  LOG_FUNC
+  //Start() should never be called if started, starting or stopping (or in state EUsbServiceFatalError)
+  __ASSERT_DEBUG(iState == EUsbServiceIdle, _USB_PANIC(KObexCcPanicCategory, EBadApiCallStart));
+
+  // Start OBEX SM
+  iRequestStatus = &aStatus;
+  iState = EUsbServiceStarting;
+  aStatus = KRequestPending;
+  LOGTEXT(_L8("CUsbObexClassController::Start() calling ManageUSBService(ETrue)")); 
+  iObexSM->ManageUSBServices(ETrue, iStatus);
+  SetActive();
+  }
+
+// ---------------------------------------------------------------------------
+// From class CUsbClassControllerPlugIn.
+// Called by UsbMan to stop this class.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::Stop(TRequestStatus& aStatus)
+  {
+
+  LOG_FUNC
+  LOGTEXT2(_L8("CUsbObexClassController::Stop iState = %d"), iState);
+  
+  //Stop() should never be called if stopping or starting (or in state EUsbServiceFatalError)
+  __ASSERT_DEBUG(iState == EUsbServiceStarted || iState == EUsbServiceIdle, _USB_PANIC(KObexCcPanicCategory, EBadApiCallStop));
+
+  //state may be idle after Cancel
+  if ( iState == EUsbServiceIdle )
+    {
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+  else
+    {
+    // Stop OBEX SM
+    iRequestStatus = &aStatus;
+    iState = EUsbServiceStopping;   
+    aStatus = KRequestPending;
+    LOGTEXT(_L8("CUsbObexClassController::Stop() calling ManageUSBService(EFalse)")); 
+    iObexSM->ManageUSBServices(EFalse, iStatus);
+    SetActive();
+    }
+  }
+  
+// ---------------------------------------------------------------------------
+// From class CActive.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::RunL()
+  {
+
+  LOG_FUNC
+  if (iStatus != KErrNone)
+    {
+    LOGTEXT2(_L8("CUsbObexClassController::RunL() Error = %d"), iStatus.Int());
+    User::RequestComplete(iRequestStatus, iStatus.Int());
+    return;
+    }
+  LOGTEXT2(_L8("CUsbObexClassController::RunL() State is %d"), iState);
+
+            switch (iState)
+                {
+                case EUsbServiceStarting:
+                    iState = EUsbServiceStarted;
+                    User::RequestComplete(iRequestStatus, KErrNone);
+                    break;
+                    
+                case EUsbServiceStopping:
+                    iState = EUsbServiceIdle;
+                    User::RequestComplete(iRequestStatus, KErrNone);
+                    break;
+
+                case EUsbServiceStarted:
+                case EUsbServiceIdle:
+
+                default:
+            LOGTEXT(_L8("CUsbObexClassController::RunL() Error or Unknown State"));
+                    break;
+                }
+  }
+
+// ---------------------------------------------------------------------------
+// From class CUsbClassControllerPlugIn.
+// Returns information about the interfaces supported by this class.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const
+  {
+  LOG_FUNC
+  TRAPD(ret, DoGetDescriptorInfoL(aDescriptorInfo));
+        if(ret!=KErrNone)
+          {
+                 LOGTEXT2(_L8("CUsbObexClassController::GetDescriptorInfo leave with code: %d"), ret);
+          }
+        }
+
+// ---------------------------------------------------------------------------
+// Leave version of GetDescriptor info function for fit in Class Controller framework.
+// Returns information about the interfaces supported by this class.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::DoGetDescriptorInfoL(TUsbDescriptor& aDescriptorInfo) const
+  {
+  LOG_FUNC
+        RImplInfoPtrArray implInfoArray;
+        CleanupResetAndDestroyPushL(implInfoArray);
+        TEComResolverParams resolverParams;
+        resolverParams.SetDataType(KSrcsTransportUSB);
+        resolverParams.SetWildcardMatch(EFalse);
+        REComSession::ListImplementationsL(KCSrcsInterfaceUid, resolverParams, implInfoArray);
+
+        LOGTEXT2(_L8("CUsbObexClassController::DoGetDescriptorInfoL Number of Interfaces is %d"),
+                   implInfoArray.Count());
+        aDescriptorInfo.iNumInterfaces = (implInfoArray.Count())*KObexNumInterfaces;
+        aDescriptorInfo.iLength = 0;
+
+        CleanupStack::PopAndDestroy(&implInfoArray);    
+        }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Will only be called when an asynchronous request is currently active.
+// ---------------------------------------------------------------------------
+//
+void CUsbObexClassController::DoCancel()
+  {
+  LOG_FUNC
+
+  switch (iState)
+    {
+    case EUsbServiceStarting:
+    case EUsbServiceStopping:
+      iObexSM->CancelManageUSBServices();
+      break;
+
+    default:
+      __ASSERT_DEBUG( EFalse, _USB_PANIC(KObexCcPanicCategory, EBadAsynchronousCall) );
+      break;
+    }
+
+  iState = EUsbServiceIdle;        
+  User::RequestComplete(iRequestStatus, KErrCancel);                  
+  }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Should return KErrNone to avoid an active scheduler panic. This function
+// should never be called as there is another mechanism for catching errors.
+// ---------------------------------------------------------------------------
+//
+TInt CUsbObexClassController::RunError(TInt aError)
+  {
+  LOG_FUNC
+  LOGTEXT2(_L8("CUsbObexClassController::RunError aError=%d"), aError);
+  return KErrNone;
+  }
+
+void CUsbObexClassController::MosmError(TInt aError)
+    {
+    LOG_FUNC
+    LOGTEXT2(_L8("CUsbObexClassController::MosmError aError=%d"), aError);
+    Owner().UccnError(aError);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/src/CUsbObexClassImpCollection.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* 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:  Defines the implementation collection for the USB Obex class controller.
+*
+*/
+
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "CUsbObexClassController.h"
+
+// Define the private interface UIDs
+const TImplementationProxy UsbCCImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0x10281F2A, CUsbObexClassController::NewL),
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(UsbCCImplementationTable) / sizeof(TImplementationProxy);
+
+    return UsbCCImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/src/obexsmwatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* 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:  Monitors Obex ServiceMan errors.
+*
+*/
+
+#include "obexsmwatcher.h"
+#include <e32base.h>
+#include <obexservicemanprop.h>
+#include <usb/usblogger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "UsbObexCcSMW");
+#endif
+
+/**
+ * @since S60 V5.2
+ */
+CObexSMWatcher* CObexSMWatcher::NewL(MObexSMObserver& aObserver)
+    {
+    LOG_STATIC_FUNC_ENTRY
+
+    CObexSMWatcher* self = new (ELeave) CObexSMWatcher(aObserver);
+    CleanupStack::PushL( self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+ *
+ */
+CObexSMWatcher::~CObexSMWatcher()
+    {
+    LOG_FUNC
+    Cancel();
+    iObexSMPostInit.Close();
+    }
+
+/**
+ * Performs 2nd phase construction.
+ */
+void CObexSMWatcher::ConstructL()
+    {
+    LOG_FUNC
+
+    TInt err = iObexSMPostInit.Attach(KUidObexSMCategory, KObexSMPostInitErrorProperty);
+    User::LeaveIfError( err);
+    
+    RunL();
+    }
+
+/**
+ * 
+ */
+
+CObexSMWatcher::CObexSMWatcher(MObexSMObserver& aObserver) :
+    CActive(CActive::EPriorityStandard), iObserver(aObserver)
+    {
+    LOG_FUNC    
+    CActiveScheduler::Add(this);
+    }
+
+/**
+ * 
+ */
+void CObexSMWatcher::RunL()
+    {
+    LOG_FUNC 
+    
+    LOGTEXT2(_L8(">>CObexSMWatcher::RunL [iStatus=%d]"), iStatus.Int());
+    
+    iObexSMPostInit.Subscribe( iStatus );
+    SetActive();
+    
+    TInt value = KErrNone;
+    TInt err = iObexSMPostInit.Get(value);
+    if (err == KErrNone && value != KErrNone)
+        {
+        iObserver.MosmError(value);
+        }
+    
+    LOGTEXT(_L8("<<CObexSMWatcher::RunL"));
+    }
+
+/**
+ *
+ */
+void CObexSMWatcher::DoCancel()
+    {
+    LOG_FUNC
+    iObexSMPostInit.Cancel();
+    }
Binary file usbclasses/usbphoneasmodem/classcontroller/conf/usbmanager_mscfile_2000fda8.crml has changed
Binary file usbclasses/usbphoneasmodem/classcontroller/conf/usbphoneasmodem_mscfile_classcontroller.confml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/data/2000fda8.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+// 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:
+// 
+// 
+
+#include "registryinfo.rh"
+#include "usbmscfileuids.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = KUidMscFileCCDll;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x101fbf21;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KUidMscFileCCImpl1;
+                    version_no = 1;
+                    display_name = "Msc File Class Controller";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/data/usbpammscfile.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* 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:
+* Resource file for the USB mass storage configuration.
+*
+*/
+
+/**
+ @file
+*/
+
+NAME MSCF
+
+#include <badef.rh>
+#include "usbpammscfile.rh"
+
+RESOURCE BA_RSS_SIGNATURE
+	{
+	signature = 1;
+	}
+
+RESOURCE USBMASSSTORAGE_CONFIG usbms_config
+	{
+    vendorId    = "Nokia";  	    // no more than 8 characters
+    productId   = "S60";      // no more than 16 characters
+    productRev  = "1.0";    	    // no more than 4 characters
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+// 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:
+// Build information file for project PhoneAsModem
+//
+//
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+usbmscfileclasscontroller.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+../rom/usbmscfileclasscontroller.iby     CORE_MW_LAYER_IBY_EXPORT_PATH(usbmscfileclasscontroller.iby)
+
+../conf/usbphoneasmodem_mscfile_classcontroller.confml MW_LAYER_CONFML(usbphoneasmodem_mscfile_classcontroller.confml)
+../conf/usbmanager_mscfile_2000fda8.crml MW_LAYER_CRML(usbmanager_mscfile_2000fda8.crml)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/group/usbmscfileclasscontroller.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,55 @@
+// 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:
+// 
+// 
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+#include "../../classimplementation/inc/usbmscfileuids.hrh"
+
+TARGET          usbmscfileclasscontroller.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009d8d KUidMscFileCCDll
+VENDORID        VID_DEFAULT
+
+CAPABILITY      LocalServices NetworkControl NetworkServices ProtServ CommDD
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../classimplementation/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH      ../src
+SOURCE          usbmscfileclasscontroller.cpp
+SOURCE          usbmscfileclasscontrollerimp.cpp
+
+SOURCEPATH      ../data
+START RESOURCE  2000fda8.rss
+TARGET          usbmscfileclasscontroller.rsc
+END
+
+start resource usbpammscfile.rss
+HEADER
+targetpath /private/101fe1db
+end
+
+LIBRARY         euser.lib
+LIBRARY         usbclasscontroller.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         centralrepository.lib
+DEBUGLIBRARY	flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/inc/usbmscfileclasscontroller.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,68 @@
+// 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: Adheres to the UsbMan USB Class API and talks to mass storage file system
+// 
+// 
+
+#ifndef USBMSCLASSCONTROLLER_H
+#define USBMSCLASSCONTROLLER_H
+
+#include <e32std.h>
+#include <cusbclasscontrollerplugin.h>
+#include "usbmscfile.h"
+
+class MUsbClassControllerNotify;
+
+const TInt KMsStartupPriority = 3;
+
+	
+/**
+ The CUsbMscFileClassController class
+ Implements the USB Class Controller API 
+ */
+NONSHARABLE_CLASS(CUsbMscFileClassController) : public CUsbClassControllerPlugIn
+	{
+
+public: 
+	static CUsbMscFileClassController* NewL(MUsbClassControllerNotify& aOwner);
+	~CUsbMscFileClassController();
+
+private: 
+	// Functions derived from CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+
+private: 
+	// Functions derived from CUsbClassControllerBase
+	virtual void Start(TRequestStatus& aStatus);
+	virtual void Stop(TRequestStatus& aStatus);
+
+	virtual void GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const;
+
+private:
+	CUsbMscFileClassController(MUsbClassControllerNotify& aOwner);
+	void ConstructL();
+
+private:
+
+    void ReadMassStorageConfigL();
+    void ConfigItem(const TPtrC& source, TDes& target, TInt maxLength);
+    void SetupUnitsL();
+
+private:
+    RUsbMscFile iMscFile;
+	TMassStorageConfig iMsConfig;
+	};
+
+#endif //USBMSCLASSCONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/inc/usbmscfileclasscontroller_crkeys.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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: Adheres to the UsbMan USB Class API and talks to mass storage file system
+// 
+// 
+#ifndef USBMSCFILECLASSCONTROLLER_CRKEYS_H
+#define USBMSCFILECLASSCONTROLLER_CRKEYS_H
+
+// CONSTANTS
+const TUid KCRUidUsbPhoneAsModemMscFileClassController = { 0x2000FDA8 };
+
+/*
+the least significant four bits is used for columns(unit file attributes: unit number, full name), 
+the remains bit is used for rows(which unit file).
+
+for example, if two units is used, the following can be added for the second unit keys.
+
+const TUint32 KCRIdMscFileLogicalUnitNumber2 = 0x00000010;
+const TUint32 KCRIdMscFileImageFullName2     = 0x00000011;
+
+refer to central repository how-to document section 5, Structured Data in the Central Repository
+
+*/
+const TUint32 KCRIdMscFileLogicalUnitNumber1 	= 0x00000000;
+const TUint32 KCRIdMscFileImageFullName1     	= 0x00000001;
+
+const TUint32 KCRMscFileLogicalUnitNumberColumn = 0x00000000;
+const TUint32 KCRMscFileImageFullNameColumn 	= 0x00000001;
+
+const TUint32 KCRMscFileColumnMask 				= 0x0000000F;
+const TUint32 KCRMscFileRowMask 				= 0xFFFFFFF0;
+#endif      // USBMSCFILECLASSCONTROLLER_CRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/inc/usbpammscfile.rh	Fri Jun 04 10:27:39 2010 +0100
@@ -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:
+* Resource header for usbman configuration.
+*
+*/
+
+/**
+ @file
+*/
+
+STRUCT USBMASSSTORAGE_CONFIG
+	{
+	LTEXT	vendorId;           // no more than 8 characters
+	LTEXT	productId;          // no more than 16 characters
+	LTEXT	productRev;        	// no more than 4 characters
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/rom/usbmscfileclasscontroller.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,30 @@
+// 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:
+// Image description file for project PhoneAsModem
+//
+//
+
+
+#ifndef __USBMSCFILECLASSCONTROLLER_IBY__
+#define __USBMSCFILECLASSCONTROLLER_IBY__
+//file content
+
+#ifdef FF_USB_MODEM
+
+ECOM_PLUGIN(usbmscfileclasscontroller.dll, usbmscfileclasscontroller.rsc)
+data=DATAZ_\private\101fe1db\usbpammscfile.rsc    \private\101fe1db\usbpammscfile.rsc
+
+#endif
+
+#endif // __USBMSCFILECLASSCONTROLLER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontroller.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,428 @@
+// 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: Adheres to the UsbMan USB Class Controller API and talks to mass storage file server
+// 
+// 
+
+#include <barsc.h> 
+#include <barsread.h>
+#include <usb_std.h>
+#include <cusbclasscontrollerplugin.h>
+#include <centralrepository.h>
+#include <usbpammscfile.rsg>
+#include <data_caging_path_literals.hrh> 
+#include "usbmscfileclasscontroller.h"
+#include "usbmscfile.h"
+#include "usbmscfileclasscontroller_crkeys.h"
+#include "debug.h"
+ 
+// Panic category 
+#ifdef _DEBUG
+_LIT( KMsCcPanicCategory, "UsbMscFileCc" );
+#endif
+
+_LIT( KUsbMsResource, "\\private\\101fe1db\\usbpammscfile.rsc" );
+
+/**
+ Panic codes for the USB MSC File Class Controller.
+ */
+enum TMscFileCcPanic
+	{
+	//Class called while in an illegal state
+	EBadApiCall = 0,
+    EUnusedFunction = 1,
+	};
+
+
+static TInt CreateServerProcess()
+    {
+    TRACE_FUNC
+
+    RProcess server;
+    TInt result = server.Create( KMscFileServerFileName, KNullDesC );
+    if ( result != KErrNone )
+        {
+        return  result;
+        }
+
+    TRequestStatus stat;
+
+    server.Rendezvous( stat );
+    if ( stat != KRequestPending )
+        {
+        server.Kill( 0 ); // abort startup
+        }    
+    else
+        {
+        server.Resume(); // logon OK - start the server
+        server.SetPriority( EPriorityForeground );
+        }
+    User::WaitForRequest( stat ); // wait for start or death
+  
+    // 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
+    result = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();    
+    
+    server.Close();
+
+    return result;
+    }
+
+/**
+ Start MSC File Server
+ */
+static TInt StartServer()
+    {
+    TInt result;
+
+    TFindServer findMscFileServer( KMscFileServerName );
+    TFullName name;
+
+    result = findMscFileServer.Next( name );
+    if ( result != KErrNone )
+        {       
+        result = CreateServerProcess();     
+        }
+
+    TRACE_INFO(( _L( "Server process created: %d" ), result ))
+    return result;
+    }
+
+/**
+ Constructs a CUsbMscFileClassController object
+ 
+ @param	aOwner	USB Device that owns and manages the class
+ @return	A new CUsbMscFileClassController object
+ */
+CUsbMscFileClassController* CUsbMscFileClassController::NewL(
+	MUsbClassControllerNotify& aOwner)
+	{
+	TRACE_FUNC
+
+	CUsbMscFileClassController* r = new (ELeave) CUsbMscFileClassController(aOwner);
+	CleanupStack::PushL(r);
+	r->ConstructL();
+	CleanupStack::Pop();
+	return r;
+	}
+
+/**
+ Destructor
+ */
+CUsbMscFileClassController::~CUsbMscFileClassController()
+	{
+	Cancel();
+	}
+
+/**
+ Constructor.
+ 
+ @param	aOwner	USB Device that owns and manages the class
+ */
+CUsbMscFileClassController::CUsbMscFileClassController(
+	MUsbClassControllerNotify& aOwner )
+	: CUsbClassControllerPlugIn( aOwner, KMsStartupPriority )	
+	{
+	// Intentionally left blank
+	}
+
+/**
+ 2nd Phase Construction.
+ */
+void CUsbMscFileClassController::ConstructL()
+	{
+	TRACE_FUNC
+
+	ReadMassStorageConfigL();
+	}
+
+/**
+ Called by UsbMan when it wants to start the mass storage class. 
+ 
+ @param aStatus The caller's request status, filled in with an error code
+ */
+void CUsbMscFileClassController::Start( TRequestStatus& aStatus )
+	{
+	TRACE_FUNC_ENTRY
+	
+	// The service state should always be idle when this function is called 
+	// (guaranteed by CUsbSession).
+	__ASSERT_DEBUG( iState == EUsbServiceIdle, 
+	        User::Panic( KMsCcPanicCategory, EBadApiCall ) );
+
+	TRequestStatus* reportStatus = &aStatus;
+
+	iState = EUsbServiceStarting;
+
+    TInt ret = StartServer();
+    if ( ret != KErrNone )
+        {
+		iState = EUsbServiceIdle;
+		User::RequestComplete( reportStatus, ret );
+        TRACE_ERROR(( _L( "Error %d Can't start server." ), ret ))
+        return;
+        }
+    
+    TRAP( ret, SetupUnitsL() );
+    if (ret != KErrNone)
+        {
+		iState = EUsbServiceIdle;
+		User::RequestComplete( reportStatus, ret );
+        TRACE_ERROR(( _L( "Error %d in SetupUnitsL." ), ret ))
+        return;
+        }
+
+
+	// Connect to USB Mass Storage server
+	ret = iMscFile.Connect();
+
+	if ( ret != KErrNone )
+		{
+		iState = EUsbServiceIdle;
+		User::RequestComplete( reportStatus, ret );
+		TRACE_ERROR(( _L( "Error %d connecting to msc file server" ), ret ))
+		return;
+		}
+
+	// StartL mass storage device
+	ret = iMscFile.Start( iMsConfig );
+
+	if (ret != KErrNone)
+		{
+		iState = EUsbServiceIdle;
+		User::RequestComplete( reportStatus, ret );
+		TRACE_ERROR(( _L( "Error %d starting msc file server" ), ret ))
+		return;
+		}
+
+	iState = EUsbServiceStarted;
+
+	User::RequestComplete(reportStatus, KErrNone);
+	TRACE_FUNC_EXIT
+	}
+
+/**
+ Called by UsbMan when it wants to stop the USB ACM class.
+ 
+ @param aStatus KErrNone on success or a system wide error code
+ */
+void CUsbMscFileClassController::Stop( TRequestStatus& aStatus )
+	{
+	TRACE_FUNC_ENTRY
+	
+	// The service state should always be started when this function is called
+	// (guaranteed by CUsbSession)
+	__ASSERT_DEBUG( iState == EUsbServiceStarted, 
+	                User::Panic( KMsCcPanicCategory, EBadApiCall ) );
+
+	TRequestStatus* reportStatus = &aStatus;
+	
+	TInt ret = iMscFile.Stop();
+	
+	if ( ret != KErrNone )
+		{
+		iState = EUsbServiceStarted;
+		User::RequestComplete( reportStatus, ret );
+		TRACE_ERROR(( _L( "Error %d stopping msc file server" ), ret ))
+		return;
+		}	
+
+	ret = iMscFile.Shutdown();
+	if ( ret != KErrNone )
+		{
+		User::RequestComplete( reportStatus, ret );
+		TRACE_ERROR(( _L( "Error %d stopping msc file server" ), ret ))
+		}	
+  else
+	  {
+		User::RequestComplete( reportStatus, KErrNone );
+	  }    
+	iMscFile.Close();
+	
+	iState = EUsbServiceIdle;
+	TRACE_FUNC_EXIT
+	}
+
+/**
+ Gets information about the descriptor which this class provides. Never called
+ by usbMan.
+ 
+ @param aDescriptorInfo Descriptor info structure filled in by this function
+ */
+void CUsbMscFileClassController::GetDescriptorInfo(TUsbDescriptor& /*aDescriptorInfo*/) const
+	{
+	__ASSERT_DEBUG( EFalse, User::Panic(KMsCcPanicCategory, EUnusedFunction));
+	}
+
+/**
+ Standard active object RunL. Never called because this class has no
+ asynchronous requests.
+ */
+void CUsbMscFileClassController::RunL()
+	{
+	__ASSERT_DEBUG( EFalse, User::Panic(KMsCcPanicCategory, EUnusedFunction) );
+	}
+
+/**
+ Standard active object cancellation function. Never called because this
+ class has no asynchronous requests.
+ */
+void CUsbMscFileClassController::DoCancel()
+	{
+	__ASSERT_DEBUG( EFalse, User::Panic(KMsCcPanicCategory, EUnusedFunction) );
+	}
+
+/**
+ Standard active object error function. Never called because this class has
+ no asynchronous requests, and hence its RunL is never called.
+ 
+ @param aError The error code (unused)
+ @return Always KErrNone to avoid an active scheduler panic
+ */
+TInt CUsbMscFileClassController::RunError(TInt /*aError*/)
+	{
+	__ASSERT_DEBUG( EFalse, User::Panic(KMsCcPanicCategory, EUnusedFunction) );
+	return KErrNone;
+	}
+
+/**
+ Read mass storage configuration info from the resource file
+ */
+void CUsbMscFileClassController::ReadMassStorageConfigL()
+	{
+	TRACE_FUNC_ENTRY
+
+	// Try to connect to file server
+	RFs fs;
+	LEAVE_IF_ERROR( fs.Connect() );
+	CleanupClosePushL( fs );
+
+    TFileName fileName;
+    const TDriveNumber KResourceDrive = EDriveZ;
+    TDriveUnit driveUnit( KResourceDrive );
+    TDriveName drive = driveUnit.Name();
+    fileName.Insert( 0, drive );
+
+    fileName += KUsbMsResource;
+
+	RResourceFile resource;
+	TRAPD( err, resource.OpenL( fs, fileName ) );
+
+	if ( err != KErrNone )
+		{
+		TRACE_ERROR(( _L( "Error %d opening resource file" ), err ))
+		CleanupStack::PopAndDestroy( &fs );
+		return;
+		}
+
+	CleanupClosePushL( resource );
+
+	resource.ConfirmSignatureL( KUsbMsResourceVersion );
+
+	HBufC8* msConfigBuf = 0;
+	TRAPD( ret, msConfigBuf = resource.AllocReadL( USBMS_CONFIG ) );
+	if ( ret != KErrNone )
+		{
+		TRACE_ERROR(( _L( "Error %d opening mass storage config" ), ret ))
+		CleanupStack::PopAndDestroy(2, &fs); 
+		return;
+		}
+	CleanupStack::PushL( msConfigBuf );
+	
+	// The format of the USB resource structure is:
+	
+	/* 	
+	 * 	STRUCT USBMASSSTORAGE_CONFIG
+	 *	{
+	 *	LTEXT	vendorId;           // no more than 8 characters
+	 *	LTEXT	productId;          // no more than 16 characters
+	 *	LTEXT	productRev;        	// no more than 4 characters
+	 *	};
+	 */
+	 
+	// Note that the resource must be read in this order!
+	
+	TResourceReader reader;
+	reader.SetBuffer( msConfigBuf );
+
+	TPtrC	vendorId		= reader.ReadTPtrC();
+	TPtrC	productId		= reader.ReadTPtrC();
+	TPtrC	productRev		= reader.ReadTPtrC();
+	
+	// populate iMsConfig, truncate if exceeding limit
+	ConfigItem( vendorId, iMsConfig.iVendorId, 8 );
+	ConfigItem( productId, iMsConfig.iProductId, 16 );
+	ConfigItem( productRev, iMsConfig.iProductRev, 4 );
+	
+	// Debugging
+	TRACE_INFO(( _L( "vendorId = %s" ),   &vendorId ))
+	TRACE_INFO(( _L( "productId = %s" ),  &productId ))
+	TRACE_INFO(( _L( "productRev = %s" ), &productRev ))
+		
+	CleanupStack::PopAndDestroy( 3, &fs ); // msConfigBuf, resource, fs
+	TRACE_FUNC_EXIT
+	}
+	
+/**
+ Utility. Copies the data from TPtr to TBuf and checks data length 
+ to make sure the source does not exceed the capacity of the target
+ */
+ void CUsbMscFileClassController::ConfigItem( const TPtrC& source, 
+                                              TDes& target, 
+                                              TInt maxLength )
+ 	{
+ 	if ( source.Length() < maxLength )
+ 		{
+ 		maxLength = source.Length();
+ 		}
+ 		
+ 	target.Copy( source.Ptr(), maxLength );	 	
+ 	}
+
+void CUsbMscFileClassController::SetupUnitsL()
+    {
+    RFs fs;
+    RUsbMscFile mscFile;
+    
+    LEAVE_IF_ERROR( mscFile.Connect() );
+    CleanupClosePushL( mscFile );
+    CRepository* repository = CRepository::NewLC(KCRUidUsbPhoneAsModemMscFileClassController);
+    
+	RArray<TUint32> lunKeys;
+	CleanupClosePushL(lunKeys);
+	
+	repository->FindL(KCRMscFileLogicalUnitNumberColumn, KCRMscFileColumnMask, lunKeys);
+
+	
+	TInt count = lunKeys.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TUint32 lunKey = lunKeys[i];
+		TUint32 fullNameKey = ((lunKey&KCRMscFileRowMask)|KCRMscFileImageFullNameColumn);
+		TRACE_INFO( (_L( "lunKey=%d,fullNameKey=%d" ), lunKey, fullNameKey) )
+
+		TInt lun = 0;
+		LEAVE_IF_ERROR(repository->Get(lunKey, lun));
+		
+		TFileName fullName;
+		LEAVE_IF_ERROR(repository->Get(fullNameKey, fullName));	
+		
+		TRACE_INFO( (_L("lun=%d, fullName=%S"), lun, &fullName) );
+	
+		TInt protocol = 0; // It is not used. Bulk Transport(0x50), SCSI transparent command Set(0x06), PDT CD/DVD device(0x05) is supported only.
+		
+		LEAVE_IF_ERROR(mscFile.SetupLogicalUnit( fullName, protocol, lun ));
+		}
+    CleanupStack::PopAndDestroy( 3 ); // mscFile, repository, lunKeys
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontrollerimp.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,35 @@
+// 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: Defines the implementation collection for the mass storage class controller.
+// 
+// 
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "usbmscfileclasscontroller.h"
+#include "usbmscfileuids.hrh"
+
+// Define the private interface UIDs
+const TImplementationProxy ImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY(KUidMscFileCCImpl1, CUsbMscFileClassController::NewL),
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(ImplementationTable[0]);
+
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/data/20026f61.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,48 @@
+// 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:
+// 
+// 
+//
+
+#include <ecom/registryinfo.rh>
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x20026F61; // Phone as modem plugin uid
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x2001CBEE;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x20026F7F;
+                    version_no = 1;
+                    display_name = "PhoneAsModemPlugin AT EXT";
+                    default_data = "PAT*NQAP|PAT*NCNN";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:
+// class definition for phone as modem at extension plugin
+// 
+//
+
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+PRJ_EXPORTS
+../rom/usbpamatplugin.iby     CORE_MW_LAYER_IBY_EXPORT_PATH(usbpamatplugin.iby)
+
+PRJ_MMPFILES
+pamplugin.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/group/pamplugin.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,60 @@
+// 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:
+// class definition for phone as modem at extension plugin
+// 
+//
+
+#include <platform_paths.hrh>
+#include "../inc/pampluginprjconfig.h"
+
+CAPABILITY 	CAP_ECOM_PLUGIN
+
+VENDORID VID_DEFAULT
+
+TARGET      usbpamatplugin.dll
+TARGETTYPE	PLUGIN
+UID         0x10009D8D 0x20026F61
+
+
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH  ../src
+SOURCE      main.cpp
+SOURCE      pamplugin.cpp
+SOURCE      pamengine.cpp
+
+
+USERINCLUDE ../inc
+
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+START RESOURCE  ../data/20026f61.rss
+TARGET usbpamatplugin.rsc
+END
+
+LIBRARY     ecom.lib
+LIBRARY     euser.lib
+LIBRARY     atextpluginbase.lib
+
+LIBRARY     charconv.lib
+LIBRARY	    bafl.lib
+LIBRARY     etel3rdparty.lib
+LIBRARY     etel.lib
+LIBRARY     etelmm.lib
+LIBRARY     cmmanager.lib
+
+DEBUGLIBRARY flogger.lib
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/atcmdpam_debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,121 @@
+// 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:
+// Define Debug API for phone as modem at extension plugin
+// 
+//
+
+#ifndef ATCMDPAM_DEBUG_H
+#define ATCMDPAM_DEBUG_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32svr.h>
+
+// FORWARD DECLARATIONS
+class CATCommand;
+
+#ifdef ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+#define DebugMsg( msg ) CATCmdPAMDebug::NoteL( msg );
+#else // !ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+#define DebugMsg( msg )
+#endif // ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+
+#ifdef ATCMDPAM_DEBUG_TRACES
+
+NONSHARABLE_CLASS( TOverflowTruncate ) : public TDes16Overflow
+    {
+    public:
+	    virtual void Overflow( TDes16& aDes );
+	};
+
+NONSHARABLE_CLASS( TOverflowTruncate8 ) : public TDes8Overflow
+    {
+    public:
+	    virtual void Overflow( TDes8& aDes );
+	};
+
+
+
+class CATCmdPAMDebug 
+    : public CBase
+    {
+    public:
+#ifdef ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+		/**
+        * Debug message
+        * @param aNote Message
+        */
+        static void NoteL( TPtrC aNote );
+#endif // ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+
+		/**
+        * Log AT command / response with flogger
+        * @param aCmd
+        */
+        static void ATLog( CATCommand& aCmd );
+
+#ifndef ATCMDPAM_DEBUG_NOFLOGGER
+		/**
+        * Debug print
+        * @param aFmt.,, Print content
+        */
+        static void Print( TRefByValue<const TDesC> aFmt,... );
+
+		/**
+        * Debug print8
+        * @param aFmt.,, Print content
+        */
+        static void Print8( TRefByValue<const TDesC8> aFmt,... );
+#endif // !ATCMDPAM_DEBUG_NOFLOGGER
+    };
+#endif // ATCMDPAM_DEBUG_TRACES
+
+#ifdef ATCMDPAM_DEBUG_TRACES
+#define ATDEBUG( f ) { f; }
+#ifndef ATCMDPAM_DEBUG_NOFLOGGER
+#define DebugPrint CATCmdPAMDebug::Print
+#define DebugPrint8 CATCmdPAMDebug::Print8
+#define ATLog CATCmdPAMDebug::ATLog
+#else // ATCMDPAM_DEBUG_NOFLOGGER
+#define DebugPrint (void)
+#define DebugPrint8 (void)
+#define ATLog RDebug::Print
+#endif // !ATCMDPAM_DEBUG_NOFLOGGER
+TText* DEBUG_STR( TDes* aStr );
+TText16* DEBUG_STR( TDes16& aStr );
+TText* DEBUG_STR( TPtr aStr );
+TText* DEBUG_STR( HBufC* aStr );
+TText* DEBUG_STR( TDesC* aStr );
+TText* DEBUG_STR( const TDes& aStr );
+TText* DEBUG_STR( const TPtrC& aStr );
+TText* DEBUG_STR( const TDesC& aStr );
+TText8* DEBUG_STR( const TDes8& aStr );
+TText8* DEBUG_STR( const TDesC8& aStr );
+TText8* DEBUG_STR( TDes8& aStr );
+void DEBUG_BUF( TDes aBuf, TRefByValue<const TDesC> aFmt,... );
+#else // !ATCMDPAM_DEBUG_TRACES
+// Compiler preprosessor should ignore this line with it's content, therefore
+// parameter format and function inline prefix are meaningless. Function parameters
+// may not have operations build-in.
+inline void DebugPrint( TRefByValue<const TDesC> aFmt,... ) { (void) aFmt; };
+inline void DebugPrint8( TRefByValue<const TDesC8> aFmt,... ) { (void) aFmt; };
+
+#define DEBUG_STR( str ) str
+#define ATDEBUG( f )
+#endif // ATCMDPAM_DEBUG_TRACES
+
+#endif // ATCMDPAM_DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamengine.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,145 @@
+// 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:
+// class definition for phone as modem at extension plugin
+// 
+//
+
+#ifndef PAMENGINE_H
+#define PAMENGINE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <cntdef.h>
+#include <cntdbobs.h>
+#include <badesca.h>
+#include <etel3rdparty.h>
+#include <rmmcustomapi.h>
+#include <etelmm.h>
+#include <mmtsy_names.h>
+#include <cmmanager.h>
+#include <cmdestination.h>
+#include <cmconnectionmethod.h>
+#include <cmconnectionmethoddef.h>
+#include <cmpluginpacketdatadef.h>
+
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class CPamPlugin;
+/**
+*  CPamEngine
+*/
+class CPamEngine : public CActive
+	{
+public: // Constructor, destructor
+	/**
+	* Two-phased contructor
+	* @param aOwner
+	* @return Instance of CPamEngine
+	*/
+	static CPamEngine* CPamEngine::NewL( CPamPlugin* aOwner );
+						   
+	/**
+	* Two-phased contructor
+	* @param aOwner
+	* @return Instance of CPamEngine
+	*/
+	static CPamEngine* NewLC( CPamPlugin* aOwner );
+
+
+	/**
+	* C++ Destructor
+	*/
+	~CPamEngine();
+
+
+	/**
+	* CPamEngine::ReadAccessPointTableL()
+	* @param aAccessPoint
+	* @param apArray 
+	*/
+	void ReadAccessPointTableL( TInt aAccessPoint, CDesC8ArrayFlat*& apArray );
+
+
+	/**
+	*  CPamEngine::ReadPacketServicetableL()
+	*/
+	void ReadPacketServicetableL( CMManager::TPacketDataApType  aAccessPointType, CDesC8ArrayFlat*& apArray );
+
+
+	/**
+	* Adds quotationmarks before and after string if not empty
+	*/
+	void AddQuotationmarks( const TDesC& aString, HBufC16*& aBuf );
+
+
+	/**
+	* Reads supported access points
+	*/
+	void SupportedAccessPoints( HBufC16*& aBuf );
+
+
+	/**
+	* Gets Service provider name
+	*/
+	void GetServiceProviderName();
+
+
+private: // from CActive
+	/**
+	* AO callback
+	*/    
+   void RunL();
+
+	/**
+	* AO callback
+	*/    
+   void DoCancel();
+
+
+private:
+	/**
+	* 2nd phase Constructor
+	*/
+	void ConstructL();
+
+	/**
+	* C++ Constructor
+	* @param aObserver
+	* @param aObserver
+	*/
+
+	CPamEngine( CPamPlugin* aOwner );
+
+private:
+    enum TAccessPointType
+    {
+    EINTERNETACCESSPOINT = 0,
+    EWAPACCESSPOINT,
+    EBOTHACCESSPOINT
+    };
+
+private: // Data
+	CTelephony::TNetworkNameV1 iNWName;
+	CTelephony* iTelephony;
+	CPamPlugin* iOwner;
+	};  
+	
+   
+#endif // PAMENGINE_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugin.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,92 @@
+// 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:
+// class definition for phone as modem at extension plugin
+// 
+//
+
+#ifndef PAMPLUGIN_H
+#define PAMPLUGIN_H
+
+#include <etel3rdparty.h>
+#include <atextpluginbase.h>
+
+
+class CPamEngine;
+
+class CPamPlugin : public CATExtPluginBase
+  	{
+public:
+
+	/**
+	* Two-phased constructor.
+	*/
+	static CPamPlugin* NewL();
+	
+	/**
+	* Destructor.
+	*/
+	~CPamPlugin();
+
+	void NameReqCallback( const TDesC8& aName );
+
+private:
+    //From CATExtPluginBase
+    TBool IsCommandSupported( const TDesC8& aCmd ) ;
+
+    void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
+    void HandleCommandCancel();
+    TInt NextReplyPartLength();
+    TInt GetNextPartOfReply( RBuf8& aNextReply );
+    void ReceiveUnsolicitedResult();
+    void ReceiveUnsolicitedResultCancel();
+    void ReportNvramStatusChange( const TDesC8& aNvram );
+    void ReportExternalHandleCommandError();
+    void ReportConnectionName( const TDesC8& aName );
+    
+private:    
+    /**
+    * Read Supported Access points
+    */   
+    void SupportedAccessPointL( RBuf8& aReply );
+
+
+    /**
+    * Read Access points data
+    */   
+    void ReadAccessPointL(TInt aAccessPoint, RBuf8& aReply );
+
+
+    
+private:
+
+    TInt HandleRunError(TInt aErr);
+    
+
+private:
+
+    CPamPlugin();
+    
+    void ConstructL();
+       
+    
+private:
+    // Data
+
+    CPamEngine* iPAMEngine;
+    RBuf8* iReply;
+    };
+
+#endif      // PAMPLUGIN_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugindebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,170 @@
+// 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:
+// debug API definition for phone as modem at extension plugin
+// 
+//
+
+#ifndef PAMPLUGINDEBUG_H
+#define PAMPLUGINDEBUG_H
+
+#include <e32base.h>
+#include "pamplugindebugconfig.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::Leave(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_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, PTR);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY {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_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC {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_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_STATIC_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_STATIC_FUNC
+
+#define TRACE_FUNC
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+
+#endif // PAMPLUGINDEBUG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pamplugindebugconfig.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,54 @@
+// 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:
+// class definition for phone as modem at extension plugin
+// 
+//
+
+#ifndef PAMPLUGINDEBUGCONFIG_H
+#define PAMPLUGINDEBUGCONFIG_H
+
+#include "pampluginprjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"pamplugin.txt");
+_LIT(KLogDir,"USB");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[ref_ATEXT] ");
+_LIT8(KTracePrefix8, "[ref_ATEXT] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT(KPanicCategory, "Ref_ATExt");    
+_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 // PAMPLUGINDEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/inc/pampluginprjconfig.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,44 @@
+// 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:
+// class definition for phone as modem at extension plugin
+// 
+//
+#ifndef PAMPLUGINPRJCONFIG_H
+#define PAMPLUGINPRJCONFIG_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 // PAMPLUGINPRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/rom/usbpamatplugin.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+// 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 __USBPAMATPLUGIN_IBY__
+#define __USBPAMATPLUGIN_IBY__
+
+#ifdef FF_USB_MODEM
+ECOM_PLUGIN(usbpamatplugin.dll, usbpamatplugin.rsc)
+#endif
+
+#endif // __USBPAMATPLUGIN_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/src/atcmdpam_debug.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,283 @@
+// 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:
+// Implements Debug API for phone as modem at extension plugin
+// 
+//
+
+// INCLUDES
+#include <e32std.h>
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <atcodec.h>
+#include <AknNoteWrappers.h>
+#include <flogger.h>
+#include "atcmdpam_debug.h"
+#ifdef ATCMDPAM_DEBUG_TRACES
+#pragma message( "Traces enabled" )
+#endif // ATCMDPAM_DEBUG_TRACES
+#ifdef ATCMDPAM_DEBUG_BTTRACES
+#include <btlog.h>
+#endif // ATCMDPAM_DEBUG_BTTRACES
+// CONSTANTS
+#ifdef ATCMDPAM_DEBUG_TRACES
+_LIT( KDebugFile, "atcmdpam.txt" );
+_LIT( KDebugDir, "atcmdpam" );
+_LIT( KATDebugFile, "log.txt" );
+_LIT( KATDebugDir, "atcmdpam" );
+#endif // ATCMDPAM_DEBUG_TRACES
+
+// ============================= LOCAL FUNCTIONS  =============================
+
+/**
+ Debug str
+ */
+#ifdef ATCMDPAM_DEBUG_TRACES
+TText* DEBUG_STR( TDes* aStr )
+    {
+    if ( aStr )
+        {
+        return DEBUG_STR( *aStr );
+        }
+    else
+        {
+        return const_cast<TText*>( _L( "" ).Ptr() );
+        }
+    }
+
+/**
+ Debug str
+ */
+TText16* DEBUG_STR( TDes16& aStr )
+    {
+    if ( aStr.Length() < aStr.MaxLength() )
+        {
+        aStr.ZeroTerminate();
+        }
+    TText16* txt = const_cast<TText16*>( aStr.Ptr() );
+
+    return txt;
+    }
+
+/**
+ Debug str
+ */
+TText8* DEBUG_STR( TDes8& aStr )
+    {
+    if ( aStr.Length() < aStr.MaxLength() )
+        {
+        aStr.ZeroTerminate();
+        }
+    TText8* txt = const_cast<TText8*>( aStr.Ptr() );
+
+    return txt;
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( TPtr aStr )
+    {
+    if ( aStr.Length() < aStr.MaxLength() )
+        {
+        aStr.ZeroTerminate();
+        }
+    TText* txt = const_cast<TText*>( aStr.Ptr() );
+
+    return txt;
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( HBufC* aStr )
+    {
+    if ( aStr )
+        {
+        return DEBUG_STR( aStr->Des() );
+        }
+    else
+        {
+        return const_cast<TText*>( _L( "" ).Ptr() );
+        }
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( TDesC* aStr )
+    {
+    if ( aStr )
+        {
+        TText* txt = const_cast<TText*>( aStr->Ptr() );
+        return txt;
+        }
+    else
+        {
+        return const_cast<TText*>( _L( "" ).Ptr() );
+        }
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( const TDes& aStr )
+    {
+    return DEBUG_STR( const_cast<TDes&>( aStr ) );
+    }
+
+/**
+ Debug str
+ */
+TText8* DEBUG_STR( const TDes8& aStr )
+    {
+    return DEBUG_STR( const_cast<TDes8&>( aStr ) );
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( const TPtrC& aStr )
+    {
+    return const_cast<TText*>( aStr.Ptr() );
+    }
+
+/**
+ Debug str
+ */
+TText* DEBUG_STR( const TDesC& aStr )
+    {
+    return const_cast<TText*>( aStr.Ptr() );
+    }
+
+/**
+ Debug str
+ */
+TText8* DEBUG_STR( const TDesC8& aStr )
+    {
+    return const_cast<TText8*>( aStr.Ptr() );
+    }
+
+// ============================= MEMBER FUNCTIONS =============================
+
+/**
+ Ignore overflow
+ */
+void TOverflowTruncate::Overflow( TDes16& /* aDes */)
+    {
+    return;
+    }
+
+/**
+ Ignore overflow
+ */
+void TOverflowTruncate8::Overflow( TDes8& /* aDes */)
+    {
+    return;
+    }
+
+/**
+ Debug print
+ (static)
+ */
+#ifndef ATCMDPAM_DEBUG_NOFLOGGER
+void CATCmdPAMDebug::Print( TRefByValue<const TDesC> aFmt,... )
+    {
+    TOverflowTruncate overflow;
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TBuf<256> buf;
+    buf.AppendFormatList( aFmt, list, &overflow );
+
+    // Output to IDE
+    RDebug::Print( buf );
+
+    // Output to file
+    RFileLogger::WriteFormat( KDebugDir,
+            KDebugFile,
+            EFileLoggingModeAppend,
+            buf
+    );
+
+#ifdef ATCMDPAM_DEBUG_BTTRACES
+    BTLog::Print( buf );
+#endif // ATCMDPAM_DEBUG_BTTRACES
+    return;
+    }
+#endif // !ATCMDPAM_DEBUG_NOFLOGGER
+
+/**
+ Debug print
+ (static)
+ */
+#ifndef ATCMDPAM_DEBUG_NOFLOGGER
+void CATCmdPAMDebug::Print8( TRefByValue<const TDesC8> aFmt,... )
+    {
+    TOverflowTruncate8 overflow8;
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TBuf8<256> buf8;
+    buf8.AppendFormatList( aFmt, list, &overflow8 );
+
+    HBufC* buf = HBufC::New( buf8.Length() + 1 );
+    if ( buf )
+        {
+        buf->Des().Copy( buf8 );
+        buf->Des().ZeroTerminate();
+        CATCmdPAMDebug::Print( buf->Des() );
+        delete buf;
+        }
+
+    return;
+    }
+#endif // !ATCMDPAM_DEBUG_NOFLOGGER
+
+/**
+ Debug message
+ (static, may leave)
+ */
+#ifdef ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+void CATCmdPAMDebug::NoteL( TPtrC aNote )
+    {
+    CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
+    (void) note->ExecuteLD( aNote );
+
+    return;
+    }
+#endif // ATCMDPAM_DEBUG_INFORMATION_NOTE_MESSAGES
+
+/**
+ Debug print
+ (static)
+ */
+void CATCmdPAMDebug::ATLog( CATCommand& aCmd )
+    {
+    TBuf8<CATCommand::EMaxCmdSize> buf;
+    const TInt err = aCmd.Des( buf );
+    if ( !err )
+        {
+        // Output to file
+        RFileLogger::WriteFormat( KATDebugDir, 
+                                  KATDebugFile, 
+                                  EFileLoggingModeAppend, 
+                                  buf 
+                                );
+        }
+
+    return;
+    }
+#endif // ATCMDPAM_DEBUG_TRACES
+
+// ========================= OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/src/main.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,35 @@
+// 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:
+// Implements a AT extension plugin
+// 
+//
+#include <e32base.h>
+#include <ecom/implementationproxy.h>
+#include "pamplugin.h"
+
+const TImplementationProxy ImplementationTable[] =
+	{
+	IMPLEMENTATION_PROXY_ENTRY(0x20026F7F, CPamPlugin::NewL),
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(ImplementationTable[0]);
+
+	return ImplementationTable;
+	}
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/src/pamengine.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,336 @@
+// 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:
+// Implements a AT extension plugin
+// 
+//
+
+// INCLUDES
+#include <utf.h>
+#include "atcmdpam_debug.h"
+#include "pamengine.h"
+#include "pamplugin.h"
+#include "pamplugindebug.h"
+
+
+// CONSTANTS
+
+
+// ============================= LOCAL FUNCTIONS  =============================
+
+// ============================= MEMBER FUNCTIONS =============================
+
+/**
+ Create a new instance
+ */
+CPamEngine* CPamEngine::NewL( CPamPlugin* aOwner )
+	{
+	CPamEngine* self = CPamEngine::NewLC( aOwner );
+	self->ConstructL();
+	CleanupStack::Pop();
+
+    ATDEBUG( DebugPrint( _L( "CPamEngine::NewL()" )))
+	return self;
+	}
+	
+
+/**
+ Create a new instance and push in cleanup stack
+ */
+CPamEngine* CPamEngine::NewLC( CPamPlugin* aOwner )
+	{
+	CPamEngine* self = new ( ELeave ) CPamEngine( aOwner );
+	CleanupStack::PushL( self );
+
+    ATDEBUG( DebugPrint( _L( "CPamEngine::NewLC()" )))
+	return self;
+	}
+
+
+/**
+ Destructor
+ */
+CPamEngine::~CPamEngine()
+	{
+	ATDEBUG( DebugPrint( _L( "CPamEngine::~CPamEngine()" ) ) )
+    delete iTelephony;
+    }
+
+/**
+ 2nd phase Constructor
+ (may leave)
+ */
+void CPamEngine::ConstructL()
+	{
+    ATDEBUG( DebugPrint( _L( "CPamEngine::ConstructL()" ) ) )
+    
+    CActiveScheduler::Add( this );
+    iTelephony = CTelephony::NewL();
+    }
+
+
+/**
+ C++ Contructror
+ */
+CPamEngine::CPamEngine( CPamPlugin* aOwner ) 
+    : CActive( EPriorityNormal ), iOwner( aOwner )
+	{
+	ATDEBUG( DebugPrint( _L( "CPamEngine::CPamEngine()" )))
+	return;
+    }
+
+
+/**
+ Get the service provider name
+ */
+void CPamEngine::GetServiceProviderName()
+    {
+    TRACE_FUNC_ENTRY
+    if ( !IsActive() )
+        {
+        CTelephony::TNetworkNameV1Pckg namePckg( iNWName );
+        iTelephony->GetCurrentNetworkName( iStatus, namePckg );
+        SetActive();
+        }
+	TRACE_FUNC_EXIT
+    }
+
+/**
+ From CActive
+ */
+void CPamEngine::RunL()
+	{
+	TRACE_FUNC_ENTRY
+	ATDEBUG( DebugPrint( _L( "CPamEngine::RunL()" ) ) )
+    if ( iStatus.Int() != KErrNone )
+        {
+        iOwner->NameReqCallback( KNullDesC8() );
+        return;
+        }
+    TBuf8<20> out;
+    CnvUtfConverter::ConvertFromUnicodeToUtf8( out, iNWName.iNetworkName );
+	iOwner->NameReqCallback( out );
+	TRACE_FUNC_EXIT
+    return;
+    }
+
+
+/**
+ From CActive
+ */
+void CPamEngine::DoCancel()
+	{
+	ATDEBUG( DebugPrint( _L( "CPamEngine::DoCancel()" ) ) )
+	iTelephony->CancelAsync( CTelephony::EGetCurrentNetworkNameCancel );
+    return;
+    }
+
+
+/**
+ Get Access point table by the specified access point type
+ */
+void CPamEngine::ReadAccessPointTableL(TInt aAccessPointType,  CDesC8ArrayFlat*& apArray )
+    {
+    TRACE_FUNC_ENTRY
+
+    switch ( aAccessPointType )
+        {
+        case EINTERNETACCESSPOINT:      
+            {
+            //Internet access point;
+            ReadPacketServicetableL( CMManager::EPacketDataInternetOnly, apArray );
+            }
+            break;
+        case EWAPACCESSPOINT:
+            {
+            //Wap access point;
+            ReadPacketServicetableL( CMManager::EPacketDataWAPOnly, apArray );
+            break;
+            }
+        case EBOTHACCESSPOINT:
+            {
+            //Internet and wap access point only;
+            ReadPacketServicetableL( CMManager::EPacketDataBoth, apArray );
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrArgument );
+            }
+            break;
+        }
+	TRACE_FUNC_EXIT
+    return;
+    }
+
+
+/**
+ Get supported access point type
+ */
+void CPamEngine::SupportedAccessPoints(HBufC16*& aBuf)
+    {
+    TRACE_FUNC_ENTRY
+    _LIT( KAccessTypeString, "(%d,%d,%d)" );
+    aBuf->Des().AppendFormat( KAccessTypeString, CMManager::EPacketDataInternetOnly, 
+                                                 CMManager::EPacketDataWAPOnly, 
+                                                 CMManager::EPacketDataBoth );
+    TRACE_FUNC_EXIT
+    return;
+    }
+
+
+/**
+ Get service names by the specified access point type
+ */
+void CPamEngine::ReadPacketServicetableL( CMManager::TPacketDataApType aAccessPointType,  CDesC8ArrayFlat*& apArray  )
+    {
+    TRACE_FUNC_ENTRY
+	ATDEBUG( DebugPrint( _L( "CPamEngine::ReadPacketServicetable()" ) ) )
+
+    _LIT( KIP, "IP" );
+    _LIT( KIPV6, "IPV6" );
+    _LIT( KComma, "," );
+    _LIT( KNumber, "%d" );
+    TBuf<1> apsecure_auth;
+    TBuf<3> apnumber;
+    const TInt KBufsize = 256;
+
+    RCmManager cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL(cmManager);
+    RArray<TUint32> destinations;
+    cmManager.AllDestinationsL(destinations);
+    CleanupClosePushL(destinations);
+    RCmDestination destination;
+
+    HBufC16 *tmpName = NULL;
+    HBufC16* buf = HBufC16::NewLC( KBufsize );
+    TBuf<4> apPDP_Type;
+
+
+    for(TInt i = 0; i < destinations.Count(); i++)
+        {
+        destination = cmManager.DestinationL(destinations[i]);
+        CleanupClosePushL(destination);
+        tmpName = destination.NameLC();
+       	ATDEBUG( DebugPrint( _L( "CPamEngine::ReadPacketServicetable() destination.name: %S" ), tmpName ) )
+
+        RCmConnectionMethod connectionMethod;
+        for(TInt j = 0; j < destination.ConnectionMethodCount(); j++)
+            {
+            connectionMethod = destination.ConnectionMethodL(j);
+            CleanupClosePushL(connectionMethod);
+
+            TUint32 bearerType = connectionMethod.GetIntAttributeL( CMManager::ECmBearerType );
+            if (bearerType == KUidPacketDataBearerType)
+                {
+                TUint32 connectionType = connectionMethod.GetIntAttributeL( CMManager::EPacketDataApType );
+                if (connectionType == aAccessPointType)
+                    {
+                    // ap number
+                    TUint32 id = connectionMethod.GetIntAttributeL( CMManager::ECmIapId );
+                    apnumber.Format( KNumber, id );
+                    buf->Des().Copy( apnumber );
+                    buf->Des().Append( KComma );
+
+                    // IAP name
+                    tmpName = connectionMethod.GetStringAttributeL(CMManager::ECmName);
+                    AddQuotationmarks( *tmpName, buf );
+                    buf->Des().Append( KComma );
+
+                    // gprs_accesspointname
+                    tmpName = connectionMethod.GetStringAttributeL(CMManager::EPacketDataAPName);
+                    AddQuotationmarks( *tmpName, buf );
+
+                    // PDP_type
+                    TInt isIPv6Supported = connectionMethod.GetBoolAttributeL(CMManager::EPacketDataPDPType);
+                    if ( isIPv6Supported )
+                        {
+                        apPDP_Type = KIPV6;
+                        }
+                    else
+                        {
+                        apPDP_Type = KIP;
+                        }
+                    buf->Des().Append( KComma );
+                    AddQuotationmarks( apPDP_Type, buf );
+
+                    // username
+                    tmpName = connectionMethod.GetStringAttributeL(CMManager::ECmIFAuthName);
+                    buf->Des().Append( KComma );
+                    AddQuotationmarks( *tmpName, buf );
+
+                    // password
+                    tmpName = connectionMethod.GetStringAttributeL(CMManager::ECmIFAuthPass);
+                    buf->Des().Append( KComma );
+                    AddQuotationmarks( *tmpName, buf );
+
+                    // secure_auth
+                    TBool tmp_apsecure_auth = connectionMethod.GetBoolAttributeL(CMManager::ECmDisablePlainTextAuth);
+                    if ( tmp_apsecure_auth )
+                        {
+                        apsecure_auth.Format( KNumber, 1 );
+                        }
+                    else
+                        {
+                        apsecure_auth.Format( KNumber, 0 );
+                        }
+                    buf->Des().Append( KComma );
+                    buf->Des().Append( apsecure_auth );
+
+                	ATDEBUG( DebugPrint( _L( "CPamEngine::ReadPacketServicetable() ATCommand items fetched" ) ) )
+
+                    TBuf8<KBufsize> text8;
+                    if ( CnvUtfConverter::ConvertFromUnicodeToUtf8( text8, *buf ) )
+                        {
+                        ATDEBUG( DebugPrint( _L( "CnvUtfConverter::ConvertFromUnicodeToUtf8 failed" ) ) )
+                        }
+                    else
+                        {
+                        // Conversion succeeded
+                        // Add data to sending table
+                        apArray->AppendL(text8);
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy(); // connectionMethod
+            }
+        tmpName = NULL;
+        CleanupStack::PopAndDestroy(2); // destination
+        }
+    CleanupStack::PopAndDestroy(3); // cmManager
+    TRACE_FUNC_EXIT
+    return;
+    }
+
+/**
+ Add quotation marks
+ */
+void CPamEngine::AddQuotationmarks( const TDesC& aString, HBufC16*& aBuf )
+    {
+    TRACE_FUNC_ENTRY
+    _LIT( KQuotationmark, "\"" );
+
+    if ( aString.Length() > 0 )
+        {
+        aBuf->Des().Append( KQuotationmark );
+        aBuf->Des().Append( aString );
+        aBuf->Des().Append( KQuotationmark );
+        }
+	TRACE_FUNC_EXIT
+    return;
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/atplugin/src/pamplugin.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,288 @@
+// 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:
+// Implements a AT extension plugin
+// 
+//
+
+#include "pamplugin.h"
+#include "pamplugindebug.h"
+#include "pamengine.h"
+
+#include <badesca.h>
+#include <etel3rdparty.h>
+
+
+_LIT8(KNqapString, "*NQAP: ");
+_LIT8(KNqapTestString, "AT*NQAP=?");
+_LIT8(KNqapInternetString, "AT*NQAP=0");
+_LIT8(KNqapWapString, "AT*NQAP=1");
+_LIT8(KNqapInternetAndWapString, "AT*NQAP=2");
+_LIT8(KErrorString, "\r\nERROR\r\n");
+_LIT8(KOkString, "\r\nOK\r\n");
+_LIT8(KCrlfString, "\r\n");
+_LIT8(KNcnnString, "AT*NCNN");
+
+/**
+ Create a new instance
+ */
+CPamPlugin* CPamPlugin::NewL()
+    {
+    CPamPlugin* self = new (ELeave) CPamPlugin();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+/**
+ Destructor
+ */
+CPamPlugin::~CPamPlugin()
+    {
+    TRACE_FUNC_ENTRY
+    delete iPAMEngine;
+    TRACE_FUNC_EXIT
+    }
+
+TBool CPamPlugin::IsCommandSupported( const TDesC8& aCmd )
+    {
+    TRACE_FUNC_ENTRY
+    TBool ret = EFalse;
+    if (aCmd.FindF(KNqapTestString) == 0)
+        {
+        ret = ETrue;
+        }
+    else if (aCmd.FindF(KNqapInternetString) == 0)
+        {
+        ret = ETrue;
+        }
+    else if (aCmd.FindF(KNqapWapString) == 0)
+        {
+        ret = ETrue;
+        }
+    else if (aCmd.FindF(KNqapInternetAndWapString) == 0)
+        {
+        ret = ETrue;
+        }
+    else if (aCmd.FindF(KNcnnString) == 0)
+        {
+        ret = ETrue;
+        }
+    return ret;
+    }
+
+
+void CPamPlugin::HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded )
+	{
+	TRACE_FUNC_ENTRY
+	TRACE_INFO((_L8("CPamPlugin::HandleCommand cmd '%S' reply '%S'"), &aCmd, &aReply))
+
+	if ( !aReplyNeeded )
+    {
+    return;
+    }
+
+    const TInt KInternet = 0;  
+    const TInt KWap = 1;  
+    const TInt KWapInternet = 2;  
+
+	TInt err(KErrNotSupported);
+
+    if (aCmd.FindF(KNqapTestString) >= 0)
+        {
+        SupportedAccessPointL( aReply );
+        err = KErrNone;
+        }
+        
+    else if (aCmd.FindF(KNqapInternetString) >= 0)
+        {
+        ReadAccessPointL( KInternet, aReply );
+        err = KErrNone;
+        }
+    else if (aCmd.FindF(KNqapWapString) >= 0)
+        {
+        ReadAccessPointL( KWap, aReply );
+        err = KErrNone;
+        }
+    else if (aCmd.FindF(KNqapInternetAndWapString) >= 0)
+        {
+        ReadAccessPointL( KWapInternet, aReply );
+        err = KErrNone;
+        }
+    else if (aCmd.FindF(KNcnnString) >= 0)
+        {
+        iReply = &aReply;
+        iPAMEngine->GetServiceProviderName();
+        return;
+        }
+    else
+        {
+        err = KErrNotSupported;
+        }
+
+    if(err != KErrNone)
+        HandleCommandCompleted(err, EReplyTypeUndefined);
+    else
+        HandleCommandCompleted(KErrNone, EReplyTypeOk);
+        
+    TRACE_FUNC_EXIT
+    }
+
+
+void CPamPlugin::NameReqCallback( const TDesC8& aName )
+    {
+    TRACE_FUNC_ENTRY
+    if ( aName == KNullDesC8() )
+        {
+        iReply->Zero();
+        iReply->Create( KErrorString );
+        }
+    else
+        {
+        TBuf8<32> buf;
+        buf.Zero();
+        buf.Append( KCrlfString );
+        buf.Append( aName );
+        buf.Append( KCrlfString );
+        buf.Append( KOkString );
+        iReply->Zero();
+        iReply->Create( buf );
+        }
+    HandleCommandCompleted(KErrNone, EReplyTypeOk);
+	TRACE_FUNC_EXIT
+    }
+
+/**
+ Used by AT*NQAP=?
+ */
+void CPamPlugin::SupportedAccessPointL( RBuf8& aReply )
+	{
+	TRACE_FUNC_ENTRY
+
+    const TInt Kbufsize = 16;
+    const TInt Kresponcebufsize = 64;
+	
+    HBufC16* supportedAp = HBufC16::NewL( Kbufsize );
+    iPAMEngine->SupportedAccessPoints( supportedAp );
+    TBuf8<Kresponcebufsize> buf;
+    
+	buf.Zero();
+    buf.Append( KCrlfString );
+    buf.Append( KNqapString );
+    buf.Append( *supportedAp );
+    buf.Append( KCrlfString );
+    buf.Append( KOkString );
+
+    aReply.Zero();
+    aReply.Create( buf ); 
+
+	TRACE_FUNC_EXIT
+ 	return;
+    }           
+
+/**
+ Used by AT*NQAP=<>
+ */
+void CPamPlugin::ReadAccessPointL(TInt aAccessPoint, RBuf8& aReply )
+	{
+	TRACE_FUNC_ENTRY
+
+    const TInt KreplyBufferLength = 1024;
+	
+   	CDesC8ArrayFlat* apArray = new(ELeave) CDesC8ArrayFlat(4);
+    CleanupStack::PushL( apArray );
+   	
+    iPAMEngine->ReadAccessPointTableL( aAccessPoint, apArray );
+
+    TInt apArrayLength = apArray->Count();
+    if ( apArrayLength > 0)
+        {
+        HBufC8* buf = HBufC8::NewL( KreplyBufferLength );
+        buf->Des().Zero();
+        buf->Des().Append( KCrlfString );
+        for (TInt i=0; i < apArrayLength; i++ )
+            {
+            // AT*NQAP=<n> responce
+            buf->Des().Append( KNqapString );
+            buf->Des().Append( (*apArray)[i] );
+            buf->Des().Append( KCrlfString );
+            }
+        buf->Des().Append( KOkString );
+        aReply.Zero();
+        aReply.Create( *buf );
+        }
+    else
+        {
+        aReply.Zero();
+        aReply.Create( KOkString );
+        }
+    CleanupStack::PopAndDestroy( apArray );
+    TRACE_FUNC_EXIT
+	return;
+    }           
+        
+
+TInt CPamPlugin::HandleRunError(TInt /*aErr*/)
+    {
+     return KErrNone;
+    }
+
+
+CPamPlugin::CPamPlugin() : CATExtPluginBase()
+    {
+    TRACE_FUNC
+    }
+     
+
+void CPamPlugin::ConstructL()
+    {
+    iPAMEngine = CPamEngine::NewL( this );
+    TRACE_FUNC
+   	}
+
+void CPamPlugin::ReportConnectionName( const TDesC8& /*aName*/ )
+    {
+    }
+
+void CPamPlugin::HandleCommandCancel()
+    {
+    }
+
+TInt CPamPlugin::NextReplyPartLength()
+    {
+    return 0;
+    }
+TInt CPamPlugin::GetNextPartOfReply(RBuf8& /*aNextReply*/)
+    {
+    return 0;
+    }
+
+void CPamPlugin::ReceiveUnsolicitedResult()
+    {
+    }
+
+void CPamPlugin::ReceiveUnsolicitedResultCancel()
+    {
+    }
+
+void CPamPlugin::ReportNvramStatusChange( const TDesC8& /*aNvram*/ )
+    {
+    }
+
+void CPamPlugin::ReportExternalHandleCommandError()
+    {
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,19 @@
+// 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:
+// 
+// 
+
+
+#include "../atplugin/group/bld.inf"
+#include "../mscfileserver/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,192 @@
+// 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 ATPLUGINDEBUG_H
+#define ATPLUGINDEBUG_H
+
+#include <e32base.h>
+#include <flogger.h>
+#include <e32svr.h>
+
+
+_LIT(KLogFile,"usbmscfile.txt");
+_LIT(KLogDir,"usbmscfile");
+
+_LIT(KTracePrefix16, "[UsbMscFile] ");
+_LIT8(KTracePrefix8, "[UsbMscFile] ");
+_LIT8(KFuncFormat8, ">< %S");
+_LIT8(KFuncThisFormat8, ">< %S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, "-> %S");
+_LIT8(KFuncEntryThisFormat8, "-> %S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<- %S");
+_LIT(KPanicCategory, "UsbMscFile");
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+
+#ifdef _DEBUG
+
+const TInt KMaxLogLineLength = 512;
+
+// Trace options
+#define KPRINTERROR		0x00000001 // Print error
+#define KPRINTINFO	    0x00000002 // Print function trace
+#define KPRINTSTATE		0x00000004 // Print state machine infos
+#define KPRINTWARNING   0x00000008 // Print warnings
+
+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 __WINS__
+#ifdef _DEBUG
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#endif
+#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 __WINS__    
+#ifdef _DEBUG
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#endif
+#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) {Trace(_L8(" RETURN %d at file %S line %d"), ERR, &(TPtrC8((const TUint8*)__FILE__)), __LINE__); return ERR;}}
+
+#else // ! _DEBUG
+
+#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 // _DEBUG
+
+#endif // ATPLUGINDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfile.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,96 @@
+// 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: RUsbMscFile Client side header
+//              Implements the Symbian OS USB mass storage server RUsbMscFile API 
+// 
+
+#ifndef USBMSCFILE_H
+#define USBMSCFILE_H
+
+#include <e32std.h>
+#include "usbmscfileshared.h"
+
+class RUsbMscFile : public RSessionBase
+/**
+ The RUsbMscFile class implements the Symbian OS USB mass storage RUsbMscFile API 
+ 
+ @internalTechnology
+ */
+	{
+public:
+	/**
+     Constructor
+      
+	 @internalTechnology
+	 */
+	inline RUsbMscFile();
+
+	/**
+     Extract the version of the server providing the RUsbMscFile API
+     
+     @return	Version of the server
+     @internalTechnology
+	 */
+	inline TVersion Version() const;
+
+	/**
+	 * Setup a logical unit. Maps a file containing a file system image
+	 * to a logical Mass Storage unit. The parameter aLun is reserved for 
+	 * future expansion, currently only one unit with LUN = 0 is supported.
+	 * 
+	 * @param aFileName path to the file containing the file system image
+	 * @param aProtocol type of SCSI protocol to use
+	 * @param aLun logical unit number (LUN) to assign
+     * @return KErrNone on success, otherwise system wide error code 
+	 */
+	inline TInt SetupLogicalUnit( const TDesC& aFileName, 
+	                              const TInt aProtocol, 
+	                              const TInt aLun = 0 );
+	/**
+     StartL the mass storage transport service
+     
+	 @param aMsConfig	mass storage configuration info
+	 @internalTechnology
+	 @return KErrNone on success, otherwise system wide error code 
+	 */
+	inline TInt Start( const TMassStorageConfig& aMsConfig );
+
+	/**
+     Stops mass storage transport service
+     
+	 @internalTechnology
+	 @return KErrNone on success, otherwise system wide error code 
+	 */
+	inline TInt Stop();
+	
+	/**
+     Shut down the Mass Storage server
+     
+	 @internalTechnology
+	 @return KErrNone on success, otherwise system wide error code 
+	 */
+	inline TInt Shutdown();
+	
+	/**
+	 Connects to mass storage file server
+	 
+	 @internalTechnology
+	 @return KErrNone on success, otherwise system wide error code 
+	 */
+    inline TInt Connect();
+    
+	};
+
+#include "usbmscfile.inl"
+
+#endif //USBMSCFILE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfile.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,83 @@
+// 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: Implementation of client API of mass storage file server
+// 
+// 
+
+#ifndef USBMSCFILE_INL
+#define USBMSCFILE_INL
+
+
+inline RUsbMscFile::RUsbMscFile()
+	{
+	// Intentionally left blank
+	}
+
+inline TVersion RUsbMscFile::Version() const
+	{
+	return ( TVersion( KUsbMsSrvMajorVersionNumber,
+	                   KUsbMsSrvMinorVersionNumber,
+	                   KUsbMsSrvBuildVersionNumber ) );
+	}
+
+inline TInt RUsbMscFile::Connect()
+	{
+    // 1: only a single session is required
+#ifdef __T_MS_CLISVR__
+   	static _LIT_SECURITY_POLICY_S0(KFileServerPolicy,0x101F7774);
+#else
+  	static _LIT_SECURITY_POLICY_S0(KFileServerPolicy,KFileServerUidValue);
+  	static _LIT_SECURITY_POLICY_PASS(KPolicyPass);
+#endif
+  	return CreateSession( KMscFileServerName, 
+  	                      Version(), 
+  	                      1, 
+  	                      EIpcSession_Unsharable,
+  	                      &KPolicyPass,
+  	                      0);
+	}
+
+inline TInt RUsbMscFile::SetupLogicalUnit( const TDesC& aFileName, 
+                                        const TInt aProtocol, 
+                                        const TInt aLun /* = 0 */ )
+
+    {
+    return SendReceive( EMscFileSetupLu, TIpcArgs( &aFileName, aProtocol, aLun ) );
+    }
+/**
+ @capability NetworkControl 
+ */
+inline TInt RUsbMscFile::Start( const TMassStorageConfig& aMsConfig )
+	{
+	return SendReceive( EMscFileStart, TIpcArgs( &aMsConfig.iVendorId, 
+	                                             &aMsConfig.iProductId, 
+	                                             &aMsConfig.iProductRev ) );
+	}
+
+/**
+ @capability NetworkControl 
+ */	
+inline TInt RUsbMscFile::Stop()
+	{
+	return SendReceive( EMscFileStop );
+	}
+
+/**
+ @capability NetworkControl 
+ */	
+inline TInt RUsbMscFile::Shutdown()
+	{
+	return SendReceive(EMscFileShutdown);
+	}
+
+#endif  //USBMSCFILE_INL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfileshared.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,44 @@
+// 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: Shared client/server definitions
+// 
+// 
+
+#ifndef USBMSCFILESHARED_H
+#define USBMSCFILESHARED_H
+
+#include <e32std.h>
+
+const TInt KUsbMsSrvMajorVersionNumber = 1;
+const TInt KUsbMsSrvMinorVersionNumber = 0;
+const TInt KUsbMsSrvBuildVersionNumber = 0;
+
+const TInt KUsbMsResourceVersion = 0;
+_LIT(KMscFileServerName, "usbmscfileserver");
+_LIT(KMscFileServerFileName, "usbmscfileserver.exe");
+
+class TMassStorageConfig
+    {
+public:
+    TBuf<8> iVendorId;
+    TBuf<16> iProductId;
+    TBuf<4> iProductRev;
+    };
+
+/** Types of requests USB mass storage class controller can make */
+enum TMscFileServerReq
+    {
+    EMscFileSetupLu, EMscFileStart, EMscFileStop, EMscFileShutdown,
+    };
+
+#endif //USBMSCFILESHARED_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/inc/usbmscfileuids.hrh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+// 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 USBMSCFILEUIDS_HRH
+#define USBMSCFILEUIDS_HRH
+
+#define KUidMscFileServer           0x2000FDA7
+#define KUidMscFileCCDll            0x2000FDA8
+#define KUidMscFileCCImpl1          0x2000FDA9
+    
+#endif // USBMSCFILEUIDS_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,29 @@
+// 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:
+// Build information file for project PhoneAsModem
+//
+//
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+usbmscfileserver.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+../rom/usbmscfileserver.iby     CORE_MW_LAYER_IBY_EXPORT_PATH(usbmscfileserver.iby)
+../rom/phone_as_modem.iso     /epoc32/data/z/private/2000FDA7/phone_as_modem.iso
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/group/usbmscfileserver.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,55 @@
+// 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:
+// 
+// 
+
+
+#include <platform_paths.hrh>
+#include "../../inc/usbmscfileuids.hrh"
+
+TARGET          usbmscfileserver.exe
+TARGETTYPE      exe
+
+UID             0x0 KUidMscFileServer
+VENDORID        VID_DEFAULT
+
+CAPABILITY      ProtServ ReadDeviceData WriteDeviceData SwEvent Location \
+                NetworkServices ReadUserData WriteUserData LocalServices \
+                UserEnvironment CommDD AllFiles
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../inc
+
+SOURCEPATH      ../src
+SOURCE          mscfileserver.cpp
+SOURCE          mscfilesession.cpp
+SOURCE          mscfilecontroller.cpp
+SOURCE          scsiprot.cpp
+SOURCE          bulkonlytransport.cpp
+SOURCE          filesystemimage.cpp
+
+LIBRARY         efile.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+DEBUGLIBRARY	flogger.lib
+
+START WINS
+BASEADDRESS     0x61000000
+END
+
+unpaged
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/bulkonlytransport.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,255 @@
+// 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: Class declaration for CBulkOnlyTransport.
+// 
+// 
+
+#ifndef BULKONLYTRANSPORT_H
+#define BULKONLYTRANSPORT_H
+
+#include <e32std.h> 
+
+#include <d32usbc.h>
+#include "protocol.h"  
+#include "mscfilecontroller.h"
+
+static const TInt KCbwLength = 31;
+
+// for control endpoint 
+static const TUint KRequestHdrSize = 8;
+
+
+/** size of buffer for command padding */
+static const TUint KBOTMaxBufSize 		= 1024; 
+
+/**
+Represent Endpoint0 request
+*/
+class TUsbRequestHdr
+	{
+public:
+	enum TEp0Request
+		{
+		EReqGetMaxLun = 0xFE,
+		EReqReset	  = 0xFF
+		};
+public:
+	TInt Decode(const TDesC8& aBuffer);
+	TBool IsDataResponseRequired() const;
+
+public:
+	TUint8	iRequestType;
+	TEp0Request	iRequest;
+	TUint16 iValue;
+	TUint16 iIndex;
+	TUint16 iLength;
+
+
+	};
+
+
+//---------------------------------------
+class CBulkOnlyTransport;  //forward declaration
+
+
+
+//
+// --- class CActiveDeviceStateNotifier -----------------------------
+//
+
+class CActiveDeviceStateNotifier : public CActive
+	{
+public:
+	// Construction
+	static CActiveDeviceStateNotifier* NewL(CBulkOnlyTransport& aParent);
+
+	// Destruction
+	~CActiveDeviceStateNotifier();
+
+	void Activate();
+
+private:
+	// Construction
+	CActiveDeviceStateNotifier(CBulkOnlyTransport& aParent);
+	void ConstructL();
+
+	// Cancel request.
+	// Defined as pure virtual by CActive;
+	// implementation provided by this class.
+	virtual void DoCancel();
+
+	// Service completed request.
+	// Defined as pure virtual by CActive;
+	// implementation provided by this class,
+	virtual void RunL();
+
+private:
+	CBulkOnlyTransport& iParent;
+	TUint iDeviceState;
+	TUint iOldDeviceState;
+	
+	};
+//=====================
+
+
+
+
+/**
+Represent session with control endpoint (Ep0).
+handles the control interface, and responds to the class specific commands (RESET and GET_MAX_LUN).  
+*/
+class CControlInterface : public CActive
+	{
+
+public:
+	enum TControlState
+		{
+		ENone,
+		EReadEp0Data,
+		ESendMaxLun
+
+		};
+
+public:
+	
+	static CControlInterface* NewL(CBulkOnlyTransport& aParent);
+	
+	~CControlInterface();
+	TInt Start();
+	void Stop();
+	virtual void RunL();
+	virtual void DoCancel();
+			
+
+private:
+	CControlInterface(CBulkOnlyTransport& aParent);
+	void ConstructL();
+	TInt ReadEp0Data();
+	void DecodeEp0Data();
+
+private:
+	/** Buffer for request data*/
+	TBuf8<KRequestHdrSize> iData;
+	TUsbRequestHdr iRequestHeader;
+	/** reference to the  CBulkOnlyTransport*/
+	CBulkOnlyTransport& iParent;
+	/** represent carrent state for state mashine */
+	TControlState iCurrentState;
+	};
+
+//----------------------
+/** handles the data transport and communications with the SCSI protocol */
+class CBulkOnlyTransport : public CActive, public MTransportBase
+	{
+public:
+	enum TCswStatus
+		{
+		ECommandPassed 	= 0,
+		ECommandFailed	= 1,
+		EPhaseError		= 2
+		};
+	
+	enum TTransportState
+		{
+		ENone,
+		EWaitForCBW,
+		ESendingCSW,
+		EWritingData,
+		EReadingData,
+        EPermErr
+		};
+public:
+	static CBulkOnlyTransport* NewL(TInt aNumDrives,CMscFileController& aController);
+
+	~CBulkOnlyTransport();
+	void SetupReadData(TPtr8& aData);	
+	void SetupWriteData(TPtrC8& aData);
+	TInt Start();
+	TInt Stop();
+	void RegisterProtocol(MProtocolBase& aProtocol);
+	TInt BytesAvailable();
+
+	CMscFileController& Controller();
+	TInt MaxLun();
+	RDevUsbcClient& Ldd();
+	TInt HwStart(TBool aDiscard = EFalse);
+	TInt HwStop();
+	TInt HwSuspend();
+	TInt HwResume();
+	
+	virtual void RunL();
+	virtual void DoCancel();
+
+private:
+	CBulkOnlyTransport(TInt aNumDrives,CMscFileController& aController);	
+	void ConstructL();
+	TInt SetupConfigurationDescriptor(TBool aUnset = EFalse);
+	TInt SetupInterfaceDescriptors();	
+	void ReadCBW();
+	void DecodeCBW();
+	TBool CheckCBW();
+	void SetPermError();
+	void SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus);
+	void WriteData(TUint aLength, TBool aZlpRequired = EFalse);
+	void ReadData(TUint aLength);
+	void StallEndpointAndWaitForClear(TEndpointNumber aEndpoint);
+	void ReadAndDiscardData(TInt aBytes);
+	void Activate(TInt aReason);
+    void PrepareReadFromHost(TUint aHostDataLength);
+    void PrepareWriteToHost(TUint aHostDataLength);
+	
+private:
+	/** maximun logic unit number supported (started from 0) */
+	TInt iMaxLun;
+	
+	CMscFileController& iController;
+	
+	CControlInterface* iControlInterface;
+	MProtocolBase* iProtocol;
+	RDevUsbcClient iLdd;
+	TTransportState  iCurrentState;
+	
+	/** buffer for Command Block Wrapper */
+	TBuf8 <KCbwLength+1> iCbwBuf;
+	
+	/** Pointer to read buffer (bufer itself provided by protocol) */
+	TPtr8 iReadBuf; 
+	
+	/** Pointer to write buffer (bufer itself provided by protocol) */
+	TPtrC8 iWriteBuf;
+
+	/** Shows how many data was not sent/reseived */
+	TUint32 iDataResidue;
+	TUint32 iCbwTag;
+	TCswStatus iCmdStatus;
+	
+	/** Indicate if SCSI protocol has data to sent */
+	TBool iWriteSetUp;
+	
+	/** Indicate if SCSI protocol expected additional data */
+	TBool iReadSetUp;
+	
+	/** Indicate whether SCSI protocol started or not */
+	
+	TBool iStarted;
+	
+	/** internal buffer for padding */
+	TBuf8<KBOTMaxBufSize> iBuf;
+	
+	TBool iStallAllowed;
+	
+	CActiveDeviceStateNotifier* iDeviceStateNotifier;
+	TBool iInterfaceConfigured;
+	};
+	
+#endif // BULKONLYTRANSPORT_H	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/filesystemimage.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,72 @@
+// 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: CFileSystemImage declaration
+// 
+// 
+
+#ifndef FILESYSTEMIMAGE_H
+#define FILESYSTEMIMAGE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+// CLASS DECLARATION
+
+/**
+ *  CFileSystemImage
+ * 
+ */
+class CFileSystemImage : public CBase
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CFileSystemImage* NewL( const TDesC& aFileName );
+
+	/**
+	 * Destructor.
+	 */
+	~CFileSystemImage();
+
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 */
+	CFileSystemImage();
+
+	/**
+	 * Default constructor for performing 2nd stage construction
+	 */
+	void ConstructL( const TDesC& aFileName );
+
+public:
+	TInt Open();
+	TInt Close();
+	TInt Read( const TInt64& aPos, TInt aLength, TDes8& aBuf );
+	TInt Write( const TInt64& aPos, TDesC8& aBuf );
+	TInt64 Size();
+
+private:
+	RFs	  iFs;
+	RFile iFile;
+	HBufC* iFileName;
+	TBool iIsOpened;
+	};
+
+#endif // FILESYSTEMIMAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfilecontroller.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,57 @@
+// 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: Class declaration for CMscFileController.
+// 
+// 
+
+#ifndef MSCFILECONTROLLER_H
+#define MSCFILECONTROLLER_H
+
+#include <e32base.h>
+#include "usbmscfileshared.h"
+#include "filesystemimage.h"
+#include "mscfileserver.h"
+#include "protocol.h"
+
+/**
+Mass Storage Controller class.
+Encapsulates the drive manager, transport and protocol for USB Mass Storage.
+Its main purpose is to instantiate and initialize these objects.
+*/
+class CMscFileController : public CBase
+	{
+public:
+    static CMscFileController* NewL();
+	~CMscFileController();
+	
+private:
+    CMscFileController();
+	void ConstructL();
+	
+public:
+    void SetupLogicalUnitL( const TDesC& aFileName, 
+                           const TInt aProtocol, 
+                           const TInt aLun );
+	TInt Start( TMassStorageConfig& aConfig );
+	TInt Stop();
+	void Reset();
+	CFileSystemImage* FsImage( TInt aLun );
+private:
+	CFileSystemImage* iFsImage;
+	MTransportBase* iTransport;
+	MProtocolBase* iProtocol;
+	TMassStorageConfig iConfig;
+	TInt iMaxDrives;
+	};
+
+#endif //MSCFILECONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,75 @@
+// 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: Implements a Symbian OS server that exposes the RUsbMassStorage API
+// 
+// 
+
+#ifndef MSCFILESERVER_H
+#define MSCFILESERVER_H
+
+_LIT(KUsbMsSvrPncCat, "CUsbMsServer");
+
+enum TUsbPanicServer
+	{
+	EMsClientInvalidSessCount,
+	EMsControlInterfaceBadState,
+	EMsControlInterfaceStillActive,
+	EMsBulkOnlyStillActive,
+	EMsWrongEndpoint,
+	EMsWrongLength
+	};
+
+//
+// Forward declarations
+//
+class CMscFileController;
+
+/**
+ The CMscFileServer class
+ Implements a Symbian OS server that exposes the RUsbMassStorage API
+ */
+class CMscFileServer : public CPolicyServer
+	{
+public:
+	static CMscFileServer* NewLC();
+	virtual ~CMscFileServer();
+
+private:
+    CMscFileServer();
+    void ConstructL();
+
+public:
+	virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const;
+	void Error(TInt aError);
+
+	inline CMscFileController& Controller() const;
+
+	void IncrementSessionCount();
+	void DecrementSessionCount();
+	inline TInt SessionCount() const;
+
+    static TInt ThreadFunction( TAny* aStarted );
+    
+private:
+    static void ThreadFunctionL();
+    
+private:
+	CMscFileController* iController;
+	TInt iSessionCount;
+	};
+
+#include "mscfileserver.inl"
+
+#endif // MSCFILESERVER_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserver.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,44 @@
+// 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: Implements a Symbian OS server that exposes the RUsbMassStorge API
+// 
+// 
+
+#ifndef MSCFILESERVER_INL
+#define MSCFILESERVER_INL
+
+
+/**
+ Returns a reference to the CMscFileController
+
+ @internalTechnology
+ @return	the reference to the CMscFileController
+ */
+inline CMscFileController& CMscFileServer::Controller() const
+    {
+    return *iController;
+    }
+
+/**
+ Gets session count
+ 
+ @internalTechnology
+ @return iSessionCount
+ */
+inline TInt CMscFileServer::SessionCount() const
+    {
+    return iSessionCount;
+    }
+
+#endif // MSCFILESERVER_INL
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfileserversecuritypolicy.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,63 @@
+// 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: USB mass storage Server Security Policy definitions for Platform security.
+// 
+// 
+
+#ifndef MSCFILESERVERSECURITYPOLICY_H
+#define MSCFILESERVERSECURITYPOLICY_H
+
+#include "usbmscfileshared.h"
+
+// USB masss storage Server Security Policy Definition
+
+const TUint KUsbMsServerRangeCount = 3;
+
+const TInt KUsbMsServerRanges[KUsbMsServerRangeCount] = 
+	{
+	EMscFileStart,                // NetworkControl	[StartL/Stop]
+	EMscFileShutdown,				// DiskAdmin		[Shutdown]
+    EMscFileShutdown + 1,         // fail (to KMaxInt)
+	};
+
+// Index numbers into KUsbMsServerElements[]
+const TInt KPolicyNetworkControl = 0;
+const TInt KPolicyDiskAdmin = 1;
+
+// Mapping IPCs to poicy element
+const TUint8 KUsbMsServerElementsIndex[KUsbMsServerRangeCount] = 
+	{
+	KPolicyNetworkControl,          // EMscFileStart & EMscFileStop 
+	KPolicyDiskAdmin,			 	// EMscFileShutdown 
+	CPolicyServer::ENotSupported,   // EMscFileShutdown + 1 to KMaxTInt    
+	};
+
+// Individual policy elements 
+const CPolicyServer::TPolicyElement KUsbMsServerElements[] = 
+	{
+  		{ _INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient },
+		{ _INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin), CPolicyServer::EFailClient},
+		// the EFailClient means that if the check fails 
+        // the CheckFailed method with return KErrPermissionDenied
+	};
+
+// Main policy
+const CPolicyServer::TPolicy KMscFileServerPolicy = 
+	{
+	CPolicyServer::EAlwaysPass, // all connect attempts should pass
+	KUsbMsServerRangeCount,
+	KUsbMsServerRanges,
+	KUsbMsServerElementsIndex,
+	KUsbMsServerElements,
+	};
+#endif //MSCFILESERVERSECURITYPOLICY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/mscfilesession.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,65 @@
+// 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: Implements a Session of a Symbian OS server for the RUsbMassStorage API
+// 
+// 
+
+#ifndef MSCFILESESSION_H
+#define MSCFILESESSION_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include "usbmscfileshared.h"
+
+_LIT(KUsbMsCliPncCat, "UsbMs-Client");
+
+enum TUsbMsPanicClient
+    {
+    EUsbMsPanicIllegalIPC
+    };
+//
+// Forward declarations
+//
+class CMscFileServer;
+
+/**
+ The CMscFileSession class
+ Implements a Session of a Symbian OS server for the RUsbMassStorage API
+ */
+class CMscFileSession : public CSession2
+	{
+public:
+	static CMscFileSession* NewL( CMscFileServer& aServer );
+	virtual ~CMscFileSession();
+
+private:
+    CMscFileSession( CMscFileServer& aServer );
+    void ConstructL();
+
+protected:
+	virtual void ServiceL( const RMessage2& aMessage );
+	
+private:
+    void DispatchMessageL( const RMessage2& aMessage );
+	void SetupLogicalUnitL( const RMessage2& aMessage );
+	void StartL( const RMessage2& aMessage );
+	TInt Stop();
+	TInt Shutdown();
+ 	void GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage);
+	
+private:
+	CMscFileServer& iMscFileServer;
+	};
+
+#endif //MSCFILESESSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/protocol.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+// 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 PROTOCOL_H
+#define PROTOCOL_H
+
+#include <e32base.h>			// C Class Definitions, Cleanup Stack
+#include <e32def.h>				// T Type  Definitions
+#include <e32std.h>    			// ELeave definition
+
+
+class MProtocolBase;
+
+class MTransportBase
+	{
+	public:
+	virtual void SetupReadData(TPtr8& aData) = 0;
+	virtual void SetupWriteData(TPtrC8& aData) = 0;
+	virtual TInt Start() = 0;
+	virtual TInt Stop() = 0;
+	virtual void RegisterProtocol(MProtocolBase& aProtocol) = 0;
+	virtual TInt BytesAvailable() = 0;
+	virtual ~MTransportBase() {};
+	};
+
+
+class MProtocolBase
+	{
+	public:
+	virtual void RegisterTransport(MTransportBase* aTransport) = 0;
+	virtual TBool DecodePacket(TPtrC8& aData, TUint aLun) = 0;
+	virtual TInt ReadComplete(TInt aError) = 0;
+	virtual TInt Cancel() = 0;
+	virtual void ReportHighSpeedDevice() {};
+	virtual ~MProtocolBase() {};
+	};
+
+
+#endif // PROTOCOL_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/inc/scsiprot.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,233 @@
+// 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: SCSI Protocol layer for USB Mass Storage
+// 
+// 
+
+#ifndef SCSIPROT_H
+#define SCSIPROT_H
+
+
+// Header files
+#include "filesystemimage.h"
+#include "protocol.h"
+#include "mscfilecontroller.h"
+#include "usbmscfileshared.h"
+
+// Define MSDC_MULTITHREADED to use Mass Storage multi-threaded (Double-buffering) disk read/writes.
+// smassstorage_db.mmp defines this macro.
+
+
+// Display time taken to write data to disk
+//#define MEASURE_AND_DISPLAY_WRITE_TIME
+// Display time taken to read data from disk
+//#define MEASURE_AND_DISPLAY_READ_TIME
+
+
+// Maximum size for SCSI Read10 Write10 and Verify10 commands
+// Windows requests size of 64K whereas MAC requests size of 128K
+static const TUint32 KMaxBufSize = 128 * 1024;
+
+// Write to media when data is available
+static const TUint32 KDefaultMediaWriteSize = 4 * 1024;
+
+// Use in the HS case a write size of 64KB
+static const TUint32 KHsMediaWriteSize = 64 * 1024;
+
+
+/**
+Sense Info
+*/
+class TSenseInfo
+	{
+public:
+	// Spec: SCSI Primary Commands 3 (SPC-3)
+	// Section 4.5.6 Sense key and sense code defintions
+	// Table 27 - Sense key descriptions
+	enum TSenseCode
+		{
+		ENoSense        = 0,
+		ERecoveredError = 1,
+		ENotReady       = 2,
+		EMediumError    = 3,
+		EHardwareError  = 4,
+		EIllegalRequest = 5,
+		EUnitAttention  = 6,
+		EDataProtection = 7,
+		EBlankCheck     = 8,
+		EVendorSpecific = 9,
+		ECopyAborted    = 10,
+		EAbortedCommand = 11,
+		EDataOverflow   = 13,
+		EMisCompare     = 14
+		};
+
+	// Table 28 - ASC and ASQ assignments
+	enum TAdditionalCode
+		{
+		EAscNull								 = 0x00,
+		EAscLogicalUnitNotReady					 = 0x04,
+		EAscLogicalUnitDoesNotRespondToSelection = 0x05,
+		EInvalidCmdCode							 = 0x20,
+		ELbaOutOfRange							 = 0x21,
+		EInvalidFieldInCdb						 = 0x24,
+		ELuNotSupported							 = 0x25,
+		EWriteProtected							 = 0x27,
+		ENotReadyToReadyChange					 = 0x28,
+		EMediaNotPresent						 = 0x3A,
+		EInsufficientRes						 = 0x55
+		};
+
+	enum TAdditionalSenseCodeQualifier
+		{
+		EAscqNull								   = 0x00,
+		EAscqLogicalUnitIsInProcessOfBecomingReady = 0x01
+		};
+
+public:
+	TSenseInfo();
+
+	void SetSense(TSenseCode aSenseCode);
+
+	void SetSense(TSenseCode aSenseCode,
+				  TAdditionalCode aAdditional);
+
+	void SetSense(TSenseCode aSenseCode,
+				  TAdditionalCode aAdditional,
+				  TAdditionalSenseCodeQualifier aQualifier);
+
+	TBool SenseOk();
+
+public:
+	TUint8 iSenseCode;
+	TUint8 iAdditional;
+	TUint8 iQualifier;
+	};
+
+
+/**
+Returns EFalse if a sense code has been set. 
+Note that ENoSense indicates that there is no specific sense key infotmation
+to be reported and the command was successful. 
+*/
+inline TBool TSenseInfo::SenseOk()
+	{
+	return (iSenseCode == ENoSense);
+	}
+
+
+const TUint KModeSenseCommandLength = 4;
+const TUint KReadCapacityCommandLength = 8;
+const TUint KReadFormatCapacitiesCommandLength = 12;
+const TUint KRequestSenseCommandLength = 18;
+const TUint KInquiryCommandLength = 36;
+
+const TUint KCommandBufferLength = KInquiryCommandLength;
+
+
+/**
+The CScsiProtocol is responsible for interpreting the data received from the Transpor layer
+and where appropriate routing specific requests through to the appropriate drive unit.
+
+@internalTechnology
+*/
+class CScsiProtocol : public CBase, public MProtocolBase
+	{
+public:
+	enum TCommand
+	{
+    ETestUnitReady          = 0x00,
+    ERequestSense           = 0x03,
+    EInquiry                = 0x12,
+    EModeSense              = 0x1A,
+    EStartStopUnit          = 0x1B,
+    EPreventMediaRemoval    = 0x1E,
+    EReadFormatCapacities   = 0x23, // not supported for CD-ROM
+    EReadCapacity           = 0x25,
+    ERead10                 = 0x28,
+    EWrite10                = 0x2A, // not supported for CD-ROM
+    EVerify10               = 0x2f, // not supported for CD-ROM
+    EReadTOC                = 0x43,
+    EGetConfiguration       = 0x46,
+    EModeSense10            = 0x5A,
+    ERead12                 = 0xA8,
+    EUndefinedCommand       = 0xFF
+	};
+
+
+public:
+
+	static CScsiProtocol* NewL(CMscFileController& aController);
+	void RegisterTransport(MTransportBase* aTransport);
+	void ReportHighSpeedDevice();
+	TBool DecodePacket(TPtrC8& aData, TUint aLun);
+	TInt ReadComplete(TInt aError);
+	TInt SetScsiParameters(TMassStorageConfig aConfig);
+	TInt Cancel();
+	~CScsiProtocol();
+
+private:
+	CScsiProtocol(CMscFileController& aController);
+	void  ConstructL();
+	CFileSystemImage* GetCheckFs(TUint aLun);
+    TBool HandleUnitReady(TUint aLun);
+    TBool HandleRequestSense(TPtrC8& aData);
+    TBool HandleInquiry(TPtrC8& aData, TUint aLun);
+    TBool HandleStartStopUnit(TPtrC8& aData, TUint aLun);
+    TBool HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun);
+    TBool HandleReadCapacity(TPtrC8& aData, TUint aLun);
+    TBool HandleRead10(TPtrC8& aData, TUint aLun);
+    TBool HandleRead12(TPtrC8& aData, TUint aLun);
+    TBool HandleModeSense(TPtrC8& aData, TUint aLun);
+    TBool HandleModeSense10(TPtrC8& aData, TUint aLun);
+    TBool HandleReadTOC(TPtrC8& aData, TUint aLun);
+    TBool HandleGetConfiguration(TPtrC8& aData, TUint aLun);
+
+private:
+	/** Configuration data for INQUIRY command*/
+	TMassStorageConfig iConfig;
+
+	/** reference to the Drive Manager */
+	CMscFileController& iController;
+	
+	/** pointer to the transport level */
+	MTransportBase* iTransport; 
+
+	/** Sense Info */
+	TSenseInfo iSenseInfo;
+
+	/** General buffer for read/write operations */
+	TBuf8<KMaxBufSize> iCommandBuf;
+
+	/** StartL offset (in bytes) for Write/Verify */
+	TInt64 iOffset;
+
+	/** Last command for SetupRead (Write or Verify) */
+	TUint8 iLastCommand;
+
+	/** LUN for SetupRead */
+	TUint iLastLun;
+
+#ifdef SIMDISK
+	CArrayFixFlat<TUint8>* iSimDisk;
+#endif
+
+	/** The number of bytes remaining to be read from the host for write operations */
+	TUint32 iBytesRemain;
+
+	/** Write to the media when this amount of data is available */
+	TUint32 iMediaWriteSize;
+
+	};
+
+#endif // SCSIPROT_H
Binary file usbclasses/usbphoneasmodem/classimplementation/mscfileserver/rom/phone_as_modem.iso has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/rom/usbmscfileserver.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:  Image description file for project usbmscfilepersonality
+*
+*/
+
+
+#ifndef __USBMSCFILESERVER_IBY__
+#define __USBMSCFILESERVER_IBY__
+//file content
+
+#ifdef FF_USB_MODEM
+
+file=ABI_DIR\BUILD_DIR\usbmscfileserver.exe    PROGRAMS_DIR\usbmscfileserver.exe
+
+data=DATAZ_\private\2000FDA7\phone_as_modem.iso    Private\2000FDA7\phone_as_modem.iso
+
+#endif
+
+#endif // __USBMSCFILESERVER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/bulkonlytransport.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1491 @@
+// 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:
+// 
+// 
+
+#include "bulkonlytransport.h"
+#include "mscfileserver.h"
+#include "usbmscfileshared.h"
+#include "debug.h"
+#define InEndpoint EEndpoint1
+#define OutEndpoint EEndpoint2
+//This value defined in USB Mass Storage Bulk Only Transrt spec and not supposed to be changed
+LOCAL_D const TInt KRequiredNumberOfEndpoints = 2; // in addition to endpoint 0. 
+
+
+//CBW offsets
+LOCAL_D const TInt KCbwSignatureOffset = 0;
+LOCAL_D const TInt KCbwTagOffset = 4;
+LOCAL_D const TInt KCbwDataTransferLengthOffset = 8;
+LOCAL_D const TInt KCbwFlagOffset = 12;
+LOCAL_D const TInt KCbwLunOffset = 13;
+LOCAL_D const TInt KCbwCbLengthOffset = 14;
+LOCAL_D const TInt KMaxCbwcbLength = 16;
+// CSW offsets
+LOCAL_D const TInt KCswSingnatureOffset = 0;
+LOCAL_D const TInt KCswTagOffset = 4;
+LOCAL_D const TInt KCswDataResidueOffset = 8;
+LOCAL_D const TInt KCswStatusOffset = 12;
+LOCAL_D const TInt KCswLength = 13;
+LOCAL_D const TInt KUsbNumInterfacesOffset = 4;
+
+/**
+ This function unpacks into the TUsbRequestHdr class from a descriptor with 
+ the alignment that would be introduced on the USB bus.
+ 
+ @param aBuffer Input buffer
+ @param aTarget Unpacked header.
+ @return Error.
+ */
+TInt TUsbRequestHdr::Decode(const TDesC8& aBuffer)
+
+    {
+    if (aBuffer.Length() < static_cast<TInt> (KRequestHdrSize))
+        {
+        TRACE_ERROR((_L("TUsbRequestHdr::Decode buffer invalid length %d"),aBuffer.Length()))
+        return KErrGeneral;
+        }
+
+    // Decode as SPEC 1.3.3
+    iRequestType = aBuffer[0];
+    iRequest = static_cast<TEp0Request>(aBuffer[1]);
+    iValue = static_cast<TUint16>(aBuffer[2] + (aBuffer[3] << 8));
+    iIndex = static_cast<TUint16>(aBuffer[4] + (aBuffer[5] << 8));
+    iLength = static_cast<TUint16>(aBuffer[6] + (aBuffer[7] << 8));
+    TRACE_INFO((_L("type=%d request=%d value=%d index=%d length=%d"), iRequestType,iRequest,iValue,iIndex,iLength))
+
+    return KErrNone;
+    }
+
+/**
+ This function determines whether data is required by the host in response 
+ to a message header.
+
+ @return TBool	Flag indicating whether a data response required.
+ */
+TBool TUsbRequestHdr::IsDataResponseRequired() const
+
+    {
+    return (iRequestType & 0x80) ? ETrue : EFalse;
+    }
+
+//
+/**
+ Called by CBulkOnlyTransport to create an instance of CControlInterface
+
+ @param aParent reference to the CBulkOnlyTransport
+ */
+CControlInterface* CControlInterface::NewL(CBulkOnlyTransport& aParent)
+    {
+    CControlInterface* self = new (ELeave) CControlInterface(aParent);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CActiveScheduler::Add(self);
+    CleanupStack::Pop();
+    return self;
+    }
+
+void CControlInterface::ConstructL()
+    {
+    }
+
+/**
+ c'tor
+
+ @param aParent reference to the CBulkOnlyTransport
+ */
+CControlInterface::CControlInterface(CBulkOnlyTransport& aParent) :
+	CActive(EPriorityStandard),
+	iParent(aParent),
+	iCurrentState(ENone)
+    {
+    }
+
+/**
+ d'tor
+ */
+CControlInterface::~CControlInterface()
+    {
+    TRACE_FUNC
+	Cancel();
+    }
+
+/**
+ Called by  CBulkOnlyTransportStart to start control interface
+ */
+TInt CControlInterface::Start()
+    {
+    TRACE_FUNC
+    TInt res = ReadEp0Data();
+    return (res);
+    }
+
+/**
+ Called by CBulkOnlyTransportStart to stop control interface
+ */
+void CControlInterface::Stop()
+    {
+    TRACE_FUNC
+    // Don't need to be any thing if we're not in active state
+    if (!IsActive())
+        {
+        TRACE_INFO((_L("Not active")))
+        return;
+        }
+
+    TRACE_INFO((_L("Stopping...")))
+
+    // Stop by cancel
+    Cancel();
+    iCurrentState = ENone;
+    }
+
+/**
+ Cancel outstanding request (if any)
+ */
+void CControlInterface::DoCancel()
+    {
+    TRACE_FUNC
+    switch(iCurrentState)
+        {
+        case EReadEp0Data:
+        iParent.Ldd().ReadCancel(EEndpoint0);
+        break;
+        case ESendMaxLun:
+        iParent.Ldd().WriteCancel(EEndpoint0);
+        break;
+        default:
+        TRACE_ERROR((_L("\nWrong state !")))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
+        }
+    }
+
+/**
+ Implement CControlInterface state machine
+ */
+void CControlInterface::RunL()
+    {
+    TRACE_FUNC
+    if (iStatus != KErrNone)
+        {
+        TRACE_ERROR(( _L( "Error %d in RunL" ), iStatus.Int() ))
+
+        //read EP0  again 
+        ReadEp0Data();
+        return;
+        }
+
+    switch (iCurrentState)
+        {
+        case ESendMaxLun:
+            ReadEp0Data();
+            break;
+
+        case EReadEp0Data:
+            DecodeEp0Data();
+            break;
+
+        default:
+            TRACE_ERROR(( _L( "error: (Shouldn't end up here...)" ) ))
+            __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
+            break;
+        }
+    return;
+    }
+
+/**
+ Post a read request to EEndpoint0 to read request header
+ */
+TInt CControlInterface::ReadEp0Data()
+    {
+    TRACE_FUNC
+    if ( IsActive() )
+        {
+        TRACE_ERROR(( _L( "Still active" ) ))
+        return KErrServerBusy;
+        }
+
+    iParent.Ldd().Read(iStatus, EEndpoint0, iData, KRequestHdrSize);
+
+    iCurrentState = EReadEp0Data;
+
+    SetActive();
+    return KErrNone;
+    }
+
+/**
+ Decode request header and do appropriate action - get max LUN info or post a reset request
+ */
+void CControlInterface::DecodeEp0Data()
+    {
+    TRACE_FUNC
+    if ( IsActive() )
+        {
+        TRACE_ERROR(( _L( "Still active" ) ))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceStillActive));
+        return;
+        }
+
+    TInt err = iRequestHeader.Decode(iData);
+
+    if (err != KErrNone)
+        {
+        TRACE_WARNING((_L("Decode header error : err=%d"), err))
+        return;
+        }
+
+    switch(iRequestHeader.iRequest)
+        {
+        // GET MAX LUN (0xFE)
+        case TUsbRequestHdr::EReqGetMaxLun:
+            {
+            TRACE_INFO((_L("DecodeEp0Data : 'Get Max LUN' Request MaxLun = %d" ),
+                            iParent.MaxLun() ))
+
+            if ( iRequestHeader.iRequestType != 0xA1 //value from USB MS BOT spec
+                    || iRequestHeader.iIndex> 15 || iRequestHeader.iValue != 0 || iRequestHeader.iLength != 1)
+                {
+                TRACE_ERROR((_L("GetMaxLun command packet check error")))
+                iParent.Ldd().EndpointZeroRequestError();
+                break;
+                }
+
+            iData.FillZ(1); //Return only 1 byte to host 
+            iData[0] = static_cast<TUint8>(iParent.MaxLun()); // Supported Units
+            iParent.Ldd().Write(iStatus, EEndpoint0, iData, 1);
+
+            iCurrentState = ESendMaxLun;
+            SetActive();
+
+            return;
+            }
+
+        // RESET (0xFF)
+        case TUsbRequestHdr::EReqReset:
+            {
+            TRACE_INFO((_L("DecodeEp0Data : 'Mass Storage Reset' Request")))
+
+            if ( iRequestHeader.iRequestType != 0x21 //value from USB MS BOT spec
+                    || iRequestHeader.iIndex> 15 || iRequestHeader.iValue != 0 || iRequestHeader.iLength != 0)
+                {
+                TRACE_ERROR((_L("MSC Reset command packet check error")))
+                iParent.Ldd().EndpointZeroRequestError();
+                break;
+                }
+
+            iParent.HwStop();
+            iParent.Controller().Reset();
+            iParent.HwStart(ETrue);
+
+            err = iParent.Ldd().SendEp0StatusPacket();
+            TRACE_INFO((_L("SendEp0StatusPacket: err=%d"), err))
+
+            return;
+            }
+        // Unknown?
+        default:
+            {
+            TRACE_ERROR((_L("DecodeEp0Data : Unknown Request")))
+            }
+        }
+    ReadEp0Data(); //try to get another request 
+    }
+
+//-------------------------------------
+/**
+ Create CBulkOnlyTransport object
+ @param aNumDrives - The number of drives available for MS
+ @param aController - reference to the parent
+ @return pointer to newly created object
+ */
+CBulkOnlyTransport* CBulkOnlyTransport::NewL(TInt aNumDrives,CMscFileController& aController)
+    {
+	CBulkOnlyTransport* self = new(ELeave) CBulkOnlyTransport(aNumDrives, aController);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+ c'tor 
+ @param aNumDrives - The number of drives available for MS
+ @param aController - reference to the parent
+ */
+CBulkOnlyTransport::CBulkOnlyTransport(TInt aNumDrives,CMscFileController& aController):
+	CActive(EPriorityStandard),
+	iMaxLun(aNumDrives-1),
+	iController(aController),
+	iReadBuf(NULL,0),
+	iWriteBuf(NULL,0),
+	iStallAllowed(ETrue)
+    {
+    }
+
+/**
+ Constructs the CBulkOnlyTranspor object
+ */
+void CBulkOnlyTransport::ConstructL()
+    {
+    TRACE_FUNC
+    iControlInterface = CControlInterface::NewL(*this);
+    iDeviceStateNotifier = CActiveDeviceStateNotifier::NewL(*this);
+    CActiveScheduler::Add(this);
+    }
+
+/**
+ Destructor
+ */
+CBulkOnlyTransport::~CBulkOnlyTransport()
+    {
+    TRACE_FUNC
+    if (iInterfaceConfigured)
+        {
+        Stop();
+        }
+    delete iControlInterface;
+    delete iDeviceStateNotifier;
+    }
+
+/**
+ Set or unset configuration descriptor for USB MassStorage Bulk Only transport
+
+ @param aUnset indicate whether set or unset descriptor
+ @return KErrNone if operation was completed successfully, errorcode otherwise
+ */
+TInt CBulkOnlyTransport::SetupConfigurationDescriptor(TBool aUnset)
+    {
+    TRACE_FUNC
+    TInt ret(KErrNone);
+    TInt configDescriptorSize(0);
+
+    iLdd.GetConfigurationDescriptorSize(configDescriptorSize);
+    if (static_cast<TUint> (configDescriptorSize) != KUsbDescSize_Config)
+        {
+        return KErrCorrupt;
+        }
+
+    TBuf8<KUsbDescSize_Config> configDescriptor;
+    ret = iLdd.GetConfigurationDescriptor(configDescriptor);
+    if (ret != KErrNone)
+        {
+        return ret;
+        }
+
+    // I beleive that other fields setted up during LDD initialisation
+    if (aUnset)
+        {
+        --configDescriptor[KUsbNumInterfacesOffset];
+        }
+    else
+        {
+        ++configDescriptor[KUsbNumInterfacesOffset];
+        }
+    ret = iLdd.SetConfigurationDescriptor(configDescriptor);
+
+    return ret;
+    }
+
+/**
+ Set up interface descriptor
+
+ @return KErrNone if operation was completed successfully, errorcode otherwise
+ */
+TInt CBulkOnlyTransport::SetupInterfaceDescriptors()
+    {
+    TRACE_FUNC
+    // Device caps
+    TUsbDeviceCaps d_caps;
+    TInt ret = iLdd.DeviceCaps(d_caps);
+    if (ret != KErrNone)
+        {
+        return ret;
+        }
+    TInt totalEndpoints = d_caps().iTotalEndpoints;
+    if (totalEndpoints < KRequiredNumberOfEndpoints)
+        {
+        return KErrHardwareNotAvailable;
+        }
+
+    // Endpoint caps
+    TUsbcEndpointData data[KUsbcMaxEndpoints];
+	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
+    ret = iLdd.EndpointCaps(dataptr);
+    if (ret != KErrNone)
+        {
+        return ret;
+        }
+
+    // Set the active interface
+    TUsbcInterfaceInfoBuf ifc;
+    TInt ep_found = 0;
+    TBool foundBulkIN = EFalse;
+    TBool foundBulkOUT = EFalse;
+
+    for (TInt i = 0; i < totalEndpoints; i++)
+        {
+        const TUsbcEndpointCaps* caps = &data[i].iCaps;
+        const TInt maxPacketSize = caps->MaxPacketSize();
+		if (!foundBulkIN &&
+			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
+            {
+            // InEndpoint is going to be our TX (IN, write) endpoint
+            ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
+            ifc().iEndpointData[0].iDir = KUsbEpDirIn;
+            ifc().iEndpointData[0].iSize = maxPacketSize;
+            ifc().iEndpointData[0].iInterval_Hs = 0;
+			ifc().iEndpointData[0].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA;
+            foundBulkIN = ETrue;
+            if (++ep_found == KRequiredNumberOfEndpoints)
+                {
+                break;
+                }
+            continue;
+            }
+		if (!foundBulkOUT &&
+			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
+            {
+            // OutEndpoint is going to be our RX (OUT, read) endpoint
+            ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
+            ifc().iEndpointData[1].iDir = KUsbEpDirOut;
+            ifc().iEndpointData[1].iSize = maxPacketSize;
+            ifc().iEndpointData[1].iInterval_Hs = 0;
+			ifc().iEndpointData[1].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA;
+            foundBulkOUT = ETrue;
+            if (++ep_found == KRequiredNumberOfEndpoints)
+                {
+                break;
+                }
+            continue;
+            }
+        }
+    if (ep_found != KRequiredNumberOfEndpoints)
+        {
+        return KErrHardwareNotAvailable;
+        }
+    _LIT16(string, "USB Mass Storage Interface");
+    ifc().iString = const_cast<TDesC16*> (&string);
+    ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
+    ifc().iClass.iClassNum = 0x08; // Mass Storage
+    ifc().iClass.iSubClassNum = 0x06; // SCSI Transparent Command Set
+    ifc().iClass.iProtocolNum = 0x50; // Bulk Only Transport
+
+	TUint bandwidth_priority = (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault);
+    if (d_caps().iHighSpeed)
+        {
+        // If this device supports USB High-speed, then we request 64KB buffers
+        // (otherwise the default 4KB ones will do).
+        bandwidth_priority = (EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2);
+        // Also, tell the Protocol about it, because it might want to do some
+        // optimizing too.
+        iProtocol->ReportHighSpeedDevice();
+        }
+    ret = iLdd.SetInterface(0, ifc, bandwidth_priority);
+    return ret;
+    }
+
+/**
+ Called by the protocol after processing the packet to indicate that more data is required.  
+
+ @param aData reference to the data buffer. 
+ */
+void CBulkOnlyTransport::SetupReadData(TPtr8& aData)
+    {
+    TRACE_FUNC
+    TRACE_INFO((_L("Length = %d  (bytes)"), aData.Length()))
+    iReadBuf.Set(aData);
+    iReadSetUp = ETrue;
+    }
+
+/**
+ Called by the protocol after processing the packet to indicate that data should be written to the host.  
+
+ @param aData reference to the data buffer. 
+ */
+void CBulkOnlyTransport::SetupWriteData(TPtrC8& aData)
+    {
+    TRACE_FUNC
+    TRACE_INFO((_L("Length = %d  (bytes)"), aData.Length()))
+    iWriteBuf.Set(aData);
+    iWriteSetUp = ETrue;
+    }
+
+TInt CBulkOnlyTransport::Start()
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt err = KErrNone;
+
+    if (!iProtocol)
+        {
+        return KErrBadHandle; //protocol should be set up before start
+        }
+
+    if (IsActive())
+        {
+        TRACE_ERROR((_L("Active before start!")))
+        return KErrInUse;
+        }
+
+    if ((err = iLdd.Open(0)) != KErrNone )
+        {
+        TRACE_ERROR((_L("Error during open ldd!")))
+        return err;
+        }
+
+    if ((err = SetupConfigurationDescriptor()) != KErrNone ||
+            (err = SetupInterfaceDescriptors()) != KErrNone )
+        {
+        iLdd.Close();
+        TRACE_ERROR((_L("Error during descriptors setup!")))
+        return err;
+        }
+
+    iDeviceStateNotifier->Activate(); // activate notifier wich will wait until USB became configured
+    TUsbcDeviceState deviceStatus = EUsbcDeviceStateDefault;
+    err = iLdd.DeviceStatus(deviceStatus);
+    TRACE_INFO((_L("Device status = %d"), deviceStatus))
+    if (err == KErrNone && deviceStatus == EUsbcDeviceStateConfigured)
+        {
+        TRACE_INFO(_L("Starting bulk only transport\n"));
+        err = HwStart();
+        }
+    iInterfaceConfigured = ETrue;
+    TRACE_FUNC_EXIT
+    return err;
+    }
+
+TInt CBulkOnlyTransport::HwStart(TBool aDiscard)
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt res = iControlInterface->Start();
+
+    iCurrentState = ENone;
+    iWriteSetUp = EFalse;
+    iReadSetUp = EFalse;
+    iStarted = ETrue;
+
+    if (aDiscard)
+        {
+        TInt bytes;
+        const TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
+        if (err != KErrNone || bytes <= 0)
+            {
+            TRACE_ERROR((_L("Error: err=%d bytes=%d"), bytes))
+            }
+        else
+            {
+            TRACE_ERROR((_L("RxBuffer has %d bytes"), bytes))
+            ReadAndDiscardData(bytes);
+            }
+        }
+
+    ReadCBW();
+    TRACE_FUNC_EXIT
+    return res;
+    }
+
+TInt CBulkOnlyTransport::HwStop()
+    {
+    TRACE_FUNC
+
+    if (iStarted)
+        {
+        Cancel();
+        iControlInterface->Cancel();
+        iProtocol->Cancel();
+        iStarted = EFalse;
+        }
+    return KErrNone;
+    }
+
+TInt CBulkOnlyTransport::HwSuspend()
+    {
+    TRACE_FUNC
+    return KErrNone;
+    }
+
+TInt CBulkOnlyTransport::HwResume()
+    {
+    TRACE_FUNC
+    return KErrNone;
+    }
+
+/**
+ Stops the Bulk Only Transport
+ */
+TInt CBulkOnlyTransport::Stop()
+    {
+    TRACE_FUNC
+    iControlInterface->Cancel();
+    iDeviceStateNotifier->Cancel();
+    Cancel();
+    if (iInterfaceConfigured)
+        {
+        iLdd.ReleaseInterface(0);
+        SetupConfigurationDescriptor(ETrue);
+        iLdd.Close();
+        }
+    iCurrentState = ENone;
+    iInterfaceConfigured = EFalse;
+
+    return KErrNone;
+    }
+
+/**
+ Read aLength bytes of data from the host into the read buffer.
+ @param aLength The number of bytes to read from the host.
+ */
+void CBulkOnlyTransport::ReadCBW()
+    {
+    TRACE_FUNC
+    if (IsActive())
+        {
+        TRACE_ERROR(( _L( "Still active" ) ))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+        return;
+        }
+
+    iCbwBuf.SetMax();
+    iLdd.ReadUntilShort(iStatus, OutEndpoint, iCbwBuf, iCbwBuf.Length());
+
+    iCurrentState = EWaitForCBW;
+    SetActive();
+    }
+
+void CBulkOnlyTransport::DoCancel()
+    {
+    TRACE_FUNC
+    iLdd.WriteCancel(InEndpoint);
+    iLdd.ReadCancel(OutEndpoint);
+    }
+
+void CBulkOnlyTransport::Activate(TInt aReason)
+    {
+    SetActive();
+    TRequestStatus* r = &iStatus;
+    User::RequestComplete(r, aReason);
+    }
+
+void CBulkOnlyTransport::RunL()
+    {
+    TRACE_FUNC
+    if (iStatus != KErrNone)
+        {
+        TRACE_ERROR((_L("Error %d in RunL, halt endpoints \n"), iStatus.Int()))
+        SetPermError(); //halt endpoints for reset recovery
+        return;
+        }
+
+    switch (iCurrentState)
+        {
+        case EWaitForCBW:
+            TRACE_INFO((_L("EWaitForCBW")))
+            DecodeCBW();
+            break;
+
+        case EWritingData:
+            TRACE_INFO((_L("EWritingData")))
+            iWriteSetUp = EFalse; //the buffer was used
+
+            if (iDataResidue && iStallAllowed)
+                {
+                StallEndpointAndWaitForClear(InEndpoint);
+                }
+
+            SendCSW(iCbwTag, iDataResidue, iCmdStatus);
+            break;
+
+        case EReadingData:
+            {
+            TRACE_INFO((_L("EReadingData")))
+
+            TInt ret = KErrNone;
+            FOREVER
+                {
+                if (iReadSetUp)
+                    {
+                    ret = iProtocol->ReadComplete(KErrNone);
+                    }
+
+                TUint deviceDataLength = static_cast<TUint>(iReadBuf.Length());
+                if(ret == KErrCompletion)
+                    {
+                    // The protocol has indicated with KErrCompletion that sufficient
+                    // data is available in the buffer to process the transfer immediately.
+                    iDataResidue -= deviceDataLength;
+                    iLdd.Read(iStatus, OutEndpoint, iReadBuf, deviceDataLength);
+                    User::WaitForRequest(iStatus);
+                    if (iStatus != KErrNone)
+                        {
+                        // An error occurred - halt endpoints for reset recovery
+                        TRACE_ERROR((_L("Error %d in EReadingData, halt endpoints"),
+                                        iStatus.Int()))
+                        SetPermError();
+                        return;
+                        }
+                    }
+                else if(ret == KErrNotReady)
+                    {
+                    // The protocol has indicated with KErrNotReady that insufficient
+                    // data is available in the buffer, so should wait for it to arrive
+                    ReadData(deviceDataLength);
+                    break;
+                    }
+                else
+                    {
+                    // The protocol has indicated that transfer is 
+                    // complete, so send the CSW response to the host.
+                    iReadSetUp = EFalse;
+
+                    if (ret != KErrNone)
+                        {
+                        iCmdStatus = ECommandFailed;
+                        }
+
+                    if (iDataResidue)
+                        {
+                        TRACE_INFO((_L("Discarding residue")))
+                        // we have to read as much data as available that host PC sends;
+                        // otherwise, bulk-out endpoint will need to keep sending NAK back.
+                        ReadAndDiscardData(iDataResidue);
+                        }
+                    SendCSW(iCbwTag, iDataResidue, iCmdStatus);
+                    break;
+                    }
+                }
+            }
+        break;
+
+        case ESendingCSW:
+        TRACE_INFO((_L("ESendingCSW")))
+        ReadCBW();
+        break;
+
+        case EPermErr:
+        TRACE_INFO((_L("EPermErr")))
+        StallEndpointAndWaitForClear(InEndpoint);
+        break;
+
+        default:
+        SetPermError(); // unexpected state
+        }
+    }
+
+/**
+ Prepare incase we need to read data from host
+ Called in DecodeCBW(...)
+ @param aHostDataLength The number of bytes to read from the host.
+ */
+void CBulkOnlyTransport::PrepareReadFromHost(TUint aHostDataLength)
+    {
+    if (!iReadSetUp)
+        {
+			iDataResidue =aHostDataLength;
+			TRACE_INFO((_L("Read buffer was not setup\n")))
+            //Use next block instead of StallEndpointAndWaitForClear(OutEndpoint); 
+            {
+            iBuf.SetLength(KBOTMaxBufSize);
+            TUint c =0;
+            TRequestStatus status;
+            while (c<aHostDataLength)
+                {
+                TInt len;
+                if (aHostDataLength - c> KBOTMaxBufSize)
+                    {
+                    len = KBOTMaxBufSize;
+                    }
+                else
+                    {
+                    len = aHostDataLength - c;
+                    }
+
+                iLdd.Read(status, OutEndpoint, iBuf, len);
+                User::WaitForRequest(status);
+                c += KBOTMaxBufSize;
+                }
+            }
+
+        if (iWriteSetUp) //case (10)
+            {
+            TRACE_INFO((_L("case 10\n")))
+            SendCSW(iCbwTag, aHostDataLength, EPhaseError);
+            }
+        else // case (9)
+
+            {
+            TRACE_INFO((_L("Case 9\n")))
+            SendCSW(iCbwTag, aHostDataLength, iCmdStatus);
+            }
+
+        return;
+        }
+    else
+        {
+        TUint deviceDataLength = static_cast<TUint>(iReadBuf.Length());
+        iDataResidue =aHostDataLength - deviceDataLength;
+        TRACE_INFO((_L("deviceDataLength=%d, DataResidue (read from host) =%d\n"),
+                        deviceDataLength,iDataResidue))
+
+        if (deviceDataLength <= aHostDataLength) // case (11) and (12)
+
+            {
+            TRACE_INFO((_L("Case 11 or 12\n")))
+            ReadData(deviceDataLength);
+            return;
+            }
+
+        if (deviceDataLength> aHostDataLength) // case  (13)
+
+            {
+            TRACE_INFO((_L("Case 13\n")))
+            /**
+             * Comment following line in order to pass compliant test.
+             * As spec said in case 13:"The device may receive data up to a
+             * total of dCBWDataTransferLength."
+             * Here we choose to ignore incoming data.
+             */
+            //StallEndpointAndWaitForClear(OutEndpoint); //Stall Out endpoint
+            if (iReadSetUp)
+                {
+                iLdd.Read(iStatus, OutEndpoint, iReadBuf, aHostDataLength);
+                User::WaitForRequest(iStatus);
+                iProtocol->ReadComplete(KErrGeneral);
+                iReadSetUp = EFalse;
+                }
+            SendCSW(iCbwTag, aHostDataLength, EPhaseError);
+            return;
+            }
+        }
+    }
+
+/**
+ Prepare incase we need to read data from host
+ Called in DecodeCBW(...)
+ @param aHostDataLength The number of bytes to write to the host.
+ */
+void CBulkOnlyTransport::PrepareWriteToHost(TUint aHostDataLength)
+    {
+    if (!iWriteSetUp) //write buffer was not set up 
+        {
+        TRACE_INFO((_L("Write buffer was not setup")))
+        iDataResidue =aHostDataLength;
+        TRACE_INFO((_L("DataResidue (write to host)=%d"),iDataResidue))
+
+        //------------------------------------
+        if (aHostDataLength <= KBOTMaxBufSize)
+            {
+            TRACE_INFO((_L("Case 4 or 8\n")))
+            iBuf.FillZ(aHostDataLength);
+            iLdd.Write(iStatus, InEndpoint, iBuf, aHostDataLength);
+            SetActive();
+            iCurrentState = EWritingData;
+            iStallAllowed = EFalse;
+            if (iReadSetUp) //read buffer WAS set up - case (8)
+
+                {
+                TRACE_INFO((_L("It is Case 8")))
+                iCmdStatus = EPhaseError;
+                }
+            return;
+            }
+        else
+        //------------------------------------
+        //					Use next block instead of StallEndpointAndWaitForClear(InEndpoint);
+
+            {
+            iBuf.FillZ(KBOTMaxBufSize);
+            TUint c =0;
+            TRequestStatus status;
+            while (c<aHostDataLength)
+                {
+                TInt len;
+                if (aHostDataLength - c> KBOTMaxBufSize)
+                    {
+                    len = KBOTMaxBufSize;
+                    }
+                else
+                    {
+                    len = aHostDataLength - c;
+                    }
+
+                iLdd.Write(status, InEndpoint, iBuf, len);
+                User::WaitForRequest(status);
+                c += KBOTMaxBufSize;
+                }
+            }
+
+        if (iReadSetUp) //read buffer WAS set up - case (8)
+            {
+            TRACE_INFO(_L("Case 8"));
+            SendCSW(iCbwTag, aHostDataLength, EPhaseError);
+            //don't care to reset any flag - should get reset recovery
+            }
+        else // case (4)
+            {
+            TRACE_INFO((_L("Case 4")))
+            SendCSW(iCbwTag, aHostDataLength, iCmdStatus);
+            }
+        return;
+        }
+    else
+        {
+        //================== 
+        TUint deviceDataLength = static_cast<TUint>(iWriteBuf.Length());
+        iDataResidue =aHostDataLength - deviceDataLength;
+        TRACE_INFO((_L("Device data length = %d, DataResidue (write to host)=%d"),
+                        deviceDataLength, iDataResidue))
+
+        if (deviceDataLength < aHostDataLength &&
+                aHostDataLength < KBOTMaxBufSize )
+            {
+            TRACE_INFO((_L("Case 5 (padding)\n")))
+            iBuf.Zero();
+            iBuf.Append(iWriteBuf);
+            iBuf.SetLength(aHostDataLength);
+            iStallAllowed = EFalse;
+            TRACE_INFO((_L("iBuf.Length=%d\n"),iBuf.Length()))
+            iLdd.Write(iStatus, InEndpoint, iBuf, aHostDataLength);
+            SetActive();
+            iCurrentState = EWritingData;
+            return;
+            }
+
+        //===================
+
+        if (deviceDataLength == aHostDataLength) //case (6)[==]
+
+            {
+            TRACE_INFO((_L("Case 6\n")))
+            WriteData(deviceDataLength);
+            return;
+            }
+        else if (deviceDataLength < aHostDataLength) //case (5)[<]
+
+            {
+            TRACE_INFO((_L("Case 5\n")))
+            WriteData(deviceDataLength, ETrue); // Send ZLP
+            return;
+            }
+        else // deviceDataLength > aHostDataLength - case (7)
+
+            {
+            TRACE_INFO((_L("Case 7\n")))
+            iCmdStatus = EPhaseError;
+            iDataResidue = 0;
+            WriteData(aHostDataLength);
+            return;
+            }
+        }
+    }
+
+/**
+ Decode the CBW received from the host via OutEndpoint
+
+ - If the header is valid, the data content is passed to the parser.
+ - Depending on the command, more data may be transmitted/received.
+ - ...or the CSW is sent (if not a data command).
+
+ */
+void CBulkOnlyTransport::DecodeCBW()
+    {
+    TRACE_FUNC
+    if (!CheckCBW()) //check if CBW valid and meaningful
+
+        {
+        // CBW not valid or meaningful
+        // Specification says: "If the CBW is not valid, the device shall STALL
+        // the Bulk-In pipe. Also, the device shall either STALL the Bulk-Out pipe,
+        // or the device shall accept and discard any Bulk-Out data. The device
+        // shall maintain this state until a Reset Recovery."
+        // Here we keep bulk-in ep stalled and ignore bulk-out ep.
+        SetPermError();
+        return;
+        }
+
+    TPtrC8 aData;
+    aData.Set(&iCbwBuf[KCbwCbLengthOffset], KMaxCbwcbLength + 1); //prepare data for protocol starting form Length 
+    TUint8 lun = static_cast<TUint8> (iCbwBuf[13] & 0x0f);
+
+	iCbwTag  =	static_cast<TUint32>(iCbwBuf[KCbwTagOffset])		| 
+				static_cast<TUint32>(iCbwBuf[KCbwTagOffset+1])	<<8 | 
+				static_cast<TUint32>(iCbwBuf[KCbwTagOffset+2])	<<16| 
+				static_cast<TUint32>(iCbwBuf[KCbwTagOffset+3])	<<24;
+
+    TInt i = KCbwDataTransferLengthOffset;
+	TUint hostDataLength = 	static_cast<TUint32>(iCbwBuf[i  ])		| 
+							static_cast<TUint32>(iCbwBuf[i+1]) <<8 	| 
+							static_cast<TUint32>(iCbwBuf[i+2]) <<16	| 
+							static_cast<TUint32>(iCbwBuf[i+3]) <<24;
+
+    TBool dataToHost = iCbwBuf[KCbwFlagOffset] & 0x80;
+
+    TRACE_INFO((_L("lun =%d, hostDataLength=%d, CBWtag = 0x%X\n, dataToHost=%d"),
+                    lun, hostDataLength, iCbwTag, dataToHost))
+    //
+    TBool ret = iProtocol->DecodePacket(aData, lun);
+    //
+
+    iStallAllowed = ETrue;
+
+    if (!ret)
+        {
+        TRACE_INFO((_L("Command Failed")))
+        iCmdStatus = ECommandFailed;
+        }
+    else
+        {
+        TRACE_INFO((_L("Command Passed")))
+        iCmdStatus = ECommandPassed;
+        }
+
+    if (hostDataLength == 0)
+        {
+        TRACE_INFO((_L("No data transfer expected\n")))
+        iDataResidue = 0;
+        if (iWriteSetUp || iReadSetUp) // case (2) and (3)
+
+            {
+            TRACE_INFO((_L("Case 2 or 3\n")))
+            SendCSW(iCbwTag, 0, EPhaseError);
+            }
+        else
+            {
+            TRACE_INFO((_L("Case 1\n")))
+            SendCSW(iCbwTag, 0, iCmdStatus); //case (1)
+            }
+
+        return;
+        }
+    else
+        {
+        // Data Direction, To or From Host
+        if (dataToHost)
+            {
+            PrepareWriteToHost(hostDataLength);
+            }
+        else
+            {
+            PrepareReadFromHost(hostDataLength);
+            }
+        }
+    }
+
+/**
+ Check if CBW Valid and Meaningful.  
+
+ @return ETrue if CBW is Valid and Meaningful, EFalse otherwise
+ */
+TBool CBulkOnlyTransport::CheckCBW()
+    {
+    TRACE_FUNC
+
+    // Check valid
+
+    // Check length
+    if (iCbwBuf.Length() != KCbwLength)
+        {
+        TRACE_INFO((_L("Bad length: %d"), iCbwBuf.Length()))
+        return EFalse;
+        }
+
+    // Check signature
+    TInt i = KCbwSignatureOffset;
+	if (iCbwBuf[i  ] != 0x55 ||         // CBW Singature from USB Bulk-Only Transport spec
+		iCbwBuf[i+1] != 0x53 ||
+		iCbwBuf[i+2] != 0x42 ||
+		iCbwBuf[i+3] != 0x43)
+        {
+        TRACE_INFO((_L("Bad signature")))
+        TRACE_INFO((_L(" 0x%x, 0x%x, 0x%x, 0x%x"),
+                        iCbwBuf[i], iCbwBuf[i+1], iCbwBuf[i+2],iCbwBuf[i+3]))
+        return EFalse;
+        }
+
+    // Check meaningful
+
+    // Check reserved bits ( must be zero )
+    if ((iCbwBuf[KCbwLunOffset] & 0xF0) || (iCbwBuf[KCbwCbLengthOffset] & 0xE0))
+        {
+        TRACE_INFO((_L("Reserved bits not zero\n")))
+        return EFalse;
+        }
+
+    // check command block length
+    TInt cbwcbLength = iCbwBuf[KCbwCbLengthOffset] & 0x1F;
+    if (cbwcbLength>KMaxCbwcbLength)
+        {
+        TRACE_INFO((_L("Incorrect block length\n")))
+        return EFalse;
+        }
+
+    //check LUN
+    TInt8 lun = static_cast<TUint8>(iCbwBuf[KCbwLunOffset] & 0x0f);
+    if (iMaxLun < lun)
+        {
+        TRACE_INFO((_L("bad lun: %d"), lun))
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
+/**
+ Initiate stalling of bulk IN endpoint.
+ Used when protocol wants to force host to initiate a reset recovery.
+ */
+void CBulkOnlyTransport::SetPermError()
+    {
+    TRACE_FUNC
+    iCurrentState = EPermErr;
+    Activate(KErrNone);
+    }
+
+/**
+ Send data provided by protocol to the host
+
+ @param aLength amount of data (in bytes) to be send to host
+ */
+void CBulkOnlyTransport::WriteData(TUint aLength, TBool aZlpRequired)
+    {
+    TRACE_FUNC
+
+    if (IsActive())
+        {
+        TRACE_INFO((_L("Still active")))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+        return;
+        }
+    iLdd.Write(iStatus, InEndpoint, iWriteBuf, aLength, aZlpRequired);
+    iCurrentState = EWritingData;
+    SetActive();
+    }
+
+/**
+ Request data form the host for the protocol
+
+ @param aLength amount of data (in bytes) to be received from the host
+ */
+void CBulkOnlyTransport::ReadData(TUint aLength)
+    {
+    TRACE_FUNC
+    if (IsActive())
+        {
+        TRACE_INFO((_L("Still active")))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+        return;
+        }
+    iLdd.Read(iStatus, OutEndpoint, iReadBuf, aLength);
+    SetActive();
+    iCurrentState = EReadingData;
+    }
+
+/**
+ Send Command Status Wrapper to the host
+
+ @param aTag Echo of Command Block Tag sent by the host.
+ @param aDataResidue the difference between the amount of data expected by the
+ host, and the actual amount of data processed by the device.
+ @param aStatus indicates the success or failure of the command.
+ */
+void CBulkOnlyTransport::SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus)
+    {
+    TRACE_FUNC
+    TRACE_INFO((_L("DataResidue = %d, Status = %d \n"), aDataResidue, aStatus))
+
+    if (IsActive())
+        {
+        TRACE_INFO((_L("Still active")))
+        __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+        return;
+        }
+    TBuf8<KCswLength> csw(KCswLength);
+
+    TInt i = KCswSingnatureOffset;
+    csw[i] = 0x55; // CSW Singature from USB Bulk-Only Transport spec
+    csw[i + 1] = 0x53;
+    csw[i + 2] = 0x42;
+    csw[i + 3] = 0x53;
+
+    i = KCswTagOffset;
+
+    csw[i] = static_cast<TUint8> ((aTag & 0x000000FF));
+    csw[i + 1] = static_cast<TUint8> ((aTag & 0x0000FF00) >> 8);
+    csw[i + 2] = static_cast<TUint8> ((aTag & 0x00FF0000) >> 16);
+    csw[i + 3] = static_cast<TUint8> ((aTag & 0xFF000000) >> 24);
+
+    i = KCswDataResidueOffset;
+    csw[i] = static_cast<TUint8> ((aDataResidue & 0x000000FF));
+    csw[i + 1] = static_cast<TUint8> ((aDataResidue & 0x0000FF00) >> 8);
+    csw[i + 2] = static_cast<TUint8> ((aDataResidue & 0x00FF0000) >> 16);
+    csw[i + 3] = static_cast<TUint8> ((aDataResidue & 0xFF000000) >> 24);
+
+    csw[KCswStatusOffset] = static_cast<TUint8> (aStatus);
+
+    iLdd.Write(iStatus, InEndpoint, csw, KCswLength);
+
+    iCurrentState = ESendingCSW;
+
+    SetActive();
+    }
+
+/**
+ Associates the transport with the protocol.  Called during initialization of the controller.
+
+ @param aProtocol reference to the protocol
+ */
+void CBulkOnlyTransport::RegisterProtocol(MProtocolBase& aProtocol)
+    {
+    TRACE_FUNC
+    iProtocol = &aProtocol;
+    }
+
+/**
+ Used by CControlInterface
+
+ @return reference to the controller which instantiate the CBulkOnlyTransport
+ */
+CMscFileController& CBulkOnlyTransport::Controller()
+    {
+    return iController;
+    }
+
+/**
+ @return the number of logical units supported by the device. 
+ Logical Unit Numbers on the device shall be numbered contiguously starting from LUN
+ 0 to a maximum LUN of 15 (Fh).
+ */
+TInt CBulkOnlyTransport::MaxLun()
+    {
+    return iMaxLun;
+    }
+
+/**
+ Used by CControlInterface
+ @return reference to USB logical driver
+ */
+RDevUsbcClient& CBulkOnlyTransport::Ldd()
+    {
+    return iLdd;
+    }
+
+
+void CBulkOnlyTransport::StallEndpointAndWaitForClear(TEndpointNumber aEndpoint)
+    {
+    TRACE_FUNC
+    __ASSERT_DEBUG(aEndpoint != EEndpoint0, User::Panic(KUsbMsSvrPncCat, EMsWrongEndpoint));
+
+    // Now stall this endpoint
+    TRACE_INFO((_L("Stalling endpoint %d"), aEndpoint))
+    TInt r = iLdd.HaltEndpoint(aEndpoint);
+    if (r != KErrNone)
+        {
+        TRACE_ERROR((_L("Error: stalling ep %d failed: %d"), aEndpoint, r))
+        }
+    TEndpointState ep_state;
+    TInt i = 0;
+    do
+        {
+        // Wait for 10ms before checking the ep status
+        User::After(10000);
+        iLdd.EndpointStatus(aEndpoint, ep_state);
+        if (++i >= 1000)
+            {
+            // 10 secs should be enough
+            TRACE_ERROR((_L("Error: Checked for ep %d de-stall %d seconds - giving up now..."),
+                            aEndpoint, i / 100))
+            // We can only hope for a Reset Recovery
+            return;
+            }
+        }while ((ep_state == EEndpointStateStalled) && iStarted);
+    TRACE_INFO((_L("Checked for ep %d de-stall: %d time(s)"), aEndpoint, i))
+    }
+
+/**
+ * Read out rest data from OutEndpoint and discard them
+ */
+void CBulkOnlyTransport::ReadAndDiscardData(TInt aBytes)
+    {
+    TRACE_FUNC
+    const TUint bufsize = static_cast<TUint>(iReadBuf.Length());
+    __ASSERT_ALWAYS(bufsize> 0, User::Panic(_L("Buffer size is zero"), bufsize));
+    TRequestStatus status;
+    while (aBytes> 0)
+        {
+        TRACE_INFO((_L("Bytes still to be read: %d\n"), aBytes))
+        iLdd.ReadOneOrMore(status, OutEndpoint, iReadBuf, bufsize);
+        User::WaitForRequest(status);
+        TInt err = status.Int();
+        if (err != KErrNone)
+            {
+            // Bad.
+            break;
+            }
+        aBytes -= iReadBuf.Length();
+        }
+    iReadBuf.SetLength(bufsize);
+    }
+
+/**
+ Called by the protocol to determine how many bytes of data are available in the read buffer. 
+
+ @return The number of bytes available in the read buffer
+ */
+TInt CBulkOnlyTransport::BytesAvailable()
+    {
+    TInt bytes = 0;
+    TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
+    if (err != KErrNone)
+        bytes = 0;
+    return bytes;
+    }
+
+//
+// --- class CActiveDeviceStateNotifier ---------------------------------------------------------
+//
+CActiveDeviceStateNotifier::CActiveDeviceStateNotifier(CBulkOnlyTransport& aParent)
+/**
+ *
+ */
+	: CActive(EPriorityStandard),
+	  iParent(aParent),
+	  iDeviceState(EUsbcNoState),
+            iOldDeviceState(EUsbcNoState)
+    {
+
+    }
+
+
+CActiveDeviceStateNotifier* CActiveDeviceStateNotifier::NewL(CBulkOnlyTransport& aParent)
+/**
+ *
+ */
+    {
+	CActiveDeviceStateNotifier* self = new (ELeave) CActiveDeviceStateNotifier(aParent);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CActiveScheduler::Add(self);
+    CleanupStack::Pop(); // self
+    return (self);
+    }
+
+void CActiveDeviceStateNotifier::ConstructL()
+/**
+ *
+ */
+    {
+    TRACE_FUNC
+	}
+
+CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()
+/**
+ *
+ */
+    {
+    TRACE_FUNC
+    Cancel();												// base class
+    }
+
+void CActiveDeviceStateNotifier::DoCancel()
+/**
+ *
+ */
+    {
+    TRACE_FUNC
+    iParent.Ldd().AlternateDeviceStatusNotifyCancel();
+    }
+
+void CActiveDeviceStateNotifier::RunL()
+/**
+ *
+ */
+    {
+    TRACE_FUNC
+    // This displays the device state.
+    // In a real world program, the user could take here appropriate action (cancel a
+    // transfer request or whatever).
+    if (!(iDeviceState & KUsbAlternateSetting))
+        {
+
+        switch (iDeviceState)
+            {
+            case EUsbcDeviceStateUndefined:
+            TRACE_INFO((_L("Device State notifier: Undefined\n")))
+            iParent.HwStop();
+            break;
+            case EUsbcDeviceStateAttached:
+            TRACE_INFO((_L("Device State notifier: Attached\n")))
+            iParent.HwStop();
+            break;
+            case EUsbcDeviceStatePowered:
+            TRACE_INFO((_L("Device State notifier: Powered\n")))
+            iParent.HwStop();
+            break;
+            case EUsbcDeviceStateDefault:
+            TRACE_INFO((_L("Device State notifier: Default\n")))
+            iParent.HwStop();
+            break;
+            case EUsbcDeviceStateAddress:
+            TRACE_INFO((_L("Device State notifier: Address\n")))
+            iParent.HwStop();
+            break;
+            case EUsbcDeviceStateConfigured:
+            TRACE_INFO((_L("Device State notifier: Configured\n")))
+            if (iOldDeviceState == EUsbcDeviceStateSuspended)
+                {
+                iParent.HwResume();
+                }
+            else
+                {
+                iParent.HwStart();
+                }
+            break;
+            case EUsbcDeviceStateSuspended:
+            TRACE_INFO((_L("Device State notifier: Suspended\n")))
+            if (iOldDeviceState == EUsbcDeviceStateConfigured)
+                {
+                iParent.HwSuspend();
+                }
+            break;
+            default:
+            TRACE_INFO((_L("Device State notifier: ***BAD***\n")))
+            iParent.HwStop();
+            break;
+            }
+        iOldDeviceState = iDeviceState;
+        }
+    else if (iDeviceState & KUsbAlternateSetting)
+        {
+        TRACE_INFO((_L("Device State notifier: Alternate interface setting has changed: now %d\n"),
+                        iDeviceState & ~KUsbAlternateSetting))
+        }
+    Activate();
+    }
+
+void CActiveDeviceStateNotifier::Activate()
+/**
+ *
+ */
+    {
+    TRACE_FUNC
+    if (IsActive())
+        {
+        TRACE_INFO((_L("Still active")))
+        return;
+        }
+    iParent.Ldd().AlternateDeviceStatusNotify(iStatus, iDeviceState);
+    SetActive();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/filesystemimage.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,94 @@
+// 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: CFileSystemImage implementation
+// 
+// 
+
+#include "filesystemimage.h"
+#include "debug.h"
+
+const TInt KImageFileMode = EFileShareReadersOnly | EFileRead;
+
+CFileSystemImage::CFileSystemImage() :
+    iIsOpened( EFalse )
+	{
+	// No implementation required
+	}
+
+CFileSystemImage::~CFileSystemImage()
+	{
+	// iFile will be closed with the session if it's still open
+	iFs.Close();
+	delete iFileName;
+	}
+
+CFileSystemImage* CFileSystemImage::NewL( const TDesC& aFileName )
+	{
+	CFileSystemImage* self = new (ELeave) CFileSystemImage();
+	CleanupStack::PushL( self );
+	self->ConstructL( aFileName );
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+void CFileSystemImage::ConstructL( const TDesC& aFileName )
+	{
+	TRACE_FUNC
+	User::LeaveIfError( iFs.Connect() );
+	iFileName = aFileName.AllocL();
+	TRACE_INFO(( _L( "Image file is '%S'" ), iFileName ))
+	}
+
+TInt CFileSystemImage::Open()
+	{
+	TRACE_FUNC
+	if ( iIsOpened )
+	    {
+	    TRACE_INFO(( _L( "Image already opened" ) ))
+	    return KErrNone;
+	    }
+	TInt err = iFile.Open( iFs, *iFileName, KImageFileMode );
+	if ( err == KErrNone )
+	    {
+	    iIsOpened = ETrue;
+	    }
+	TRACE_INFO(( _L( "Image opened with error %d" ), err ))
+	return err;
+	}
+
+TInt CFileSystemImage::Close()
+	{
+	if ( iIsOpened )
+	    {
+	    iFile.Close();
+	    iIsOpened = EFalse;
+	    }
+	return KErrNone;
+	}
+
+TInt CFileSystemImage::Read( const TInt64& aPos, TInt aLength, TDes8& aBuf )
+	{
+	return iFile.Read( aPos, aBuf, aLength );
+	}
+
+TInt CFileSystemImage::Write( const TInt64& /*aPos*/, TDesC8& /*aBuf*/ )
+	{
+	return KErrAccessDenied;
+	}
+
+TInt64 CFileSystemImage::Size()
+	{
+	TInt size;
+	iFile.Size( size );
+	return size;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfilecontroller.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,158 @@
+// 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: CMscFileController implementation.
+// 
+// 
+
+#include "mscfilecontroller.h"
+#include "scsiprot.h"
+#include "bulkonlytransport.h"
+#include "debug.h"
+
+CMscFileController* CMscFileController::NewL()
+    {
+    TRACE_FUNC
+    CMscFileController* self = new (ELeave) CMscFileController;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+/**
+Destructor
+*/
+CMscFileController::~CMscFileController()
+	{
+	delete iProtocol;
+	delete iTransport;
+	delete iFsImage;
+	}
+
+CMscFileController::CMscFileController()
+    {
+    }
+/**
+Creates the drive manager, transport, protocol and server
+
+@param aMaxDrives Maximum number of Mass Storage drives supported.
+*/
+void CMscFileController::ConstructL()
+	{
+	TRACE_FUNC_ENTRY
+	iMaxDrives = 1; 
+    TRACE_INFO(( _L( "Creating transport" ) ))
+    iTransport = CBulkOnlyTransport::NewL(iMaxDrives, *this);
+	TRACE_FUNC_EXIT
+	}
+
+void CMscFileController::SetupLogicalUnitL( const TDesC& aFileName, 
+                                            const TInt /*aProtocol*/, 
+                                            const TInt aLun )
+    {
+    TRACE_FUNC_ENTRY
+    if ( aLun != 0 )
+        {
+        // More than one logical unit is not supported in this version
+        LEAVE( KErrArgument );
+        }
+    if(iFsImage)
+        {
+        delete iFsImage;
+        iFsImage = NULL;
+        }
+    iFsImage = CFileSystemImage::NewL( aFileName );
+
+    TRACE_INFO(( _L( "Creating protocol" ) ))
+    //create protocol according to aProtocol
+    if(iProtocol)
+        {
+        delete iProtocol;
+        iProtocol = NULL;
+        }
+    iProtocol = CScsiProtocol::NewL( *this );
+    iTransport->RegisterProtocol( *iProtocol );
+    iProtocol->RegisterTransport( iTransport );
+    TRACE_FUNC_EXIT
+    }
+
+/**
+Starts the transport and initializes the protocol.
+
+@param aConfig Reference to Mass Storage configuration data
+*/
+TInt CMscFileController::Start( TMassStorageConfig& aConfig )
+	{
+	TRACE_FUNC_ENTRY
+	//Save this value for use in the Reset method.
+	iConfig = aConfig;
+	TInt err = KErrNotReady;
+	if ( iProtocol && iTransport )
+		{
+		TRACE_INFO(( _L( "Starting" ) ))
+		((CScsiProtocol*)iProtocol)->SetScsiParameters(aConfig);
+		err = iTransport->Start();
+		}
+
+	TRACE_FUNC_EXIT
+	return err;
+	}
+
+/**
+Stops the transport.
+*/
+TInt CMscFileController::Stop()
+	{
+	TRACE_FUNC_ENTRY
+	TInt err = KErrNotReady;
+	if ( iTransport )
+		{
+		TRACE_INFO(( _L( "Stopping" ) ))
+		err = iTransport->Stop();
+		}
+	TRACE_FUNC_EXIT
+	return err;
+	}
+
+/**
+Delete the transport and protocol and start new ones.
+*/
+void CMscFileController::Reset()
+	{
+	TRACE_FUNC
+	delete iProtocol;
+	iProtocol = NULL;
+
+	//Create transport and protocol and initialize them
+	TRACE_INFO(_L("Creating  protocol"));
+
+	TRAPD(err,iProtocol = CScsiProtocol::NewL(*this));
+	err = err;
+	__ASSERT_DEBUG(err==KErrNone, User::Invariant());
+	iTransport->RegisterProtocol(*iProtocol);
+	iProtocol->RegisterTransport(iTransport);
+	}
+
+CFileSystemImage* CMscFileController::FsImage( TInt aLun )
+    {
+    // Only 1 LUN supported in this version
+    if ( aLun == 0 )
+        {
+        return iFsImage;
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfileserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,190 @@
+// 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: Implements a Symbian OS server that exposes the RUsbMassStorage API
+// 
+// 
+
+#include <e32svr.h>
+#include "usbmscfileshared.h"
+#include "mscfileserver.h"
+#include "mscfilesession.h"
+#include "mscfileserversecuritypolicy.h"
+#include "mscfilecontroller.h"
+#include "debug.h"
+
+/**
+ Constructs a USB mass storage Server
+ 
+ @return  a pointer to CMscFileServer object
+ */
+CMscFileServer* CMscFileServer::NewLC()
+	{
+	CMscFileServer* r = new (ELeave) CMscFileServer();
+	CleanupStack::PushL(r);
+	r->ConstructL();
+	return r;
+	}
+
+/**
+ Destructor
+ */
+CMscFileServer::~CMscFileServer()
+	{
+	TRACE_FUNC
+
+    delete iController;
+	}
+
+/**
+ Constructor
+
+ @param aController a USB mass storage controller reference
+ */
+CMscFileServer::CMscFileServer()
+     : CPolicyServer(EPriorityHigh, KMscFileServerPolicy)
+	{
+	}
+
+void CMscFileServer::ConstructL()
+    {
+    TRACE_FUNC
+
+    StartL( KMscFileServerName );
+
+    iController = CMscFileController::NewL();
+    }
+/**
+ Create a new session on this server
+ 
+ @param	&aVersion	Version of client
+ @return	A pointer to a session object to be used for the client
+ */
+CSession2* CMscFileServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
+	{
+	TRACE_FUNC
+	TVersion v( KUsbMsSrvMajorVersionNumber,
+	            KUsbMsSrvMinorVersionNumber,
+	            KUsbMsSrvBuildVersionNumber );
+
+	if ( !User::QueryVersionSupported( v, aVersion ) )
+	    {
+        User::Leave( KErrNotSupported );
+	    }
+
+	CMscFileServer* ncThis = const_cast<CMscFileServer*>(this);
+	CMscFileSession* sess = CMscFileSession::NewL(*ncThis);
+	return sess;
+	}
+
+
+/**
+ Inform the client there has been an error.
+ 
+ @param	aError	The error that has occurred
+ */
+void CMscFileServer::Error(TInt aError)
+	{
+	TRACE_STATE(( _L("!! CMscFileServer::Error( %d )"), aError ))
+
+	Message().Complete(aError);
+	ReStart();
+	}
+
+/**
+ Increment the open session count (iSessionCount) by one.
+ 
+ @post	the number of open sessions is incremented by one
+ */
+void CMscFileServer::IncrementSessionCount()
+	{
+	TRACE_STATE(( _L(">< CMscFileServer::IncrementSessionCount( %d )"), iSessionCount ))
+	__ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
+	
+	++iSessionCount;
+	}
+
+/**
+ Decrement the open session count (iSessionCount) by one.
+ 
+ @post		the number of open sessions is decremented by one
+ */
+void CMscFileServer::DecrementSessionCount()
+	{
+	TRACE_STATE(( _L(">< CMscFileServer::DecrementSessionCount( %d )"), iSessionCount ))
+	__ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
+
+	--iSessionCount;
+	}
+
+void CMscFileServer::ThreadFunctionL()
+    {
+    TRACE_FUNC_ENTRY
+
+    // Naming the server thread after the server helps to debug panics
+    User::LeaveIfError( User::RenameThread( KMscFileServerName ) );
+    
+    // Construct active scheduler
+    CActiveScheduler* activeScheduler = new ( ELeave ) CActiveScheduler;
+    CleanupStack::PushL( activeScheduler ) ;
+
+    // Install active scheduler
+    // We don't need to check whether an active scheduler is already installed
+    // as this is a new thread, so there won't be one
+    CActiveScheduler::Install( activeScheduler );
+
+    // Construct our server
+    CMscFileServer::NewLC(); // Anonymous
+
+    RProcess::Rendezvous( KErrNone );
+
+    // Start handling requests
+    CActiveScheduler::Start();
+
+    //===== thread stopped =====
+    TRACE_INFO(( _L( "   MscFileServer thread stopped" ) ))
+    CleanupStack::PopAndDestroy( 2, activeScheduler ); // Anonymous CMscFileServer
+    
+    TRACE_FUNC_EXIT
+    }
+
+
+TInt CMscFileServer::ThreadFunction( TAny* /*aNone*/ )
+    {
+    TRACE_FUNC_ENTRY
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+    if ( !cleanupStack )
+        {
+        RThread::Rendezvous( KErrNoMemory );
+        }
+
+    TRAPD( err, ThreadFunctionL() )
+    if ( err != KErrNone )
+        {
+        TRACE_ERROR(( _L( "*** Error! Thread leaves w/ %d ***" ), err ))
+        RThread::Rendezvous( KErrNoMemory );        
+        }
+
+    delete cleanupStack;
+    cleanupStack = NULL;
+
+    TRACE_FUNC_EXIT
+    return KErrNone;
+    }
+
+
+TInt E32Main()
+    {
+    return CMscFileServer::ThreadFunction( NULL );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/mscfilesession.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,188 @@
+// 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: Implements a Session of a Symbian OS server for the RUsbMassStorage API
+// 
+// 
+
+#include <e32property.h>
+#include <coreapplicationuisdomainpskeys.h>
+#include "mscfilesession.h"
+#include "mscfilecontroller.h"
+#include "mscfileserver.h"
+#include "usbmscfileshared.h"
+#include "debug.h"
+
+/**
+ Construct a Symbian OS session object.
+ 
+ @param	aServer		Service the session will be a member of
+ @param	aMessage	The message from the client.
+ @return	A new CMscFileSession object
+ */
+CMscFileSession* CMscFileSession::NewL(CMscFileServer& aServer)
+	{
+	CMscFileSession* r = new (ELeave) CMscFileSession(aServer);
+	CleanupStack::PushL(r);
+	r->ConstructL();
+	CleanupStack::Pop();
+	return r;
+	}
+
+/**
+ Constructor.
+ 
+ @param	aServer	Service the session will be a member of
+ */
+CMscFileSession::CMscFileSession(CMscFileServer& aServer)
+	: iMscFileServer( aServer )
+	{
+    TRACE_FUNC
+	}
+
+
+/**
+ 2nd Phase Construction.
+ */
+void CMscFileSession::ConstructL()
+	{
+	TRACE_FUNC
+	iMscFileServer.IncrementSessionCount();
+    if ( iMscFileServer.SessionCount() > 1 )
+        {
+        TRACE_ERROR(( _L( "SessionCount: %d" ), iMscFileServer.SessionCount() ))
+        // Only one session is allowed
+        User::Leave( KErrInUse );
+        }        
+ 	}
+
+
+/**
+ Destructor.
+ */
+CMscFileSession::~CMscFileSession()
+	{
+	iMscFileServer.DecrementSessionCount();
+	}
+
+/**
+ Called when a message is received from the client.
+ 
+ @param	aMessage	Message received from the client
+ */
+void CMscFileSession::ServiceL( const RMessage2& aMessage )
+	{
+	TRAPD( err, DispatchMessageL( aMessage ) );
+	
+    aMessage.Complete( err );
+	}
+
+void CMscFileSession::DispatchMessageL( const RMessage2& aMessage )
+    {
+    switch (aMessage.Function())
+        {
+        case EMscFileSetupLu:
+            SetupLogicalUnitL( aMessage );
+            break;
+            
+        case EMscFileStart:
+            StartL( aMessage );
+            break;
+            
+        case EMscFileStop:
+            LEAVE_IF_ERROR( Stop() );
+            break;
+            
+        case EMscFileShutdown:
+            LEAVE_IF_ERROR( Shutdown() );
+            break;
+
+        default:
+            aMessage.Panic( KUsbMsCliPncCat, EUsbMsPanicIllegalIPC );
+            break;
+        }
+
+    }
+
+void CMscFileSession::SetupLogicalUnitL( const RMessage2& aMessage )
+    {
+    TRACE_FUNC_ENTRY
+    TInt protocol;
+    TInt lun;
+    RBuf fullImageFileName;
+    TInt len = aMessage.GetDesLength( 0 );
+    fullImageFileName.CreateL( len );
+    fullImageFileName.CleanupClosePushL();
+    aMessage.ReadL( 0, fullImageFileName );
+    protocol = aMessage.Int1();
+    lun = aMessage.Int2();
+    
+    iMscFileServer.Controller().SetupLogicalUnitL( fullImageFileName, protocol, lun );
+    CleanupStack::PopAndDestroy( &fullImageFileName );
+    TRACE_FUNC_EXIT
+    }
+/**
+ Client request to start the device.
+ 
+ @return	Any error that occurred or KErrNone
+ */
+void CMscFileSession::StartL( const RMessage2& aMessage )
+	{
+	TRACE_FUNC
+
+    User::LeaveIfError(RProperty::Set(KPSUidCoreApplicationUIs, 
+        KCoreAppUIsUSBFileTransfer, 
+        ECoreAppUIsUSBFileTransferActive));
+	
+	TMassStorageConfig msConfig;
+	GetMsConfigL( aMessage, msConfig );
+	LEAVE_IF_ERROR( iMscFileServer.Controller().Start( msConfig ) );
+	}
+
+/**
+ Client request to stop the device.
+ 
+ @return	Any error that occurred or KErrNone
+ */
+TInt CMscFileSession::Stop()
+    {
+    TRACE_FUNC
+
+    RProperty::Set(KPSUidCoreApplicationUIs, 
+        KCoreAppUIsUSBFileTransfer, 
+        ECoreAppUIsUSBFileTransferNotActive);
+
+	return iMscFileServer.Controller().Stop();
+	}
+
+/**
+ Client request to shut down the server
+ 
+ @return KErrNone
+ */
+TInt CMscFileSession::Shutdown()
+    {
+    TRACE_FUNC
+    CActiveScheduler::Stop();
+	return KErrNone;
+	}
+
+ /**
+  Get mass storage configuration data from the received message
+  */
+ void CMscFileSession::GetMsConfigL( const RMessage2& aMessage, 
+                                     TMassStorageConfig& aMsStorage )
+ 	{
+ 	aMessage.ReadL( 0, aMsStorage.iVendorId );
+ 	aMessage.ReadL( 1, aMsStorage.iProductId );
+ 	aMessage.ReadL( 2, aMsStorage.iProductRev );
+ 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classimplementation/mscfileserver/src/scsiprot.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1084 @@
+// 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: SCSI protocol
+// 
+// 
+
+#include "scsiprot.h"
+#include "debug.h"
+#include "mscfileserver.h"
+
+// Helper macros
+#define LBA(x) static_cast<TUint32>((x[3] << 24) | (x[4] << 16) | (x[5] << 8) | x[6])
+#define LEN(x) static_cast<TUint16>((x[8] << 8) | x[9])
+
+
+LOCAL_D const TUint KDefaultBlockSize = 0x800;  //default block size for MM
+
+LOCAL_D const TUint KUndefinedLun = 0xFFFF;
+
+LOCAL_D const TUint8 KAllPages = 0x3F;
+
+LOCAL_D const TUint8 KChangeableValues = 0x1;
+LOCAL_D const TUint8 KDefaultValues = 0x2;
+
+/**
+Default constructor for TSenseInfo
+*/
+TSenseInfo::TSenseInfo()
+	: iSenseCode(ENoSense),
+	  iAdditional(EAscNull),
+	  iQualifier(EAscqNull)
+	{}
+
+
+/**
+Set sense with no additional info.
+
+@param aSenseCode sense key
+*/
+void TSenseInfo::SetSense(TSenseCode aSenseCode)
+	{
+	iSenseCode	= static_cast<TUint8>(aSenseCode);
+	iAdditional = EAscNull;
+	iQualifier = EAscqNull;
+	}
+
+
+/**
+Set sense with additional info.
+
+@param aSenseCode sense key
+@param aAdditional additional sense code (ASC) 
+*/
+void TSenseInfo::SetSense(TSenseCode aSenseCode, TAdditionalCode aAdditional)
+
+	{
+	iSenseCode = static_cast<TUint8>(aSenseCode);
+    iAdditional = static_cast<TUint8>(aAdditional);
+	iQualifier = EAscqNull;
+	}
+
+
+/**
+Set sense with additional info and qualifier.
+
+@param aSenseCode sense key 
+@param aAdditional additional sense code (ASC) 
+@param aQualifier additional sense code qualifier (ASCQ)
+*/
+void TSenseInfo::SetSense(TSenseCode aSenseCode,
+						  TAdditionalCode aAdditional,
+						  TAdditionalSenseCodeQualifier aQualifier)
+	{
+	iSenseCode = static_cast<TUint8>(aSenseCode);
+    iAdditional = static_cast<TUint8>(aAdditional);
+	iQualifier = static_cast<TUint8>(aQualifier);
+	}
+
+
+//-----------------------------------------------
+
+/**
+Creates the CScsiProtocol object.  Called during controller initialisation.
+
+@param aFsImage reference to the file system image
+*/
+CScsiProtocol* CScsiProtocol::NewL(CMscFileController& aController)
+	{
+	CScsiProtocol* self = new (ELeave) CScsiProtocol(aController);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+c'tor
+
+@param aFsImage reference to the file system image
+*/
+CScsiProtocol::CScsiProtocol(CMscFileController& aController):
+	iController(aController),
+	iLastCommand(EUndefinedCommand),
+	iLastLun(KUndefinedLun),
+	iMediaWriteSize(KDefaultMediaWriteSize)
+	{
+	}
+
+
+CScsiProtocol::~CScsiProtocol()
+	{
+	}
+
+
+void CScsiProtocol::ConstructL()
+	{
+	TRACE_FUNC
+	}
+
+
+/**
+Associates the transport with the protocol. Called during initialisation of the controller.
+
+@param aTransport pointer to the transport object
+*/
+void CScsiProtocol::RegisterTransport(MTransportBase* aTransport)
+	{
+	TRACE_FUNC
+	iTransport = aTransport;
+	}
+
+
+/**
+Called by the Transport when it detects that the USB device is either running
+at High Speed or is at least capable of HS operation. The Protocol can use this
+information (for instance) to select the optimal write block size to use.
+
+This function is preferably called before actual MS data transfer operation
+starts, and usually only once.
+
+*/
+void CScsiProtocol::ReportHighSpeedDevice()
+	{
+	TRACE_FUNC
+	iMediaWriteSize = KHsMediaWriteSize;
+	TRACE_INFO(( _L( "HS Device reported: SCSI will use %d bytes disk write size"), 
+	        iMediaWriteSize ))
+	}
+
+
+TInt CScsiProtocol::SetScsiParameters(TMassStorageConfig aConfig)
+	{
+	TRACE_FUNC
+	iConfig = aConfig;
+	return KErrNone;
+	}
+
+
+/**
+Called by the transport layer when a packet is available for decoding.
+If an error occurs, the sense code is updated and EFalse is returned.
+
+@param aData
+
+@return  ETrue if command was decoded and executed successfully
+*/
+TBool CScsiProtocol::DecodePacket(TPtrC8& aData, TUint aLun)
+	{
+	TRACE_FUNC_ENTRY
+
+	TUint8 command = aData[1];
+
+	if (command != ERequestSense)
+		{
+		iSenseInfo.SetSense(TSenseInfo::ENoSense);
+		}
+
+	TRACE_INFO(( _L( "command = 0x%x lun=%d"), command, aLun ))
+	switch (command)
+		{
+        case ETestUnitReady:
+            HandleUnitReady(aLun);
+            break;
+
+        case ERequestSense:
+            HandleRequestSense(aData);
+            break;
+            
+        case EInquiry:
+            HandleInquiry(aData, aLun);
+            break;
+                
+        case EModeSense:
+            HandleModeSense(aData, aLun);
+            break;
+            
+        case EModeSense10:
+            HandleModeSense10(aData, aLun);
+            break;
+        
+        case EStartStopUnit:
+            HandleStartStopUnit( aData,aLun);
+            break;
+    
+        case EPreventMediaRemoval:
+            HandlePreventMediaRemoval(aData, aLun);
+            break;
+    
+        case EReadCapacity:
+            HandleReadCapacity(aData, aLun);
+            break;
+            
+        case ERead10:
+            HandleRead10(aData, aLun);
+            break;
+            
+        case ERead12:
+            HandleRead12(aData, aLun);
+            break;
+        
+        case EReadTOC:
+            HandleReadTOC(aData, aLun);
+            break;
+        
+        case EGetConfiguration:
+            HandleGetConfiguration(aData, aLun);
+            break;
+    
+		default:
+			iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidCmdCode);
+		}
+	TRACE_INFO(( _L( "result = %d" ), iSenseInfo.SenseOk() ))
+	TRACE_FUNC_EXIT
+	return ( iSenseInfo.SenseOk() );
+	}
+
+
+/**
+Checks if drive ready
+
+@param aLun Logic unit number 
+@return pointer to drive correspondent to LUN if drive mounted and ready, NULL otherwise
+*/
+CFileSystemImage* CScsiProtocol::GetCheckFs(TUint aLun)
+	{
+	TRACE_FUNC
+	TInt err = KErrNone;
+	CFileSystemImage* image = iController.FsImage( aLun );
+	
+	if ( image == NULL )
+		{
+		TRACE_ERROR(( _L( "Illegal LUN %d" ), aLun ))
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
+		return NULL;
+		}
+	
+	// Image exists, ensure it is opened for access
+    err = image->Open();
+    if ( err == KErrNone )
+        {
+        // Image is now open, if it wasn't already
+        TRACE_INFO(( _L( "Image opened successfully" ) ))
+        return image;
+        }
+    else
+        {
+        // Either file doesn't exist or was removed
+        TRACE_ERROR(( _L( "Error %d opening image" ), err ))
+        iSenseInfo.SetSense( TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent );
+        }
+    return NULL;
+	}
+
+
+/**
+Command Parser for the UNIT READY command (0x00)
+
+@param aLun Logic unit number 
+@return ETrue if successful, 
+*/
+TBool CScsiProtocol::HandleUnitReady(TUint aLun)
+	{
+	TRACE_FUNC
+	return ( GetCheckFs(aLun) != NULL );
+	}
+
+
+/**
+Command Parser for the REQUEST SENSE command (0x03)
+
+@return ETrue if successful, 
+*/
+TBool CScsiProtocol::HandleRequestSense(TPtrC8& aData)
+	{
+	TRACE_FUNC
+	TUint length = aData[5];
+	TRACE_INFO(( _L( "length = %d"), length ))
+	iCommandBuf.FillZ(KRequestSenseCommandLength);
+
+	TSenseInfo* senseInfo;
+	senseInfo = &iSenseInfo;
+	iCommandBuf[00] = 0x70; //(current errors)
+
+	iCommandBuf[02] = static_cast<TUint8>(senseInfo->iSenseCode & 0x0F);
+	
+	iCommandBuf[12] = senseInfo->iAdditional;
+	iCommandBuf[13] = senseInfo->iQualifier;
+	if (length<18 && length >=8) 
+		{
+		iCommandBuf.SetLength(length);  //length of response code data
+		iCommandBuf[07] = TUint8(length - 8);  //additional sence length
+		}
+	else if (length >= KRequestSenseCommandLength)
+		{
+		iCommandBuf[07] = KRequestSenseCommandLength - 8;	// we have max 18 byte to send
+		}
+
+	TRACE_INFO(( _L( "Response=0x%x Sense=0x%x, Additional=0x%x, Qualifier=0x%x\n"),
+				iCommandBuf[0], iCommandBuf[02], iCommandBuf[12], iCommandBuf[13] ))
+ 
+	TPtrC8 writeBuf = iCommandBuf.Left(length);
+	iTransport->SetupWriteData(writeBuf);
+
+	// clear the sense info
+	iSenseInfo.SetSense(TSenseInfo::ENoSense);
+	
+	return ETrue;
+	}
+
+
+/**
+Command Parser for the INQUIRY command (0x12)
+
+@param aLun Logic unit number 
+@return ETrue if successful, 
+*/
+TBool CScsiProtocol::HandleInquiry(TPtrC8& aData, TUint /*aLun*/ )
+	{
+	TRACE_FUNC
+	
+	TBool cmdDt = aData[2] & 0x2;
+	TBool evpd  = aData[2] & 0x1;
+	TUint8 page = aData[3];
+	if (cmdDt || evpd || page /*|| aLun >= KUsbMsMaxDrives*/)
+		{
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb); 
+		return EFalse;
+		}
+
+	iCommandBuf.FillZ(KInquiryCommandLength);
+
+    iCommandBuf[0] = 0x05; // CD-ROM
+    iCommandBuf[1] = 0x80; // MSB: RMB : Removable
+    iCommandBuf[2] = 0x02; // Version SPC-3
+    iCommandBuf[3] = 0x02; // AERC, TrmTsk, NormACA, Response Data Format
+    iCommandBuf[4] = 0x1F; // Additional Length
+
+	TPtr8 vendorId(&iCommandBuf[8], 8, 8);		// Vendor ID (Vendor Specific/Logged by T10)
+	vendorId.Fill(' ', 8);
+	vendorId.Copy(iConfig.iVendorId);
+
+	TPtr8 productId(&iCommandBuf[16], 16, 16);	// Product ID (Vendor Specific)
+	productId.Fill(' ', 16);
+	productId.Copy(iConfig.iProductId);
+
+	TPtr8 productRev(&iCommandBuf[32], 4, 4);		// Product Revision Level (Vendor Specific)
+	productRev.Fill(' ', 4);
+	productRev.Copy(iConfig.iProductRev);
+
+    TUint length = aData[5];
+	TPtrC8 writeBuf = iCommandBuf.Left(length);
+	iTransport->SetupWriteData(writeBuf);
+
+	iSenseInfo.SetSense(TSenseInfo::ENoSense); 
+	return ETrue;
+	}
+
+
+/**
+ Command Parser for the START STOP UNIT command (0x1B)
+ 
+ @param aData command data (started form position 1)
+ @param aLun Logic unit number 
+ @return ETrue if successful, TFalse otherwise
+ */
+TBool CScsiProtocol::HandleStartStopUnit(TPtrC8& aData, TUint aLun)
+	{
+	TRACE_FUNC
+    CFileSystemImage* image = GetCheckFs(aLun); 
+    if ( image == NULL )
+        {
+        return EFalse;
+        }
+
+	const TUint8 KStartMask = 0x01;
+	const TUint8 KImmedMask = 0x01;
+	const TUint8 KLoejMask = 0x02;
+
+	TBool immed = aData[2] & KImmedMask ? ETrue : EFalse;
+	TBool start = aData[5] & KStartMask ? ETrue : EFalse;
+	TBool loej = aData[5] & KLoejMask ? ETrue : EFalse;
+
+	TRACE_INFO(( _L( "Data %X %X" ), aData[2], aData[5] ))
+	TRACE_INFO(( _L( "IMMED = %d" ), immed ))
+	TRACE_INFO(( _L( "START = %d"), start ))
+	TRACE_INFO(( _L( "LOEJ  = %d" ), loej ))
+
+	TInt err = KErrNone;
+	if (loej)
+		{
+		if (start)	//Start unit
+			{
+			// GetCheckFs has already opened the image file
+			TRACE_INFO(( _L( "Load media" ) ))
+			}
+		else		//Stop unit 
+			{
+			err = image->Close();
+			TRACE_INFO(( _L( "Unload media" ) ))
+			}
+		}
+
+	if (err != KErrNone)  //actually we have error here only if the LUN is incorrect 
+		{
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
+		return EFalse;
+		}
+
+	return ETrue;
+	}
+
+
+/**
+Command Parser for the PREVENT/ALLOW MEDIA REMOVAL command (0x1E)
+
+@param aData command data (started form position 1)
+@param aLun Logic unit number 
+@return ETrue if successful.
+*/
+TBool CScsiProtocol::HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun)
+	{
+	TRACE_FUNC
+    if ( GetCheckFs(aLun) == NULL )
+        {
+        return EFalse;
+        }
+
+	TInt prevent = aData[5] & 0x01;
+
+	// locking is not supported
+	if (prevent)
+		{
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+		}
+	return ETrue;
+	}
+
+/** Cancel active state, Invoked by transnport when it stops */
+TInt CScsiProtocol::Cancel()
+	{
+	TRACE_FUNC
+	return KErrNone;
+	}
+
+/**
+Command Parser for the READ CAPACITY(10) command (0x25)
+
+@param aData command data (started form position 1)
+@param aLun Logic unit number 
+@return ETrue if successful.
+*/
+TBool CScsiProtocol::HandleReadCapacity(TPtrC8& aData, TUint aLun)
+	{
+	TRACE_FUNC
+	CFileSystemImage* image = GetCheckFs(aLun); 
+    if ( image == NULL )
+        {
+        return EFalse;
+        }
+
+	TInt pmi = aData[9] & 0x01;
+	TInt lba = aData[3] | aData[4] | aData[5] | aData[6];
+
+	if (pmi || lba)   //do not support partial medium indicator
+		{
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+		return EFalse;
+		} 
+
+	TInt64 driveBlocks = image->Size() / MAKE_TINT64(0, KDefaultBlockSize) - 1;
+	iCommandBuf.FillZ(KReadCapacityCommandLength);
+	if (I64HIGH(driveBlocks) == 0)
+		{
+		TUint32 numBlocks = I64LOW(driveBlocks);
+
+		TRACE_INFO(( _L( "Block size=%d, NumBlocks=%d" ), 
+		        KDefaultBlockSize, numBlocks ))
+		iCommandBuf[0] = static_cast<TUint8>((numBlocks & 0xFF000000) >> 24);	// Number of blocks
+		iCommandBuf[1] = static_cast<TUint8>((numBlocks & 0x00FF0000) >> 16);
+		iCommandBuf[2] = static_cast<TUint8>((numBlocks & 0x0000FF00) >> 8);
+		iCommandBuf[3] = static_cast<TUint8>((numBlocks & 0x000000FF));
+		}
+	else   
+		{
+		iCommandBuf[0] = iCommandBuf[1] = iCommandBuf[2] = iCommandBuf[3] = 0xFF;  // indicate that size more then )0xFFFFFFFF
+		}
+
+	iCommandBuf[4] = static_cast<TUint8>((KDefaultBlockSize & 0xFF000000) >> 24);	// Block Size
+	iCommandBuf[5] = static_cast<TUint8>((KDefaultBlockSize & 0x00FF0000) >> 16);
+	iCommandBuf[6] = static_cast<TUint8>((KDefaultBlockSize & 0x0000FF00) >> 8);
+	iCommandBuf[7] = static_cast<TUint8>((KDefaultBlockSize & 0x000000FF));
+
+	TPtrC8 writeBuf = iCommandBuf;
+	iTransport->SetupWriteData(writeBuf);
+
+	return ETrue;
+	}
+
+
+/**
+Command Parser for the READ10 command (0x28)
+
+@param aData command data (started form position 1)
+@param aLun Logic unit number
+@return ETrue if successful.
+*/
+TBool CScsiProtocol::HandleRead10(TPtrC8& aData, TUint aLun)
+	{
+	TRACE_FUNC
+    CFileSystemImage* image = GetCheckFs(aLun); 
+    if ( image == NULL )
+        {
+        return EFalse;
+        }
+    
+	TInt rdProtect = aData[2] >> 5;
+	if (rdProtect)
+		{
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+		return EFalse;
+		}
+
+	const TUint32 lba = LBA(aData);
+	const TUint16 len = LEN(aData);
+
+	TRACE_INFO(( _L( "READ(10) : LBA = %d, Length = %d (blocks)" ), lba, len))
+
+	if (!len)
+		{
+		return ETrue; // do nothing - this is not an error
+		}
+
+	const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
+	const TInt bLength = len * KDefaultBlockSize;
+	const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
+
+    if (theEnd > image->Size())  //check if media big enough for this request
+		{
+		TRACE_ERROR(( _L( "err - Request ends out of media" ) ))
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
+		return EFalse;
+		}
+
+	// check if our buffer can hold requested data
+	if (iCommandBuf.MaxLength() < bLength)
+		{
+		TRACE_ERROR(( _L( "err - Buffer too small" ) ))
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+		return EFalse;
+		}
+
+	TInt err = image->Read(bOffset, bLength, iCommandBuf);
+	if (err != KErrNone)
+		{
+		TRACE_ERROR(( _L( "Read failed, err=%d" ), err ))
+		iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+		return EFalse;
+		}
+
+	TPtrC8 writeBuf = iCommandBuf;
+
+	// Set up data write to the host
+	iTransport->SetupWriteData(writeBuf);
+
+	return ETrue;
+	}
+
+
+/**
+Command Parser for the READ12 command (0xA8)
+
+@param aData command data (started form position 1)
+@param aLun Logic unit number
+@return ETrue if successful.
+*/
+TBool CScsiProtocol::HandleRead12(TPtrC8& aData, TUint aLun)
+    {
+    TRACE_FUNC
+    CFileSystemImage* image = GetCheckFs(aLun); 
+    if ( image == NULL )
+        {
+        return EFalse;
+        }
+    TInt rdProtect = aData[2] >> 5;
+    if (rdProtect)
+        {
+        iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+        return EFalse;
+        }
+
+    const TUint32 lba = static_cast<TUint32>((aData[3] << 24) | (aData[4] << 16) | (aData[5] << 8) | aData[6]);
+    const TUint32 len = static_cast<TUint32>((aData[7] << 24) | (aData[8] << 16) | (aData[9] << 8) | aData[10]);
+
+    TRACE_INFO(( _L( "READ(12) : LBA = %d, Length = %d  (blocks)" ), lba, len ))
+
+    if (!len)
+        {
+        return ETrue; // do nothing - this is not an error
+        }
+
+    const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
+    const TUint32 bLength = len * KDefaultBlockSize;
+    const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
+
+    if (theEnd > image->Size())  //check if media big enough for this request
+        {
+        TRACE_ERROR(( _L( "err - Request ends out of media" ) ))
+        iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
+        return EFalse;
+        }
+
+    // check if our buffer can hold requested data
+    if (iCommandBuf.MaxLength() < bLength)
+        {
+        TRACE_ERROR(( _L( "err - Buffer too small" ) ))
+        iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+        return EFalse;
+        }
+
+    TInt err = image->Read(bOffset, bLength, iCommandBuf);
+    if (err != KErrNone)
+        {
+        TRACE_ERROR(( _L( "Read failed, err=%d" ), err ))
+        iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+        return EFalse;
+        }
+
+    TPtrC8 writeBuf = iCommandBuf;
+
+    // Set up data write to the host
+    iTransport->SetupWriteData(writeBuf);
+
+    return ETrue;
+    }
+
+/**
+Called by the transport when the requested data has been read or an error has
+occurred during the read.
+
+@param aError Indicate if an error occurs during reading data by transport.
+@return KErrAbort if command processing is complete but has failed,
+        KErrCompletion if sufficient data is available in the buffer to process
+        the transfer immediately, KErrNotReady if insufficient data is
+        available in the buffer so the transport should wait for it to arrive,
+        KErrNone if command processing is complete and was successful.
+*/
+TInt CScsiProtocol::ReadComplete(TInt aError)
+	{
+	TRACE_FUNC
+	TRACE_INFO(( _L( "Error = 0x%X" ), aError ))
+//	const TInt64 bOffset = iOffset;
+	TUint8 lastCommand = iLastCommand;
+	TUint lastLun = iLastLun;
+
+	iOffset = 0;
+	iLastCommand = EUndefinedCommand;
+	iLastLun = KUndefinedLun;
+
+	TRACE_INFO(( _L( "Last command was: %s" ),
+			 (lastCommand == EUndefinedCommand) ? _S("Undefined") :
+			 ((lastCommand == EWrite10) ? _S("EWrite10") :
+			  ((lastCommand == EVerify10) ? _S("EVerify10") :
+			   _S("Unknown"))) ))
+
+	if (aError != KErrNone ||
+		lastCommand == EUndefinedCommand ||
+		lastLun == KUndefinedLun)
+		{
+		iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
+		return KErrAbort;
+		}
+
+    CFileSystemImage* image = GetCheckFs(lastLun); 
+    if ( image == NULL )
+        {
+        return KErrAbort;
+        }
+    else
+        {
+        iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
+        }
+	return iSenseInfo.SenseOk() ? KErrNone : KErrAbort;
+	}
+
+
+/**
+Command Parser for the MODE SENSE(06) command (0x1A)
+
+@return ETrue if successful.
+*/
+TBool CScsiProtocol::HandleModeSense(TPtrC8& aData, TUint /*aLun*/)
+	{
+	TRACE_FUNC
+
+	TInt pageCode = aData[3] & 0x3F;
+	TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
+
+	// reserve 4 bytes for Length, Media type, Device-specific parameter and Block descriptor length
+	iCommandBuf.FillZ(KModeSenseCommandLength);
+
+	if (pageCode != KAllPages || pageControl == KChangeableValues) 
+		{
+		TRACE_ERROR(( _L( "TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb")))
+		iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
+		return EFalse;
+		}
+	if (pageControl != KDefaultValues)
+		{
+	    iCommandBuf[2] = 1<<7;  // set SWP bit at the Device Specific parameters
+		}
+
+	iCommandBuf[0]=3;  //Sending only Mode parameter header
+
+	TPtrC8 writeBuf = iCommandBuf;
+	iTransport->SetupWriteData(writeBuf);
+
+	return (iSenseInfo.SenseOk());
+	}
+
+
+const TUint16 KMaxModeRespLen = 58;
+/**
+Command Parser for the MODE SENSE(10) command (0x5A)
+
+@return ETrue if successful.
+*/  
+TBool CScsiProtocol::HandleModeSense10(TPtrC8& aData, TUint /*aLun*/)
+    {
+    TRACE_FUNC
+    
+    TInt pageCode   = aData[3] & 0x3F;
+    TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
+    
+    iCommandBuf.FillZ(KMaxModeRespLen);
+    
+    TBool allPages = EFalse;
+    TUint16 len = static_cast<TUint16>((aData[8] << 8) | aData[9]);
+    __ASSERT_DEBUG(len > 1, User::Panic(KUsbMsSvrPncCat, EMsWrongLength));
+
+    iCommandBuf[2] = 0x71; // medium type
+    
+    TInt i = 8;
+    
+    switch (pageCode)
+        {
+        case 0x3F: // All mode pages
+            allPages = ETrue;
+        case 0x1A: // Power condition mode page
+            // byte 0
+            iCommandBuf[i++] = 0x1A; // page code
+            iCommandBuf[i++] = 0x0A; // length
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // IDLE = 0, STANDBY = 0
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; // idle timer
+            // byte 8
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00;
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; // standby timer
+            
+            if (!allPages)
+                {
+                break;
+                }
+        case 0x1D: // Timeout and protect mode page
+            // byte 0
+            iCommandBuf[i++] = 0x1D; // page code
+            iCommandBuf[i++] = 0x08; // length
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // reserver
+            iCommandBuf[i++] = 0x00; // G3, TMOE, DISP, SWPP = 0, 0, 0, 0
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; // group 1 timeout
+            // byte 8
+            iCommandBuf[i++] = 0x00; 
+            iCommandBuf[i++] = 0x00; // group 2 timeout
+            
+            if (!allPages)
+                {
+                break;
+                }
+        case 0x2A: // MM capabilities and mechanical status page
+            // byte 0
+            iCommandBuf[i++] = 0x2A; // page code
+            iCommandBuf[i++] = 0x1A; // length
+            iCommandBuf[i++] = 0x00; // !CD-R
+            iCommandBuf[i++] = 0x00;
+            iCommandBuf[i++] = 0x30; // mode (mode 2, form 1,2)
+            iCommandBuf[i++] = 0x00;
+            iCommandBuf[i++] = 0x29; // tray, eject, lock
+            iCommandBuf[i++] = 0x00;
+            // byte 8
+            iCommandBuf[i++] = 0x00; //
+            iCommandBuf[i++] = 0x00; // obsolete
+            iCommandBuf[i++] = 0x00; //
+            iCommandBuf[i++] = 0x00; // volume levels
+            iCommandBuf[i++] = 0x00; //
+            iCommandBuf[i++] = 0x00; // buffer size
+            iCommandBuf[i++] = 0x00; //
+            iCommandBuf[i++] = 0x00; // obsolete
+            // byte 16
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // unspecified
+            iCommandBuf[i++] = 0x00; // obsolete
+            iCommandBuf[i++] = 0x00; // obsolete
+            iCommandBuf[i++] = 0x00; // obsolete
+            iCommandBuf[i++] = 0x00; // obsolete
+            iCommandBuf[i++] = 0x00; //
+            iCommandBuf[i++] = 0x00; // copy management revision
+            // byte 24
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // reserved
+            iCommandBuf[i++] = 0x00; // reserved
+            
+            break;
+        default:
+            // Unknown page code
+            iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
+            return EFalse;
+        }
+   
+    if (i > len)
+        {
+        // don't send more data than the host will accept
+        i = len;
+        }
+    iCommandBuf.SetLength(i);
+    iCommandBuf[1] = (TUint8)(i-2); // length will not exceed 255, so LSB is enough
+    
+    TPtrC8 writeBuf = iCommandBuf;
+    iTransport->SetupWriteData(writeBuf);
+
+    return (iSenseInfo.SenseOk());
+    }
+
+/**
+Command Parser for the READ TOC/PMA/ATIP command (0x43)
+
+@return ETrue if successful.
+*/  
+TBool CScsiProtocol::HandleReadTOC(TPtrC8& aData, TUint aLun)
+    {
+    TRACE_FUNC
+    if ( GetCheckFs(aLun) == NULL )
+        {
+        return EFalse;
+        }    
+    
+    TUint16 len = static_cast<TUint16>((aData[8] << 8) | aData[9]);
+    
+    if (len == 0)
+        {
+        return ETrue; // allocation length = 0 is not an error
+        }
+    else if (len > 20)
+        {
+        len = 20;
+        }
+    
+    iCommandBuf.FillZ(len);  
+    
+    // TOC header
+    iCommandBuf[0] = 0x00; // length MSB
+    iCommandBuf[1] = len-2; // length LSB
+    iCommandBuf[2] = 0x01; // first track
+    iCommandBuf[3] = 0x01; // last track
+    if (len >= 12)
+        {
+        // Track descriptor, track 1
+        iCommandBuf[5] = 0x14; // ADR | CTRL
+        iCommandBuf[6] = 0x01; // track
+        // Track start address
+        if (aData[2] & 0x02)
+            {
+            // TIME address = 0x00 00 02 00
+            iCommandBuf[10] = 0x02;
+            }
+        }
+    if (len >= 20)
+        {
+        // Track descriptor, lead-out
+        iCommandBuf[13] = 0x14;
+        iCommandBuf[14] = 0xaa;
+        }
+    
+    TPtrC8 writeBuf = iCommandBuf;
+    iTransport->SetupWriteData(writeBuf);
+
+    return (iSenseInfo.SenseOk());
+    }
+
+const TUint16 KFeatureNums[] = { 0x0000, 0x0001, 0x0002, 0x0003,
+                                 0x0010, 0x001E, 0x0100, 0x0105 };
+const TInt KNumFeatures = sizeof(KFeatureNums) / sizeof(TUint16);
+const TInt KMaxConfRespLen = 76;
+
+/**
+Command Parser for the GET CONFIGURATION command (0x46)
+
+@return ETrue if successful.
+*/  
+TBool CScsiProtocol::HandleGetConfiguration(TPtrC8& aData, TUint aLun)
+    {
+    TRACE_FUNC
+    if ( GetCheckFs(aLun) == NULL )
+        {
+        return EFalse;
+        }    
+    TUint blockSize = KDefaultBlockSize;
+
+    TUint8 rt = aData[2] & 0x03;
+    TUint16 feature = static_cast<TUint16>((aData[3] << 8) | aData[4]);
+    TUint16 len =     static_cast<TUint16>((aData[8] << 8) | aData[9]);
+    
+    if (len == 0)
+        {
+        return ETrue; // allocation length = 0 is not an error
+        }
+    
+    iCommandBuf.FillZ(KMaxConfRespLen);  
+    
+    // Feature header
+    iCommandBuf[0] = 0x00;  // length 
+    iCommandBuf[1] = 0x00;  // length 
+    iCommandBuf[2] = 0x00;  // length 
+    iCommandBuf[6] = 0x00;
+    iCommandBuf[7] = 0x08;  // CD-ROM Profile 0x0008
+    
+    TInt i = 8;
+    
+    for (TInt f = 0; f < KNumFeatures; f++)
+        {
+        if ( ( ( rt == 2 ) && ( KFeatureNums[f] == feature ) ) ||
+             ( ( rt != 2 ) && ( KFeatureNums[f] >= feature ) ) )
+            {
+            switch (KFeatureNums[f])
+                {
+                case 0x0000:
+                    // Profile list 
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x00; // feature code = 0x0000
+                    iCommandBuf[i++] = 0x03; // persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x04; // additional length (1 profile desc.)
+                    // Profile descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x08; // profile 0x0008
+                    iCommandBuf[i++] = 0x01; // current
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x0001:
+                    // Core feature descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x01; // feature code = 0x0001
+                    iCommandBuf[i++] = 0x07; // version = 0001b, persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x08; // additional length
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x08; // physical interface = 0x00000008 (USB)
+                    iCommandBuf[i++] = 0x01; // DBE = 1
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x0002:
+                    // Morphing feature descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x02; // feature code = 0x0002
+                    iCommandBuf[i++] = 0x07; // version = 0001b, persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x04; // additional length
+                    iCommandBuf[i++] = 0x02; // OCEvent = 1, ASYNC = 0
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x0003:
+                    // Removable medium feature descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x03; // feature code = 0x0003
+                    iCommandBuf[i++] = 0x03; // persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x04; // additional length
+                    iCommandBuf[i++] = 0x29; // tray, eject, lock
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x0010:
+                    // Random readable feature descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x10; // feature code = 0x0010
+                    iCommandBuf[i++] = 0x03; // persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x08; // additional length
+                    // Block Size
+                    iCommandBuf[i++] = static_cast<TUint8>((blockSize & 0xFF000000) >> 24);
+                    iCommandBuf[i++] = static_cast<TUint8>((blockSize & 0x00FF0000) >> 16);  
+                    iCommandBuf[i++] = static_cast<TUint8>((blockSize & 0x0000FF00) >> 8);   
+                    iCommandBuf[i++] = static_cast<TUint8>((blockSize & 0x000000FF));        
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x01; // blocking = 1
+                    iCommandBuf[i++] = 0x00; // PP = 0
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x001E:
+                    // CD Read feature descriptor
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x1E; // feature code = 0x001E
+                    iCommandBuf[i++] = 0x0B; // version = 2, persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x04; // additional length
+                    iCommandBuf[i++] = 0x00; // DAP = 0, C2 flags = 0, CD-Text = 0
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00; // reserved
+                    break;
+                case 0x0100:
+                    // Power management feature descriptor
+                    iCommandBuf[i++] = 0x01;
+                    iCommandBuf[i++] = 0x00; // feature code = 0x0100
+                    iCommandBuf[i++] = 0x03; // persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x00; // additional length = 0
+                    break;    
+                case 0x0105:
+                    // Timeout feature descriptor
+                    iCommandBuf[i++] = 0x01;
+                    iCommandBuf[i++] = 0x05; // feature code = 0x0105
+                    iCommandBuf[i++] = 0x07; // version = 1, persistent = 1, current = 1
+                    iCommandBuf[i++] = 0x04; // additional length
+                    iCommandBuf[i++] = 0x00; // G3 = 0
+                    iCommandBuf[i++] = 0x00; // reserved
+                    iCommandBuf[i++] = 0x00;
+                    iCommandBuf[i++] = 0x00; // unit lenght = undefined
+                    break;
+                default:
+                    break;
+                }                
+            }
+        }
+    iCommandBuf[3] = (TUint8)(i-4); // length LSB
+    if (i > len)
+        {
+        // don't send more data than the host will accept
+        i = len;
+        }
+    
+    TPtrC8 writeBuf = iCommandBuf.Left(i);
+    iTransport->SetupWriteData(writeBuf);
+
+    return (iSenseInfo.SenseOk());
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,20 @@
+/*
+* 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:
+*
+*/
+
+
+#include "../classcontroller/group/bld.inf"
+#include "../classimplementation/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for project usbengines
+*
+*/
+
+#include "../usbotgwatcher/group/bld.inf"
+#include "../usbwatcher/group/bld.inf"
+#include "../usblocodplugin/group/bld.inf"
+#include "../usbdevcon/group/bld.inf"
+#include "../usbremotepersonality/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for project UsbDeviceControl
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/usbdevcon.iby    CORE_MW_LAYER_IBY_EXPORT_PATH(usbdevcon.iby)
+
+PRJ_MMPFILES
+usbdevcon.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/group/build_component.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,22 @@
+rem
+rem Copyright (c) 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:
+rem
+
+call bldmake clean
+call bldmake bldfiles
+call abld clean
+call abld reallyclean
+call abld build
+call pause
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/group/usbdevcon.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:  Project definition file for project UsbDevCon
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+target			usbdevcon.exe
+CAPABILITY 		LocalServices CommDD
+targettype		exe
+
+uid			0 0x10282F31
+VENDORID VID_DEFAULT
+
+sourcepath		../src
+
+source			cusbdevcon.cpp
+source			cep0reader.cpp cep0writer.cpp
+source			crequestshandler.cpp
+source			cstatemachine.cpp
+source			cusbstatewatcher.cpp
+
+userinclude		../inc
+MW_LAYER_SYSTEMINCLUDE
+
+library			euser.lib usbman.lib usbwatcher.lib ecom.lib
+DEBUGLIBRARY  	flogger.lib            // File logging
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/cep0reader.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,128 @@
+/*
+* 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:  State, while waiting for requests
+*
+*/
+
+
+#ifndef CEP0READER_H
+#define CEP0READER_H
+
+#include "cusbdevcon.h"
+
+class CStateMachine;    // gets notifications on events happened on EP0
+
+/**
+ *  EP0 Reader
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CEP0Reader : public CActive 
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notification when Read request is completed
+     * @param aLdd Link to services for reading EP0
+     * @return Constructed instance
+     */
+    static CEP0Reader* NewL(CStateMachine& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CEP0Reader();
+    
+    /**
+     * Set request to read setup packet
+     *
+     * @since S60 v.5.0
+     */
+    void ReadSetupPacket();
+    
+    /**
+     * Set request to read EP0 data
+     *
+     * @since S60 v.5.0
+     * @param aDataLength Max length of data to read
+     */
+    void Read(TUint aDataLength);
+    
+private:
+    
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notification when Read request is completed
+     * @param aLdd Link to services for reading EP0
+     */
+    CEP0Reader(CStateMachine& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+     * Two-phased construction.
+     *
+     */
+    void ConstructL();
+    
+    // from CActive
+    
+    /**
+     * From CActive.
+     *
+     */
+    void RunL();
+    
+    /**
+     * From CActive.
+     *
+     */ 
+    void DoCancel();
+    
+    /**
+     * From CActive.
+     *
+     */ 
+     TInt RunError( TInt /*aError*/ );
+
+private: // data
+    
+    /**
+     * LDD Logical Device Driver
+     * Not own.  
+     */
+    RDevUsbcClient& iLdd;
+    
+    /**
+     * State machine gets read data
+     * Not own.  
+     */
+    CStateMachine& iObserver;
+    
+    /**
+     * Read buffer
+     */
+    RBuf8 iBuffer;
+        
+    };
+
+#endif // CEP0READER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/cep0writer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* 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:  State, while waiting for requests
+*
+*/
+
+
+#ifndef CEP0WRITER_H
+#define CEP0WRITER_H
+
+#include "cusbdevcon.h"
+
+class CStateMachine;    // gets notifications on events happened on EP0
+
+/**
+ *  EP0 Writer
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CEP0Writer : public CActive 
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notification when Read request is completed
+     * @param aLdd Link to services for reading EP0
+     * @return Constructed instance
+     */
+    static CEP0Writer* NewL(CStateMachine& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CEP0Writer();
+    
+    /**
+     * Set request to write EP0 data
+     *
+     * @since S60 v.5.0
+     * @param aBuffer Data to write
+     * @param aDataLength Max length of data to write
+     */
+    void Write(const RBuf8& aBuffer, TUint aDataLength);
+    
+private:
+    
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notification when Read request is completed
+     * @param aLdd Link to services for writing EP0
+     */
+    CEP0Writer(CStateMachine& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+     * Two-phased construction.
+     *
+     */
+    void ConstructL();
+    
+    // from CActive
+    
+    /**
+     * From CActive.
+     *
+     */
+    void RunL();
+    
+    /**
+     * From CActive.
+     *
+     */ 
+    void DoCancel();
+    
+     /**
+     * From CActive.
+     *
+     */ 
+     TInt RunError( TInt /*aError*/ );
+
+private: // data
+
+    /**
+     * Gets notifications
+     * Not own.  
+     */
+    CStateMachine& iObserver;
+    
+    /**
+     * LDD
+     * Not own.  
+     */
+    RDevUsbcClient& iLdd;
+        
+    /**
+     * Write data
+     * 
+     */
+    RBuf8 iBuffer;
+    };
+
+#endif // CEP0WRITER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/crequestshandler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* 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:  Handles requests
+*
+*/
+
+
+#ifndef CREQUESTSHANDLER_H
+#define CREQUESTSHANDLER_H
+
+#include <e32base.h>
+
+class CUsbCMHandler;
+
+/**
+ *  Requests handler
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CRequestsHandler : public CBase
+    {
+
+public:
+
+     /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @param aLdd Link to LDD services
+     * @param aUsbWatcher Link to USb Watcher services
+     * @param aUsbManager Link to USB Manager services
+     * @return Constructed instance
+     */ 
+    static CRequestsHandler* NewL(RDevUsbcClient& aLdd, RUsbWatcher& aUsbWatcher, RUsb& aUsbManager);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CRequestsHandler();
+    
+    /**
+     * Handler
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket Request to be handled
+     * @param aUsbManager Link to UsbManager services
+     */
+    TInt Handle(const RBuf8& aSetupPacket, RBuf8& aData);
+    
+private:
+    
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     * @param aLdd Link to LDD services
+     * @param aUsbWatcher Link to USB Watcher services
+     * @param aUsbManager Link to USB Manager services
+     */
+    CRequestsHandler(RDevUsbcClient& aLdd, RUsbWatcher& aUsbWatcher, RUsb& aUsbManager);
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */ 
+    void ConstructL();
+
+private: // data
+    
+    /**
+     * Request handlers
+     * Own.  
+     */
+    RPointerArray<CUsbCMHandler> iHandlers;
+    
+    /**
+     * LDD
+     * Not own.  
+     */
+    RDevUsbcClient& iLdd;
+    
+    /**
+     * USB Watcher
+     * Not own.  
+     */
+    RUsbWatcher& iUsbWatcher;
+    
+    /**
+     * Usb manager
+     * Not own
+     */
+    RUsb& iUsbManager;
+        
+    };
+
+#endif // CREQUESTSHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/cstatemachine.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,190 @@
+/*
+* 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:  State machine
+*
+*/
+
+
+#ifndef CSTATEMACHINE_H
+#define CSTATEMACHINE_H
+
+class CRequestsHandler;
+class CEP0Reader;
+class CEP0Writer;
+
+/**
+ *  State machine for the control transfers
+ *  Switches usbdevcon states between Setup-Data-Status
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CStateMachine : public CBase 
+    {
+
+public:
+
+    /**  States */
+    enum TState
+    {
+        ENoneState,     // State is not defined 
+        ESetupStage,    // ready for getting control setup transaction
+        EDataStage,     // reading data from host, in Data stage        
+        EStatusStage    // waiting for Status transaction, after writing data to host
+    };
+
+     /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @param aRequestHandler Handles requests
+     * @param aLdd Link to LDD services
+     * @return Constructed instance
+     */ 
+    static CStateMachine* NewL(CRequestsHandler& aRequestsHandler, RDevUsbcClient& aLdd);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CStateMachine();
+    
+    /**
+     * Call back from CEP0Reader
+     *
+     * @since S60 v.5.0
+     * @param aBuffer Data read from EP0
+     * @param aStatus status of Read request, completed
+     */
+    void ReadEP0(RBuf8& aBuffer, const TRequestStatus& aStatus);
+    
+    /**
+     * Call back from CEP0Writer
+     *
+     * @since S60 v.5.0
+     * @param aStatus status of Write request, completed
+     */
+    void WroteEP0(const TRequestStatus& aStatus);
+    
+    /**
+     * Starts machine
+     *
+     * @since S60 v.5.0
+     */
+    void Start();
+    
+    /**
+     * Stops machine
+     *
+     * @since S60 v.5.0
+     */
+    void Stop();
+    
+    /**
+     * Machine is started
+     *
+     * @since S60 v.5.0
+     * @return ETrue if state machine is started
+     */
+    TBool IsStarted() const;
+    
+private:
+    
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     * @param aRequestHandler Handles requests
+     * @param aLdd Link to LDD services
+     */
+    CStateMachine(CRequestsHandler& aRequestsHandler, RDevUsbcClient& aLdd);
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */
+    void ConstructL();
+    
+    /**
+     * Process setup packet
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket Will be processed
+     */
+    void ProcessSetupPacket(RBuf8& aSetupPacket);
+    
+    /**
+     * Checks wheather data required to be sent from host to device 
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket Contains data direction bit, and length of data
+     * @param aDataLength Length of data to be sent
+     * @return ETrue If data stage is required
+     */
+    TBool IsDataFromHostRequired(const RBuf8& aSetupPacket, TUint& aDatalength) const;
+    
+    /**
+     * Checks wheather data required to be sent from device to host
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket Contains data direction bit, and length of data
+     * @param aDataLength Length of data to be sent
+     * @return ETrue If data stage is required
+     */
+    TBool IsDataFromDeviceRequired(const RBuf8& aSetupPacket, TUint& aDatalength) const;
+    
+private: // data
+    
+    /**
+     * EP0 reader
+     * Own.  
+     */
+    CEP0Reader* iEP0Reader;
+    
+    /**
+     * EP0 writer
+     * Own.  
+     */
+    CEP0Writer* iEP0Writer;
+    
+    /**
+     * Requests handler
+     * Not own.  
+     */
+    CRequestsHandler& iRequestsHandler;
+    
+    /**
+     * LDD
+     * Not own.  
+     */
+    RDevUsbcClient& iLdd;
+    
+    /**
+     * State
+     */
+    TState iState;
+    
+    /**
+     * Buffer to keep request, if needed to receive data from host in Data stage
+     * In case if request require data to be send from device to host,
+     * iBuffer keeps result of that request
+     */
+    RBuf8 iBuffer;
+        
+    };
+
+#endif // CSTATEMACHINE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/cusbdevcon.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,185 @@
+/*
+* 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:  Takes control over the EP0 vendor specific messages, and process requests
+*
+*/
+
+
+#ifndef CUSBDEVCON_H
+#define CUSBDEVCON_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32usbc.h>
+#include <usbman.h>
+#include <usbwatcher.h>
+
+class CUsbStateWatcher;     // watches device's USB states
+class CStateMachine;        // state-machine
+class CRequestsHandler;     // contains actual requests handlers
+
+static const TUint KSetupPacketLength = 8; // 8 bytes, always
+static const TUint KInactiveTimeForShutDown = 10000000; // microseconds
+
+/**
+ *  USB Device Controller
+ *  Contains all needed subclasses, to 
+ *  take control over EP0 vendor specific messages
+ *  and processing requests
+ *
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CUsbDevCon : public CActive  
+    {
+
+public:
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @return Constructed instance
+     */ 
+    static CUsbDevCon* NewL();
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @return Constructed instance
+     */ 
+    static CUsbDevCon* NewLC();
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CUsbDevCon();
+    
+    /**
+     * Performs action needed by specific usb state
+     *
+     * @since S60 v.5.0
+     * @param aUsbState USB state
+     */
+    void ActAccordinglyToUsbStateL(TUsbcDeviceState aUsbState);
+    
+private:
+
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     */
+    CUsbDevCon();
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */
+    void ConstructL();
+    
+    /**
+     * Take needed actions on starting services
+     *
+     * @since S60 v.5.0
+     */
+    void StartL();
+    
+    /**
+     * Take needed actions on stopping services
+     *
+     * @since S60 v.5.0
+     */
+    void StopL();
+    
+    // from CActive
+    
+    /**
+     * From CActive
+     *
+     */
+    void RunL();
+    
+    /**
+     * From CActive
+     *
+     */ 
+   void DoCancel();
+   
+    /**
+     * From CActive.
+     *
+     */ 
+     TInt RunError( TInt /*aError*/ );
+
+private: // data
+
+    /**
+     * USB state watcher
+     * Own
+     */
+    CUsbStateWatcher* iUsbStateWatcher;
+
+    /**
+     * CStateMachine
+     * Own
+     */
+    CStateMachine* iStateMachine;
+    
+    /**
+     * Requests handler 
+     * Own  
+     */
+    CRequestsHandler* iRequestsHandler;
+    
+    /**
+     * USB client
+     * Need to take control over EP0 
+     * Also reference to it will be provided to handlers
+     */
+    RDevUsbcClient iLdd;
+    
+    /**
+     * USB Watcher
+     * Need to handle some requests (like GetPersonalities)
+     * Reference to it will be provided to handlers
+     */
+    RUsbWatcher iUsbWatcher;
+    
+    /**
+     * USB Manager
+     * Need to handle some requests (like SetPersonality)
+     * Reference to it will be provided to handlers
+     */
+    RUsb iUsbManager;
+    
+    /**
+     * Previous USB state 
+     */
+    TInt iPrevUsbState;
+    
+    /**
+     * Shuts down if USB inactive for specified period of time
+     */
+    RTimer iShutdownTimer;
+
+    };
+
+#endif // USBDEVCON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/cusbstatewatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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:  Watches USB states
+*
+*/
+
+
+#ifndef CUSBSTATEWATCHER_H
+#define CUSBSTATEWATCHER_H
+
+#include <e32std.h>
+#include <d32usbc.h>
+
+#include "cusbdevcon.h"
+
+/**
+ *  Usb State watcher
+ *  Reports Usb state changes to CUsbDevCon
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CUsbStateWatcher : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notifications when USB state changed
+     * @param aLdd Link to LDD services
+     * @return Constructed instance
+     */ 
+    static CUsbStateWatcher* NewL(CUsbDevCon& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CUsbStateWatcher();
+    
+    /**
+     * Activates USB states watching
+     *
+     * @since S60 v.5.0
+     */
+    void Activate();
+        
+private:
+    
+    /**
+     * Default construction
+     *
+     * @since S60 v.5.0
+     * @param aObserver Gets notifications when USB state changed
+     * @param aLdd Link to LDD services
+     */
+    CUsbStateWatcher(CUsbDevCon& aObserver, RDevUsbcClient& aLdd);
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */
+    void ConstructL();
+    
+    // from CActive
+    
+    /**
+     * From CActive.
+     *
+     */
+    void RunL();
+    
+    /**
+     * From CActive.
+     *
+     */ 
+    void DoCancel();
+    
+     /**
+     * From CActive.
+     *
+     */ 
+     TInt RunError( TInt /*aError*/ );
+
+private: // data
+    
+    /**
+     * Device state
+     */
+    TUint iState;
+        
+    /**
+     * Observer
+     * Not own.  
+     */
+    CUsbDevCon& iObserver;
+    
+    /**
+     * LDD
+     * Not own.  
+     */
+    RDevUsbcClient& iLdd;
+    
+    };
+
+#endif // CUSBSTATEWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,118 @@
+/*
+* 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:  Central place for debug-type macros & functions
+*
+*/
+
+
+#ifndef _USBDEVCON_DEBUG_H
+#define _USBDEVCON_DEBUG_H
+
+#ifdef _DEBUG
+
+// Enable this to enable memory tracing
+//#define MEMTRACE
+
+// Following define is to enable OOM
+// situations in SRCS
+// SHOULD NEVER BE IN RELEASES.
+//#define TEST_OOM
+
+#ifdef __WINS__
+
+// File logging for WINS
+#define __FLOGGING__
+
+#else
+
+// Logging with RDebug for target HW
+#define __CLOGGING__
+
+#endif //__WINS__
+
+#endif // Debug
+
+#if defined ( __FLOGGING__ )
+
+_LIT( KLogFile,"UsbWatcher.txt" );
+_LIT( KLogDir,"usb" );
+
+#include <f32file.h>
+#include <flogger.h>
+
+#define FLOG( a ) { FPrint( a ); }
+
+#define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
+
+#define FTRACE( a ) { a; }
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+
+    // If memory tracing is activated.
+#ifdef MEMTRACE
+    TInt size;
+    User::Heap().AllocSize( size );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBDEVCON]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
+#endif
+}
+
+inline void FHex( const TUint8* aPtr, TInt aLen )
+{
+    RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
+}
+
+inline void FHex( const TDesC8& aDes )
+{
+    FHex( aDes.Ptr(), aDes.Length() );
+}
+
+// RDebug logging
+#elif defined(__CLOGGING__)
+
+#include <e32svr.h>
+
+#define FLOG( a ) { RDebug::Print( a ); }
+
+#define FLOGHEX( a )
+
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TInt tmpInt = VA_ARG( list, TInt );
+    TInt tmpInt2 = VA_ARG( list, TInt );
+    TInt tmpInt3 = VA_ARG( list, TInt );
+    VA_END( list );
+    RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
+}
+
+
+#else   // No loggings --> reduced code size
+
+#define FLOG( a )
+#define FLOGHEX( a )
+#define FTRACE( a )
+
+#endif //_DEBUG
+
+#endif // USBDEVCON_DEBUG_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/rom/usbdevcon.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Image description file for project UsbDevCon
+*
+*/
+
+
+#ifndef USBDEVCON_IBY__
+#define USBDEVCON_IBY__
+
+#ifdef __USB
+file=ABI_DIR\BUILD_DIR\usbdevcon.exe		SHARED_LIB_DIR\usbdevcon.exe
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/cep0reader.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* 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:  EP0 Reader 
+*
+*/
+
+
+#include "cep0reader.h"
+#include "cstatemachine.h"
+#include "cusbdevcon.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+CEP0Reader* CEP0Reader::NewL(CStateMachine& aObserver, RDevUsbcClient& aLdd)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Reader::NewL" ) );
+    
+    CEP0Reader* self = new (ELeave) CEP0Reader(aObserver, aLdd);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CEP0Reader::CEP0Reader(CStateMachine& aObserver, RDevUsbcClient& aLdd) :
+                                                            CActive(EPriorityMore),
+                                                            iLdd(aLdd),
+                                                            iObserver(aObserver)
+                                                            
+    {
+    CActiveScheduler::Add(this);
+    }
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+void CEP0Reader::ConstructL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Reader::ConstructL" ) );
+    
+    iBuffer.CreateL(0); // later will be reallocated with required size
+    }
+    
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CEP0Reader::~CEP0Reader()
+    {
+    Cancel();
+           
+    iBuffer.Close();
+    }   
+    
+// ---------------------------------------------------------------------------
+// Cancellation of outstanding request
+// ---------------------------------------------------------------------------
+//
+void CEP0Reader::DoCancel()
+    {
+    iLdd.ReadCancel(EEndpoint0);
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CEP0Reader::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+        
+// ---------------------------------------------------------------------------
+// Data has been read from EP0
+// ---------------------------------------------------------------------------
+//
+void CEP0Reader::RunL()
+    {
+
+    FLOG( _L( "[USBDEVCON]\tCEP0Reader::RunL Data received:" ) );
+    
+    iObserver.ReadEP0(iBuffer, iStatus);
+    }
+
+// ---------------------------------------------------------------------------
+// Issue request to read setup packet
+// ---------------------------------------------------------------------------
+//
+void CEP0Reader::ReadSetupPacket()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Reader::ReadSetupPacket" ) );
+
+    if(IsActive())
+        {
+        return;
+        }
+    
+    iBuffer.Close();
+    iBuffer.Create(KSetupPacketLength);
+    
+    iLdd.ReadPacket(iStatus, EEndpoint0, iBuffer, KSetupPacketLength);
+    SetActive();
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Issue request to read data
+// ---------------------------------------------------------------------------
+//  
+void CEP0Reader::Read(TUint aDataLength)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Reader::Read" ) );
+
+    if(IsActive())
+        {
+        return;
+        }
+    
+    iBuffer.Close();
+    iBuffer.Create(aDataLength);    
+        
+    iLdd.Read(iStatus, EEndpoint0, iBuffer, aDataLength);
+    SetActive();
+    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/cep0writer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,131 @@
+/*
+* 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:  EP0 Writer 
+*
+*/
+
+
+#include "cep0writer.h"
+#include "cstatemachine.h"
+#include "cusbdevcon.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+CEP0Writer* CEP0Writer::NewL(CStateMachine& aObserver, RDevUsbcClient& aLdd)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Writer::NewL" ) );
+    
+    CEP0Writer* self = new (ELeave) CEP0Writer(aObserver, aLdd);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CEP0Writer::CEP0Writer(CStateMachine& aObserver, RDevUsbcClient& aLdd) :
+                                                            CActive(EPriorityMore),
+                                                            iObserver(aObserver),
+                                                            iLdd(aLdd)
+    {
+    CActiveScheduler::Add(this);
+    }
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+void CEP0Writer::ConstructL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCEP0Writer::ConstructL" ) );
+    
+    iBuffer.CreateL(0); // later will be set with needed size
+    }
+    
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CEP0Writer::~CEP0Writer()
+    {
+    Cancel(); 
+           
+    iBuffer.Close();
+        
+    }   
+    
+// ---------------------------------------------------------------------------
+// Cancellation
+// ---------------------------------------------------------------------------
+//
+void CEP0Writer::DoCancel()
+    {
+    iLdd.WriteCancel(EEndpoint0);
+    }
+
+// ---------------------------------------------------------------------------
+// Data has been wrote to EP0 
+// ---------------------------------------------------------------------------
+//  
+void CEP0Writer::RunL()
+    {
+
+    FLOG( _L( "[USBDEVCON]\tCEP0Writer::RunL" ) );
+
+    iObserver.WroteEP0(iStatus);
+    }
+    
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CEP0Writer::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issue request to write data
+// ---------------------------------------------------------------------------
+//
+void CEP0Writer::Write(const RBuf8& aBuffer, TUint aDataLength)
+    {
+
+    FLOG( _L( "[USBDEVCON]\tCEP0Writer::Write" ) );
+
+    if(IsActive())
+        {
+        return;
+        }
+    
+    FTRACE(FPrint(
+            _L("[USBDEVCON]\tCEP0Writer::Write. aBuffer Length = %d aDataLength = %d" ),aBuffer.Length(), aDataLength));
+
+    iBuffer.Close();
+    iBuffer.Create(aBuffer, aDataLength);   
+    
+    iLdd.Write(iStatus, EEndpoint0, iBuffer, aDataLength, ETrue);
+    SetActive();
+    
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/crequestshandler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* 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:  Requests handler
+*
+*/
+
+
+
+#include <ecom/ecom.h>
+#include <cusbdevicecontrolplugin.h>
+
+#include "cusbdevcon.h"
+#include "crequestshandler.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+CRequestsHandler* CRequestsHandler::NewL(RDevUsbcClient& aLdd,
+                                         RUsbWatcher& aUsbWatcher,
+                                         RUsb& aUsbManager)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCRequestsHandler::NewL" ) );
+
+    CRequestsHandler* self = new (ELeave) CRequestsHandler(aLdd, aUsbWatcher, aUsbManager);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+    
+// -------------------------------------Handle--------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//  
+void CRequestsHandler::ConstructL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCRequestsHandler::ConstructL" ) );
+    
+    // read, construct and attach handlers
+    
+    RImplInfoPtrArray implementations;
+    const TEComResolverParams noResolverParams;
+    REComSession::ListImplementationsL(KUsbCMHandlerInterface, noResolverParams, KRomOnlyResolverUid, implementations);
+    
+    for (TUint i(0); i < implementations.Count(); ++i)
+        {
+        TUid uid(implementations[i]->ImplementationUid());
+        CUsbCMHandler* handler = (reinterpret_cast<CUsbCMHandler*>(REComSession::CreateImplementationL
+                                                                                                    (uid, _FOFF(CUsbCMHandler, iPrivateEComUID))));
+        iHandlers.Append(handler);
+        }
+       
+   implementations.Close(); // cleanup
+        
+   FTRACE(FPrint(
+           _L("[USBDEVCON]\tCRequestsHandler::ConstructL: Amount of handlers attached = %d" ), iHandlers.Count()));
+
+    // initialize handlers, pass them iLdd, iUsbWatcher, iUsbManager
+    for(TInt i(0); i < iHandlers.Count(); ++i)
+        {
+        iHandlers[i]->Initialize(iLdd, iUsbWatcher, iUsbManager);
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CRequestsHandler::CRequestsHandler( RDevUsbcClient& aLdd, 
+                                    RUsbWatcher& aUsbWatcher,
+                                    RUsb& aUsbManager) : 
+                            iLdd (aLdd),
+                            iUsbWatcher(aUsbWatcher),
+                            iUsbManager(aUsbManager)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CRequestsHandler::~CRequestsHandler()
+    {
+
+    FLOG( _L( "[USBDEVCON]\tCRequestsHandler::~CRequestsHandler()" ) );
+    // destroy handlers  
+    iHandlers.ResetAndDestroy();
+    
+    REComSession::FinalClose(); // plug-ins final cleanup
+    
+    }   
+
+
+// ---------------------------------------------------------------------------
+// Search plugin which can handle the request
+// ---------------------------------------------------------------------------
+//
+TInt CRequestsHandler::Handle(const RBuf8& aSetupPacket, RBuf8& aData)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCRequestsHandler::Handle" ) );
+    
+    TInt err(KErrNotSupported);
+    TUint counter(0); // handlers counter
+    
+    // loop through handlers, call handle() while error == KErrNotSupported
+    while((err == KErrNotSupported) && (counter < iHandlers.Count()))               
+        {
+        err = iHandlers[counter]->Handle(aSetupPacket, aData);
+        ++counter;
+        }
+        
+    return err;
+    
+    }
+    
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/cstatemachine.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,384 @@
+/*
+* 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:  usbdevcon state machine
+*
+*/
+
+
+#include "cusbdevcon.h"
+#include "cstatemachine.h"
+#include "cep0reader.h"
+#include "cep0writer.h"
+#include "crequestshandler.h"
+#include "debug.h"
+
+const TUint KOneByte = 8; // for shifting data to one byte
+
+// binary constant for checking if bit 7 is set
+const TUint KUsbDevConBit7 = 0x80;
+
+const TUint KLengthLoByte = 6;
+const TUint KLengthHiByte = 7;
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+CStateMachine* CStateMachine::NewL(CRequestsHandler& aRequestsHandler, RDevUsbcClient& iLdd)
+    {
+    FLOG( _L( "[USBDEVCON]\tCStateMachine::NewL" ) );
+    
+    CStateMachine* self = new (ELeave) CStateMachine(aRequestsHandler, iLdd);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+    
+// ---------------------------------------------------------------------------
+// Two-phase constructon
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::ConstructL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCStateMachine::ConstructL" ) );
+    
+    iBuffer.CreateL(0); // later will be reallocated with required size
+    
+    // reader
+    iEP0Reader = CEP0Reader::NewL(*this,iLdd);
+    
+    // writer
+    iEP0Writer = CEP0Writer::NewL(*this, iLdd);
+    
+    }
+    
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CStateMachine::CStateMachine(CRequestsHandler& aRequestsHandler, RDevUsbcClient& aLdd) : 
+                            iRequestsHandler(aRequestsHandler),
+                            iLdd (aLdd),
+                            iState(ENoneState)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CStateMachine::~CStateMachine()
+    {
+    delete iEP0Writer;
+    delete iEP0Reader;
+    iBuffer.Close();    
+    }   
+
+// ---------------------------------------------------------------------------
+// Starts state machine
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::Start()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCStateMachine::Start" ) );
+    
+    // resetting, if it's been already started
+    if(IsStarted())
+        {
+        Stop();
+        }
+    
+    iState = ESetupStage;   
+    iEP0Reader->ReadSetupPacket();
+                
+    }
+    
+// ---------------------------------------------------------------------------
+// Stops machine
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::Stop()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCStateMachine::Stop" ) );
+        
+    iEP0Reader->Cancel();
+    iEP0Writer->Cancel();
+    
+    iState = ENoneState;
+    
+    }
+    
+// ---------------------------------------------------------------------------
+// ETrue if state machine is started
+// ---------------------------------------------------------------------------
+//
+TInt CStateMachine::IsStarted() const
+    {
+    
+    if(ENoneState == iState)
+        {
+        FLOG( _L( "[USBDEVCON]\tCStateMachine::IsStarted == EFalse" ) );
+        return EFalse;
+        }
+        else
+        {
+        FLOG( _L( "[USBDEVCON]\tCStateMachine::IsStarted == ETrue" ) );
+        }
+    return ETrue;
+    }
+    
+// ---------------------------------------------------------------------------
+// Something has been read from EP0 
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::ReadEP0(RBuf8& aBuffer, const TRequestStatus& aStatus)
+    {
+    
+    FTRACE(FPrint(
+            _L("[USBDEVCON]\tCStateMachine::ReadEP0: BufferLength = %d, aStatus = %d" ),aBuffer.Length(), aStatus.Int()));
+    
+    // all errors while reading data lead to idle state (ESetupStage in our case)
+    if(KErrNone != aStatus.Int())
+        {
+        // restart
+        Start();
+        return;
+        }
+    
+    TInt err(KErrNone);
+    
+    switch(iState)
+        {
+        case ESetupStage: // setup transaction received
+            {
+            
+            FLOG( _L( "[USBDEVCON]\tCStateMachine::ReadEP0 processing ESetupStage" ) );
+            
+            if(aBuffer.Length() != KSetupPacketLength) // SetupPacket is always 8 bytes
+                {
+                Start();
+                return;
+                }
+            
+            ProcessSetupPacket(aBuffer);
+                                
+            break;
+            }
+        case EDataStage:  // some data received from host. This data is required for the request, received on setup stage
+            {
+            
+            FLOG( _L( "[USBDEVCON]\tCStateMachine::ReadEP0 processing EDataStage" ) );
+
+            // handle request, providing data together with request descriptor
+            // iBuffer == request, aBuffer == data from host
+            err = iRequestsHandler.Handle(iBuffer, aBuffer);
+            
+            if(KErrNone != err) // some error happened while handling request
+                {
+                iLdd.EndpointZeroRequestError(); // stall EP0
+                }
+                else
+                {
+                // send Status Packet, indicating that we received request, data, and handled request. OK
+                iLdd.SendEp0StatusPacket();
+                }
+            
+            // all done, go to idle state
+            iState = ESetupStage;
+            iEP0Reader->ReadSetupPacket();
+            
+            break;
+            
+            }
+        default:
+            {
+            FLOG( _L( "[USBDEVCON]\tCStateMachine::ReadEP0 processing ***NOT_DEFINED state***" ) );
+            }
+            
+        }
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Processing setup packet 
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::ProcessSetupPacket(RBuf8& aSetupPacket)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCStateMachine::ProcessSetupPacket" ) );
+    
+    TUint datalength(0); // data length, to be received from host
+            
+    if(IsDataFromHostRequired(aSetupPacket, datalength)) // then goes to data stage
+        {
+        
+        FTRACE(FPrint(
+            _L("[USBDEVCON]\tCStateMachine::ProcessSetupPacket. Data from host is required: %d bytes" ),datalength));
+
+        // save request, until receiving following data
+        iBuffer.Close();
+        iBuffer.Create(aSetupPacket);
+                
+        // switch to Data state
+        iState = EDataStage;
+        iEP0Reader->Read(datalength);
+    
+        return;
+        
+        }
+            
+    TInt err(KErrNone); 
+                        
+    // Handle request. It does not require data from host   
+    // aSetupPacket == request, iBuffer = result of the request
+    err = iRequestsHandler.Handle(aSetupPacket, iBuffer);
+        
+    if(KErrNone != err) // some error happened while handling request
+        {
+        
+        FTRACE(FPrint(
+            _L("[USBDEVCON]\tCStateMachine::ProcessSetupPacket. Error while handling request, errcode: %d" ), err));
+
+        iLdd.EndpointZeroRequestError(); // stall EP0
+            
+        // listen to EP0
+        iState = ESetupStage;
+        iEP0Reader->ReadSetupPacket();
+        
+        return;
+        }
+            
+    // send response, size of datalength
+    if(IsDataFromDeviceRequired(aSetupPacket, datalength))
+        {
+        
+        FTRACE(FPrint(
+          _L("[USBDEVCON]\tCStateMachine::ProcessSetupPacket. Data from device is required: %d bytes" ),datalength));
+
+        iState = EStatusStage;
+        iEP0Writer->Write(iBuffer, datalength);
+        
+        return;
+                
+        }
+    
+    // status stage 
+    iLdd.SendEp0StatusPacket();
+                
+    // all is done, listen to EP0, in setup stage
+    iState = ESetupStage;
+    iEP0Reader->ReadSetupPacket();
+    
+    }
+    
+
+// ---------------------------------------------------------------------------
+// Something has been written to EP0 
+// ---------------------------------------------------------------------------
+//
+void CStateMachine::WroteEP0(const TRequestStatus& aStatus)
+    {
+    
+    FTRACE(FPrint(
+            _L("[USBDEVCON]\tCStateMachine::WroteEP0: iStatus = %d" ), aStatus.Int()));
+
+    // all errors while writing data lead to idle state (ESetupStage in our case)
+    if(KErrNone != aStatus.Int())
+        {
+        // restart
+        Start();
+        }
+        
+    switch(iState)
+        {
+        case EStatusStage:
+            {
+            
+            FLOG( _L( "[USBDEVCON]\tCStateMachine::WroteEP0 EStatusStage -> ESetupStage" ) );
+            
+            // successfully wrote data to EP0
+            // go to idle
+            iState = ESetupStage;
+            iEP0Reader->ReadSetupPacket();
+            
+            break;
+            }
+        default:
+            {
+            FLOG( _L( "[USBDEVCON]\tCStateMachine::WroteEP0 ***ENoneState***" ) );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// ETrue if data required to be send from host 
+// ---------------------------------------------------------------------------
+//
+TBool CStateMachine::IsDataFromHostRequired(const RBuf8& aSetupPacket, TUint& aDataLength) const
+    {
+        // bits 6 and 7 of SetupPacket contain wLength - length of data in Data stage  
+        aDataLength = static_cast<TUint16>(aSetupPacket[KLengthLoByte] |
+                                            (aSetupPacket[KLengthHiByte] << KOneByte));
+        if(0 == aDataLength)
+            {
+            // no data required in any direction
+            return EFalse;
+            }
+            
+        // direction of data
+        // bit 7 of byte 0 of aSetupPacket (means bmRequestType one) contains:
+        // 0, if no data or data goes from host to device
+        // 1 means data goes from device to host
+        if(KUsbDevConBit7 & aSetupPacket[0])
+            { // bit 7 is set => data flow is from device to host
+            return EFalse;
+            }
+            
+        return ETrue;
+        
+    }
+
+// ---------------------------------------------------------------------------
+// ETrue if data required to be send to host
+// ---------------------------------------------------------------------------
+//
+TBool CStateMachine::IsDataFromDeviceRequired(const RBuf8& aSetupPacket, TUint& aDataLength) const
+    {
+        // bytes 6 and 7 of SetupPacket contain wLength - length of data in Data stage
+        aDataLength = static_cast<TUint16>(aSetupPacket[KLengthLoByte] |
+                                            (aSetupPacket[KLengthHiByte] << KOneByte));
+        if(0 == aDataLength)
+            {
+            // no data required in any direction
+            return EFalse;
+            }
+            
+        // direction of data
+        // bit 7 of byte 0 of aSetupPacket (means bmRequestType one) contains:
+        // 0, if no data or data goes from host to device
+        // 1 means data goes from device to host
+        if(KUsbDevConBit7 & aSetupPacket[0])
+            { // bit 7 is set => data flow is from device to host
+            return ETrue;
+            }
+            
+        return EFalse;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/cusbdevcon.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,398 @@
+/*
+* 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:  Takes control of device&vendor-specific control messages over EP0
+*
+*/
+
+
+#include <usbman.h>
+
+#include "cusbdevcon.h"
+#include "cusbstatewatcher.h"
+#include "crequestshandler.h"
+#include "cstatemachine.h"
+#include "debug.h"
+
+// LITERALS
+_LIT( KUsbDevConName, "UsbDevCon" );
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+CUsbDevCon* CUsbDevCon::NewLC()
+    {
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::NewLC" ) );
+    
+    CUsbDevCon* self = new (ELeave) CUsbDevCon();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//  
+CUsbDevCon* CUsbDevCon::NewL()
+    {
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::NewL" ) );
+    
+    CUsbDevCon* self = CUsbDevCon::NewLC();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//  
+void CUsbDevCon::ConstructL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ConstructL" ) );
+    
+    // usbc
+    User::LeaveIfError(iLdd.Open(0));
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ConstructL RDevUsbcClient opened OK" ) );
+    
+    // usb manager
+    User::LeaveIfError(iUsbManager.Connect());
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ConstructL RUsb connected OK" ) );
+    
+    // usb watcher
+    User::LeaveIfError(iUsbWatcher.Connect());
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ConstructL RUsbWatcher connected OK" ) );
+    
+    // device state watcher
+    iUsbStateWatcher = CUsbStateWatcher::NewL(*this, iLdd);
+        
+    // Requests handler
+    iRequestsHandler = CRequestsHandler::NewL(iLdd, iUsbWatcher, iUsbManager);
+    
+    // state machine
+    iStateMachine = CStateMachine::NewL(*iRequestsHandler, iLdd);
+    
+     User::LeaveIfError(iShutdownTimer.CreateLocal());
+    
+    // get usb state, and act accordingly to it
+    TUsbcDeviceState usbcstate(EUsbcDeviceStateUndefined);
+    iLdd.DeviceStatus(usbcstate);
+    
+    FTRACE(FPrint(
+            _L("[USBDEVCON]\tCUsbDevCon::ConstructL: Usbc state = %d" ),usbcstate));
+    
+    ActAccordinglyToUsbStateL(usbcstate);
+     
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//  
+CUsbDevCon::CUsbDevCon() : CActive(EPriorityStandard),
+                             iUsbStateWatcher(0),
+                             iStateMachine (0),
+                             iRequestsHandler(0),
+                             iPrevUsbState(EUsbcDeviceStateUndefined)
+    {
+    CActiveScheduler::Add(this);
+     }
+
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CUsbDevCon::~CUsbDevCon()
+    {
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon" ) );
+    
+    Cancel();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Cancel" ) );
+    
+    delete iStateMachine;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon StateMachine" ) );
+    
+    delete iRequestsHandler;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon RequestsHandler" ) );
+    
+    delete iUsbStateWatcher;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbStateWatcher" ) );
+    
+    iUsbWatcher.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbWatcher" ) );
+    
+    iUsbManager.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbManager" ) );
+    
+    iLdd.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon LDD" ) );
+    
+    iShutdownTimer.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Timer" ) );
+    
+    }   
+
+// ---------------------------------------------------------------------------
+// Acts accordingly to USB state
+// ---------------------------------------------------------------------------
+//
+void CUsbDevCon::ActAccordinglyToUsbStateL(TUsbcDeviceState aUsbcState)
+    {
+    
+    switch (aUsbcState)
+        {
+        case EUsbcDeviceStateUndefined:
+            {
+            
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Undefined" ) );
+
+            StopL();
+            break;
+            }
+                
+        case EUsbcDeviceStateAttached:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Attached, ignored" ) );
+
+            break;
+            }
+                
+        case EUsbcDeviceStateSuspended:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Suspended" ) );
+            // NO break here
+            }
+        case EUsbcDeviceStatePowered:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Powered" ) );
+
+            // In powered or suspended state, we are not allowed to do any data 
+            // communication. Hence if there are pending read/write requests,
+            // we need cancel them. 
+            // Not call StopL() here because we do not want to shut down this
+            // process so earlier but in Undefined state.
+            if ( iStateMachine->IsStarted() )
+                {
+                iStateMachine->Stop();
+                // release device control
+                User::LeaveIfError(iLdd.ReleaseDeviceControl());
+                }
+            break;
+            }
+                
+        case EUsbcDeviceStateDefault:
+            {
+            // The request will only be started from default state.
+            // If it has been started already, nothing will be done.
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Default" ) );
+
+            StartL();
+            break;
+            }
+                
+        case EUsbcDeviceStateAddress:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Addressed" ) );
+
+            StartL();
+            break;
+            }
+                
+        case EUsbcDeviceStateConfigured:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Configured" ) );
+
+            StartL();
+                
+            break;
+            }
+        default:
+            {
+                
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: ***Unknown***" ) );
+
+            StopL();
+            break;
+            }
+        }
+            
+    iPrevUsbState = aUsbcState;
+            
+    // listen to USB states change
+    iUsbStateWatcher->Activate();
+    
+    }
+    
+ // ---------------------------------------------------------------------------
+// Timer is completed
+// ---------------------------------------------------------------------------
+//   
+void CUsbDevCon::RunL()
+    {
+    FTRACE(FPrint(
+            _L("[USBDEVCON]\tCUsbDevCon::RunL: iStatus = %d" ),iStatus.Int()));
+   
+    if(KErrNone == iStatus.Int())
+        {
+        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::RunL Exiting usbdevcon" ) );      
+        
+        // Shutdown timer is finished, exit program
+        CActiveScheduler::Stop(); // destruct resources
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Cancellation
+// ---------------------------------------------------------------------------
+//   
+void CUsbDevCon::DoCancel()
+    {
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::DoCancel" ) )
+    iShutdownTimer.Cancel();      
+    }
+    
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbDevCon::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// Starts UsbDevCon services
+// ---------------------------------------------------------------------------
+//
+void CUsbDevCon::StartL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StartL" ) );        
+
+    if(!iStateMachine->IsStarted())
+        {
+        // set device control
+        User::LeaveIfError(iLdd.SetDeviceControl());
+        
+        // start state machine
+        iStateMachine->Start();
+        
+        }
+        
+    // Cancel shutdown timer, if it is started
+    iShutdownTimer.Cancel();
+    }
+    
+// ---------------------------------------------------------------------------
+// Stops UsbDevCon services
+// ---------------------------------------------------------------------------
+//
+void CUsbDevCon::StopL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL" ) );
+    
+    if(iStateMachine->IsStarted())
+        {
+        
+        // stop state machine
+        iStateMachine->Stop();
+        
+        // release device control
+        User::LeaveIfError(iLdd.ReleaseDeviceControl());
+        
+        }
+         
+    if(!IsActive()) // not waiting for timer
+        {
+        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Starting timer" ) );
+        // run timer
+        iShutdownTimer.Cancel();
+
+        // RunL will be called after KInactiveTimeForShutDown milliseconds
+        iShutdownTimer.After(iStatus, TTimeIntervalMicroSeconds32(KInactiveTimeForShutDown)); 
+        SetActive();
+        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Timer is started" ) );
+        }
+    }
+    
+
+// ----------------------------------------------------------------------------
+// Constructs and installs the active scheduler, constructs UsbDevCon object.
+// ----------------------------------------------------------------------------
+//
+static void StartUsbDevConL()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tStartUsbDevConL" ) );
+        
+    // 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 );
+    
+    CUsbDevCon* instance =  CUsbDevCon::NewLC();
+    
+    RProcess::Rendezvous(KErrNone); // signal to starter process, that usbdevcon started OK or failed to start
+           
+    FLOG( _L( "[USBDEVCON]\tStartUsbDevConL Usbdevcon is started successfully" ) );
+    
+    // returns only when UsbDevCon closing
+    CActiveScheduler::Start();
+
+    CleanupStack::PopAndDestroy( instance );
+    CleanupStack::PopAndDestroy( myScheduler );
+    }
+
+// ---------------------------------------------------------------------------
+// Main function of the application executable.
+// ---------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    TInt err;
+    
+    // rename the thread so it is easy to find the panic application
+    err = User::RenameThread(KUsbDevConName);
+    
+    if(KErrNone != err)
+        {
+        return err;
+        }
+    
+    __UHEAP_MARK;
+    
+    // create clean-up stack
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    
+    TRAP( err, StartUsbDevConL() );
+    
+    delete cleanup; // destroy clean-up stack
+    __UHEAP_MARKEND;
+
+    return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbdevcon/src/cusbstatewatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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:  Watches USB states
+*
+*/
+
+
+#include "cusbstatewatcher.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phase construction 
+// ---------------------------------------------------------------------------
+//
+CUsbStateWatcher* CUsbStateWatcher::NewL(CUsbDevCon& aObserver, RDevUsbcClient& aLdd)
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbStateWatcher::NewL" ) );
+
+    CUsbStateWatcher* self = new (ELeave) CUsbStateWatcher(aObserver, aLdd);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction 
+// ---------------------------------------------------------------------------
+//
+CUsbStateWatcher::CUsbStateWatcher(CUsbDevCon& aObserver, RDevUsbcClient& aLdd) :
+                                                            CActive(EPriorityMore),
+                                                            iState(EUsbcNoState),
+                                                            iObserver(aObserver),
+                                                            iLdd(aLdd)
+                                                        
+    {
+    CActiveScheduler::Add(this);
+    }
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateWatcher::ConstructL()
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// Destruction 
+// ---------------------------------------------------------------------------
+//
+CUsbStateWatcher::~CUsbStateWatcher()
+    {
+    Cancel();
+    }   
+    
+// ---------------------------------------------------------------------------
+// Cancellation 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateWatcher::DoCancel()
+    {
+    iLdd.AlternateDeviceStatusNotifyCancel();
+    }
+    
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbStateWatcher::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// USB state has changed 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateWatcher::RunL()
+    {
+    if (!(iState & KUsbAlternateSetting))
+        {
+        iObserver.ActAccordinglyToUsbStateL(TUsbcDeviceState(iState));
+        }
+        else 
+        {
+        // Alternate interface setting changed to iDeviceState & ~KUsbAlternateSetting
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Start listening to USB state changes 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateWatcher::Activate()
+    {
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbStateWatcher::Activate" ) );
+    
+    if(IsActive())
+        {
+        return;
+        }
+        
+    iLdd.AlternateDeviceStatusNotify(iStatus, iState);
+    SetActive();
+    FLOG( _L( "[USBDEVCON]\tCUsbStateWatcher::Activate end" ) );
+     
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/data/0x102823dd.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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:  Resource definitions
+*
+*/
+
+
+#include "registryinfov2.rh"
+#include <bldvariant.hrh>
+#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 = 0x102823dd;
+  // Declare array of interface info
+  interfaces = 
+    {
+    INTERFACE_INFO
+      {
+      // UID of interface that is implemented
+      interface_uid = KLOCODBEARERINTERFACEUID;
+      implementations = 
+        {
+        // Info for USBlocodplugin
+        IMPLEMENTATION_INFO
+          {
+          implementation_uid = KFeatureIdUsb;
+          version_no = 1;
+          display_name = "LCD USB 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/usbengines/usblocodplugin/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/UsbLocodPlugin.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(UsbLocodPlugin.iby)
+
+PRJ_MMPFILES
+../group/usblocodplugin.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/group/usblocodplugin.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -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 USB LCD plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+ 
+TARGET                  usblocodplugin.dll
+TARGETTYPE              PLUGIN
+
+UID                     0x10009D8D 0x102823DD
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  usblcdplugin.cpp
+SOURCE                  usblcdactive.cpp
+SOURCE                  proxy.cpp
+
+SOURCEPATH              ../data
+START RESOURCE          0x102823dd.rss
+TARGET                  usblocodplugin.rsc
+END // RESOURCE
+
+USERINCLUDE             ../inc 
+
+SYSTEMINCLUDE           ../../../inc
+SYSTEMINCLUDE           /epoc32/include/ecom 
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 euser.lib  // Kernel API
+LIBRARY                 ECom.lib   // ECOM framework API
+LIBRARY                 usbman.lib // RUSB API (USB Manager)
+
+#include <usb/usblogger.mmh>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/inc/usblcdactive.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* 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:  Control the asynchronouse request from serviceplugin to 
+*                client side. 
+*
+*/
+
+
+#ifndef USBLCDACTIVE_H
+#define USBLCDACTIVE_H
+
+#include <locodbearerpluginobserver.h>
+#include <usb/usblogger.h>
+
+/**
+ *  Base Active Object class 
+ *
+ *  Its instance will be used to control Asynchronous request
+ *  from ECom plugin to FaxModem server
+ *
+ */
+NONSHARABLE_CLASS(CUsbLcdActive) : public CActive
+    {
+
+public:
+
+    static CUsbLcdActive* NewL(MLocodBearerPluginObserver& aObserver); 
+
+    virtual ~CUsbLcdActive();
+
+protected:
+
+    // from base class CActive
+    /**
+     * From CActive. 
+     * Cancel current activity.
+     */
+    void DoCancel();
+
+    /**
+     * From CActive. 
+     * RunL() function.
+     */
+    void RunL();
+
+    /**
+     * From CActive. 
+     * Called if RunL() leaves. Retry listening after error.
+     */
+    TInt RunError( TInt aError );
+
+private:
+
+    CUsbLcdActive(MLocodBearerPluginObserver& aObserver);
+
+    void ConstructL();
+    void Start();
+    /**
+     * Handle the change of selected USB personality.
+     * @param aNewPersonalityId current selected USB personality ID.
+     */
+    void HandleUsbPersonalityChange( TInt aNewPersonalityId );
+
+private: // data
+
+    MLocodBearerPluginObserver& iObserver;
+    RProperty iProperty;
+    };
+
+
+#endif // USBLCDACTIVE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/inc/usblcdplugin.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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:  Definition USB bearer implementation of EComm Interface. 
+*
+*/
+
+
+#ifndef USBLCDPLUGIN_H
+#define USBLCDPLUGIN_H
+
+#include <e32property.h>
+#include <locodbearerplugin.h>
+#include "usblcdactive.h"
+#include <usb/usblogger.h>
+
+/**
+ *  Class of EComm interface implementation
+ */
+NONSHARABLE_CLASS(CUsbLcdPlugin) : public CLocodBearerPlugin
+    {
+
+public:
+
+    static CUsbLcdPlugin* NewL(TLocodBearerPluginParams& aParams);
+    ~CUsbLcdPlugin(); 
+   
+private:
+
+    CUsbLcdPlugin(TLocodBearerPluginParams& aParams);
+    void ConstructL();
+
+private: // data
+    
+    /**
+     * Array of Active Object, own.
+     */
+    CUsbLcdActive*  iUsbLcdActive;
+       
+    };
+
+
+#endif // USBLCDPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/rom/UsbLocodPlugin.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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:  Image description file for project UsbLocodPlugin
+*
+*/
+
+
+#ifndef USBLOCODPLUGIN_IBY
+#define USBLOCODPLUGIN_IBY
+
+#ifdef __USB
+USB_PLUGIN(usblocodplugin.dll,102823DD.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/src/proxy.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:  Export ECom interface implementations
+*
+*/
+
+
+#include <implementationproxy.h> //ECom header file
+#include <bldvariant.hrh>
+#include "usblcdplugin.h"
+
+// ---------------------------------------------------------------------------
+// An array of TImplementationProxy objects which connect each 
+// implemeation with its instantiation function
+// ---------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KFeatureIdUsb, CUsbLcdPlugin::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/usbengines/usblocodplugin/src/usblcdactive.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,165 @@
+/*
+* 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:  Active object class used to manage asynchronous request.
+*
+*/
+
+
+#include <e32property.h>
+#include "usblcdactive.h"
+#include <UsbWatcherInternalPSKeys.h>
+#include <usbpersonalityids.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USBLcdPlugin");
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructs a CUsbLcdActive object.
+// ---------------------------------------------------------------------------
+//
+CUsbLcdActive* CUsbLcdActive::NewL(MLocodBearerPluginObserver& aObserver)
+    {
+    LOG_STATIC_FUNC_ENTRY
+    CUsbLcdActive* self = new (ELeave) CUsbLcdActive(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbLcdActive::~CUsbLcdActive()
+    {
+    LOG_FUNC
+    Cancel();
+    iProperty.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class CActive
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdActive::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// RunL() From class CActive
+// ---------------------------------------------------------------------------
+//
+   
+void CUsbLcdActive::RunL()
+    {
+    LOG_FUNC
+    TInt value;
+    
+    if( iStatus != KErrNone )
+       {
+       LOGTEXT2(_L8("CUsbLcdActive::RunL() error = %d"),iStatus.Int());
+       }
+    else
+       {
+
+        TInt ret = iProperty.Get( value );
+        LOGTEXT3(_L8("Personality: %d, ret: %d"), value, ret);  
+        iProperty.Subscribe(iStatus);
+        SetActive();
+        if (ret == KErrNone)
+            { 
+            HandleUsbPersonalityChange( value );
+            }    
+       }
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive
+// ---------------------------------------------------------------------------
+//
+    
+TInt CUsbLcdActive::RunError( TInt /*aError*/ )
+    {
+    LOG_FUNC
+    return KErrNone; 
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CUsbLcdActive::CUsbLcdActive(MLocodBearerPluginObserver& aObserver)
+    : CActive(EPriorityStandard), iObserver(aObserver)
+    {
+    LOG_FUNC
+    CActiveScheduler::Add( this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Method to perform second phase construction.
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdActive::ConstructL()
+    {  
+    LOG_FUNC
+    User::LeaveIfError(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality));
+    Start();
+    }
+
+// ---------------------------------------------------------------------------
+// Start() function is called to initiate RProperty subscription
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdActive::Start()
+    {     
+    LOG_FUNC
+    iProperty.Subscribe(iStatus);
+    SetActive();
+    // Check the starting state
+    TInt usbPersonalityId( KUsbWatcherSelectedPersonalityNone );
+    TInt ret = iProperty.Get( usbPersonalityId );
+    if ( ( ret == KErrNone ) && 
+        ( usbPersonalityId != KUsbWatcherSelectedPersonalityNone ) )
+        {
+        HandleUsbPersonalityChange( usbPersonalityId ); 
+        }
+    }
+     
+
+// ---------------------------------------------------------------------------
+// This function handles the USB active personality change, and notify LoCoD
+// framework whether PC Suite is active 
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdActive::HandleUsbPersonalityChange( TInt aNewPersonalityId )
+    {
+    LOG_FUNC
+    LOGTEXT2( _L8( "aNewPersonalityId: %d"), aNewPersonalityId );
+    TBool isPcSuiteActive( EFalse );
+    if ( ( aNewPersonalityId == KUsbPersonalityIdPCSuite ) ||
+         ( aNewPersonalityId == KUsbPersonalityIdPCSuiteMTP ) )
+        {
+        isPcSuiteActive = ETrue;
+        }
+    iObserver.NotifyBearerStatus( ELocodBearerUSB, isPcSuiteActive );
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/src/usblcdplugin.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* 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 class handles the definition of ECom plugin interface 
+*                implementation. 
+*
+*/
+
+
+#include "usblcdplugin.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USBLcdPlugin");
+#endif
+
+CUsbLcdPlugin* CUsbLcdPlugin::NewL(TLocodBearerPluginParams& aParams)
+    {
+    LOG_STATIC_FUNC_ENTRY
+    CUsbLcdPlugin* self = new (ELeave) CUsbLcdPlugin(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbLcdPlugin::~CUsbLcdPlugin()
+    {
+    LOG_FUNC
+    delete iUsbLcdActive;
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CUsbLcdPlugin::CUsbLcdPlugin(TLocodBearerPluginParams& aParams)
+    : CLocodBearerPlugin(aParams)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdPlugin::ConstructL()
+    {
+    LOG_FUNC
+    iUsbLcdActive = CUsbLcdActive::NewL(Observer()); 
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/Bmarm/USBLocodPluginTestU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/Bwins/USBLocodPluginTestU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/EABI/USBLocodPluginTestU.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/conf/USBLocodPluginTest.cfg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* 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:   
+*
+*/
+
+// USBLocodPluginTest Module - total 8 tc
+
+// USBLocodPluginTest Api Tests (4 tc)
+
+[Test]
+title Initialization (USB Locod Plugin API Test) 
+create USBLocodPluginTest tester
+tester ExecuteApiTest InitializationTestL
+delete tester
+[Endtest] 
+
+[Test]
+title Implementatiation Uid Check (USB Locod Plugin API Test) 
+create USBLocodPluginTest tester
+tester ExecuteApiTest ImplementatiationIdTestL
+delete tester
+[Endtest] 
+
+[Test]
+title Set PC Suite Personality (USB Locod Plugin API Test) 
+create USBLocodPluginTest tester
+tester ExecuteApiTest USBPCSuitePersonalityTestL
+delete tester
+[Endtest] 
+
+[Test]
+title Set Default Personality (USB Locod Plugin API Test) 
+create USBLocodPluginTest tester
+tester ExecuteApiTest USBDefaultPersonalityTestL
+delete tester
+[Endtest] 
+
+// Add new api tests here
+// ...
+
+
+// USBLocodPluginTest Module Tests (3 tc)
+
+[Test]
+title Set MS Personality (USB Locod Plugin Module Test)
+create USBLocodPluginTest tester
+tester ExecuteModuleTest USBMSPersonalityTestL
+delete tester
+[Endtest]
+
+[Test]
+title Set PTP Personality (USB Locod Plugin Module Test)
+create USBLocodPluginTest tester
+tester ExecuteModuleTest USBPTPPersonalityTestL
+delete tester
+[Endtest]
+
+[Test]
+title Set MTP Personality (USB Locod Plugin Module Test)
+create USBLocodPluginTest tester
+tester ExecuteModuleTest USBMTPPersonalityTestL
+delete tester
+[Endtest]
+
+// Add new module tests here
+// ...
+
+
+// USBLocodPluginTest Branch Tests (1 tc)
+
+[Test]
+title Set PC Suite MTP Personality (USB Locod Plugin Branch Test)
+create USBLocodPluginTest tester
+tester ExecuteBranchTest USBPCSuiteMTPPersonalityTestL
+delete tester
+[Endtest]
+
+// Add new branch tests here
+// ...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          USBLocodPluginTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         USBLocodPluginTest.def
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+USERINCLUDE	../inc
+USERINCLUDE 	../../../inc
+
+SOURCEPATH      ../src
+SOURCE          USBLocodPluginTest.cpp
+SOURCE          USBLocodPluginTestBlocks.cpp 
+SOURCE 		LocodBearerPluginObs.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY		ecom.lib
+
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest_ats.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,60 @@
+;
+; 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: 
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 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\USBLocodPluginTest.dll"-"c:\Sys\Bin\USBLocodPluginTest.dll"
+"..\init\USBLocodPluginTest_ats.ini"-"e:\testing\init\USBLocodPluginTest.ini"
+"..\conf\USBLocodPluginTest.cfg"-"e:\testing\conf\USBLocodPluginTest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/USBLocodPluginTest_phone.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,60 @@
+;
+; 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: 
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x1028315F], 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\urel\USBLocodPluginTest.dll"-"c:\Sys\Bin\USBLocodPluginTest.dll"
+"..\init\USBLocodPluginTest_phone.ini"-"c:\testframework\testframework.ini"
+"..\conf\USBLocodPluginTest.cfg"-"c:\testframework\USBLocodPluginTest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+USBLocodPluginTest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/build_sis_ats.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 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: 
+@rem
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis USBLocodPluginTest_ats.pkg
+call signsis USBLocodPluginTest_ats.sis USBLocodPluginTest_ats.sisx rd.cer rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/group/build_sis_phone.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 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: 
+@rem
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis USBLocodPluginTest_phone.pkg
+call signsis USBLocodPluginTest_phone.sis USBLocodPluginTest_phone.sisx rd.cer rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/inc/LocodBearerPluginObs.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+#ifndef LOCODBEARERPLUGINOBS_H_
+#define LOCODBEARERPLUGINOBS_H_
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <StifLogger.h>
+#include <testclassassert.h>
+
+#include <locodbearerplugin.h>
+#include <locodbearerpluginobserver.h>
+#include <locodbearer.h>
+
+NONSHARABLE_CLASS( CLocodBearerPluginObs ) : public MLocodBearerPluginObserver
+{
+public:
+    static CLocodBearerPluginObs* NewL( CStifLogger* aLog );
+    virtual ~CLocodBearerPluginObs();
+    
+    void ActivateObserver( TBool& aLocodBearerStatus );
+    
+private:
+    CLocodBearerPluginObs( CStifLogger* aLog );
+    
+    void ConstructL();
+    void NotifyBearerStatus( TLocodBearer aBearer, TBool aStatus );
+    
+private:
+    CStifLogger* iLog;
+    CActiveSchedulerWait* iWait;
+    TBool iLocodBearerStatus;
+};
+
+#endif /*LOCODBEARERPLUGINOBS_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/inc/USBLocodPluginTest.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,223 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+#ifndef USBLOCODPLUGINTEST_H
+#define USBLOCODPLUGINTEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include <e32property.h>
+#include <usbwatcherinternalpskeys.h>
+#include <usbpersonalityids.h>
+#include <locodbearerplugin.h>
+#include <locodbearer.h>
+
+#include "locodbearerpluginobs.h"
+
+// CONSTANTS
+#define KUsbDefaultPersonality  0x00
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Logging path
+_LIT( KUSBLocodPluginTestLogPath, "\\logs\\testframework\\USBLocodPluginTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+//_LIT( KUSBLocodPluginTestLogPath, "e:\\testing\\stiflogs\\" ); 
+
+// Log file
+_LIT( KUSBLocodPluginTestLogFile, "USBLocodPluginTest.txt" );
+_LIT( KUSBLocodPluginTestLogFileWithTitle, "USBLocodPluginTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CUSBLocodPluginTest;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TUSBLocodPluginTestResult
+    {
+    ETestCasePassed,
+    ETestCaseFailed
+    };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+*  CUSBLocodPluginTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CUSBLocodPluginTest) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CUSBLocodPluginTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUSBLocodPluginTest();
+
+    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.
+        */
+        CUSBLocodPluginTest( 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 ExecuteApiTest( CStifItemParser& aItem );
+        virtual TInt ExecuteModuleTest( CStifItemParser& aItem );
+        virtual TInt ExecuteBranchTest( CStifItemParser& aItem );
+        
+        /**
+         * Method used to log version of test class
+         */
+        void SendTestClassVersion();
+
+        //ADD NEW METHOD DEC HERE
+        //[TestMethods] - Do not remove
+
+	void DoExecuteApiTestL( TPtrC aApiTestName, TUSBLocodPluginTestResult& aTestResult );
+
+	void InitializationTestL( TUSBLocodPluginTestResult& aTestResult );
+	void ImplementatiationIdTestL( TUSBLocodPluginTestResult& aTestResult );
+	void USBPCSuitePersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+	void USBDefaultPersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+	
+	void DoExecuteModuleTestL( TPtrC aModuleTestName, TUSBLocodPluginTestResult& aTestResult );
+
+    void USBMSPersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+    void USBPTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+    void USBMTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+
+	void DoExecuteBranchTestL( TPtrC aBranchTestName, TUSBLocodPluginTestResult& aTestResult );
+
+	void USBPCSuiteMTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult );
+	
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        RProperty* iSelectedPersProperty;
+        
+        CLocodBearerPlugin* iLocodBearerPlugin;
+        CLocodBearerPluginObs* iLocodBearerPluginObs;
+        CActiveSchedulerWait *iWaiter;
+        TBool iDeleteProperty;
+        TBool iBearerAvailable;
+
+        // 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      // USBLOCODPLUGINTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/init/USBLocodPluginTest_ats.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,234 @@
+#
+# 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:   
+#
+
+#
+# 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= USBLocodPluginTest_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= USBLocodPluginTestUSBLocodPluginTestUSBLocodPluginTest
+# 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\USBLocodPluginTest.cfg
+[End_Module]
+
+
+# Load testmoduleUSBLocodPluginTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBLocodPluginTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBLocodPluginTest 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/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/init/USBLocodPluginTest_phone.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,233 @@
+#
+# 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:  
+#
+#
+# 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\USBLocodPluginTest\
+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= USBLocodPluginTestUSBLocodPluginTestUSBLocodPluginTest
+# 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\USBLocodPluginTest.cfg
+[End_Module]
+
+
+# Load testmoduleUSBLocodPluginTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBLocodPluginTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBLocodPluginTest 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/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/LocodBearerPluginObs.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+#include "LocodBearerPluginObs.h"
+
+CLocodBearerPluginObs::CLocodBearerPluginObs( CStifLogger* aLog )
+    {
+    iLog = aLog;
+    }
+
+
+CLocodBearerPluginObs::~CLocodBearerPluginObs()
+    {
+    STIF_LOG( "[STIF_LOG] >>>CLocodBearerPluginObs::~CLocodBearerPluginObs" );
+    
+    if ( iWait -> IsStarted() )
+        iWait -> AsyncStop();
+    delete iWait;
+    iWait = NULL;
+    
+    STIF_LOG( "[STIF_LOG] <<<CLocodBearerPluginObs::~CLocodBearerPluginObs" );
+    }
+
+
+CLocodBearerPluginObs* CLocodBearerPluginObs::NewL( CStifLogger* aLog )
+    {
+    CLocodBearerPluginObs* self = new ( ELeave )CLocodBearerPluginObs( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+void CLocodBearerPluginObs::ConstructL()
+    {
+    STIF_LOG( "[STIF_LOG] >>>CLocodBearerPluginObs::ConstructL" );   
+    iWait = new ( ELeave )CActiveSchedulerWait();    
+    STIF_LOG( "[STIF_LOG] <<<CLocodBearerPluginObs::ConstructL" );
+    }
+
+
+void CLocodBearerPluginObs::NotifyBearerStatus( TLocodBearer aBearer, TBool aStatus )
+    {
+    STIF_LOG( "[STIF_LOG] >>>CLocodBearerPluginObs::NotifyBearerStatus" );
+    if ( iWait -> IsStarted() )
+        iWait -> AsyncStop();
+    iLocodBearerStatus = aStatus;
+    STIF_LOG( "[STIF_LOG] <<<CLocodBearerPluginObs::NotifyBearerStatus" );
+    }
+
+
+void CLocodBearerPluginObs::ActivateObserver( TBool& aLocodBearerStatus )
+    {
+    STIF_LOG( "[STIF_LOG] >>>CLocodBearerPluginObs::ActivateObserver" ); 
+    iWait -> Start();
+    aLocodBearerStatus = iLocodBearerStatus;
+    STIF_LOG( "[STIF_LOG] <<<CLocodBearerPluginObs::ActivateObserver" );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/USBLocodPluginTest.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,227 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "USBLocodPluginTest.h"
+#include <SettingServerClient.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::CUSBLocodPluginTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUSBLocodPluginTest::CUSBLocodPluginTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUSBLocodPluginTest::ConstructL()
+    {
+    //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(KUSBLocodPluginTestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KUSBLocodPluginTestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KUSBLocodPluginTestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    SendTestClassVersion();
+    
+    iDeleteProperty = EFalse;    
+    iSelectedPersProperty = new ( ELeave )RProperty();        
+    TInt res = iSelectedPersProperty -> Attach( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality );
+    switch ( res )
+        {
+        case KErrNotFound:
+            {
+            STIF_LOG( "[STIF_LOG] Define" );
+            iDeleteProperty = ETrue;
+            User::LeaveIfError( RProperty::Define( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, RProperty::EInt ) );
+            break;
+            }
+        case KErrNone:
+            break;
+        default:
+            {
+            STIF_LOG( "[STIF_LOG] RProperty::Attach error" );
+            User::Leave( res );
+            }
+        }
+      
+    iLocodBearerPluginObs = CLocodBearerPluginObs::NewL( iLog );  
+    TLocodBearerPluginParams initParams( TUid::Uid( KFeatureIdUsb ), *iLocodBearerPluginObs );
+    iLocodBearerPlugin = CLocodBearerPlugin::NewL( initParams );
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBLocodPluginTest* CUSBLocodPluginTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CUSBLocodPluginTest* self = new (ELeave) CUSBLocodPluginTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CUSBLocodPluginTest::~CUSBLocodPluginTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+//-----------------------------------------------------------------------------
+// CUSBLocodPluginTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CUSBLocodPluginTest::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("USBLocodPluginTest.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* ) CUSBLocodPluginTest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/tsrc/USBLocodPluginTest/src/USBLocodPluginTestBlocks.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,509 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "USBLocodPluginTest.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CUSBLocodPluginTest::Delete() 
+    {
+    delete iLocodBearerPluginObs;
+    iLocodBearerPluginObs = NULL;
+    
+    delete iLocodBearerPlugin;
+    iLocodBearerPlugin = NULL;
+    if ( iDeleteProperty )
+        RProperty::Delete( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality );
+    
+    iSelectedPersProperty -> Close();
+    delete iSelectedPersProperty;
+    iSelectedPersProperty = NULL;    
+    REComSession::FinalClose();
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CUSBLocodPluginTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+		ENTRY( "ExecuteApiTest", CUSBLocodPluginTest::ExecuteApiTest ),
+        ENTRY( "ExecuteModuleTest", CUSBLocodPluginTest::ExecuteModuleTest ),
+        ENTRY( "ExecuteBranchTest", CUSBLocodPluginTest::ExecuteBranchTest ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::ExecuteApiTest
+// -----------------------------------------------------------------------------
+
+TInt CUSBLocodPluginTest::ExecuteApiTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteApiTest" );
+	
+	TInt res;
+    TUSBLocodPluginTestResult testResult;
+    TPtrC apiTestName( KNullDesC );
+	
+	res = aItem.GetString( _L( "ExecuteApiTest" ), apiTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+		
+	TRAP( res, DoExecuteApiTestL( apiTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteApiTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteApiTest" );
+    return KErrNone;
+    }
+	
+	
+void CUSBLocodPluginTest::DoExecuteApiTestL( TPtrC aApiTestName, TUSBLocodPluginTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteApiTestL" );
+    if ( !aApiTestName.Compare( _L( "InitializationTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: InitializationTestL" );
+        InitializationTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "ImplementatiationIdTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: ImplementatiationIdTestL" );
+        ImplementatiationIdTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "USBPCSuitePersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: USBPCSuitePersonalityTestL" );
+        USBPCSuitePersonalityTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "USBDefaultPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: USBDefaultPersonalityTestL" );
+        USBDefaultPersonalityTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteApiTestL" );
+    }
+
+	
+void CUSBLocodPluginTest::InitializationTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>InitializationTestL" );
+	
+	if( !iLocodBearerPlugin )
+	    {
+	    aTestResult = ETestCaseFailed;
+	    return;
+	    }
+	
+    aTestResult = ETestCasePassed;	
+	STIF_LOG( "[STIF_LOG] <<<InitializationTestL" );
+    }
+
+
+void CUSBLocodPluginTest::ImplementatiationIdTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>ImplementatiationIdTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    
+    TUid implementationUid = TUid::Uid( KFeatureIdUsb );
+    iLog -> Log( _L( "[STIF_LOG] Implementation Uid: %d, expected Uid: %d" ), implementationUid.iUid, iLocodBearerPlugin -> ImplementationUid().iUid );
+    if ( iLocodBearerPlugin -> ImplementationUid() != implementationUid )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;    
+    STIF_LOG( "[STIF_LOG] <<<ImplementatiationIdTestL" );
+    }
+
+
+void CUSBLocodPluginTest::USBPCSuitePersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBPCSuitePersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = ETrue;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbPersonalityIdPCSuite );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus );
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;    
+    STIF_LOG( "[STIF_LOG] <<<USBPCSuitePersonalityTestL" );
+    }
+
+
+void CUSBLocodPluginTest::USBDefaultPersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBDefaultPersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = EFalse;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbDefaultPersonality );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus ); 
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;    
+    STIF_LOG( "[STIF_LOG] <<<USBDefaultPersonalityTestL" );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::ExecuteModuleTest
+// -----------------------------------------------------------------------------	
+
+TInt CUSBLocodPluginTest::ExecuteModuleTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteModuleTest" );
+	
+    TInt res;
+    TUSBLocodPluginTestResult testResult;
+    TPtrC moduleTestName( KNullDesC );
+
+    res = aItem.GetString( _L( "ExecuteModuleTest" ), moduleTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+
+    TRAP( res, DoExecuteModuleTestL( moduleTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteModuleTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteModuleTest" );
+    return KErrNone;
+    }	
+	
+	
+void CUSBLocodPluginTest::DoExecuteModuleTestL( TPtrC aModuleTestName, TUSBLocodPluginTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteModuleTestL" );
+    if ( !aModuleTestName.Compare( _L( "USBMSPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: USBMSPersonalityTestL" );
+        USBMSPersonalityTestL( aTestResult );
+        }
+    else if ( !aModuleTestName.Compare( _L( "USBPTPPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: USBPTPPersonalityTestL" );
+        USBPTPPersonalityTestL( aTestResult );
+        }
+    else if ( !aModuleTestName.Compare( _L( "USBMTPPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: USBMTPPersonalityTestL" );
+        USBMTPPersonalityTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteModuleTestL" );
+    }
+	
+
+void CUSBLocodPluginTest::USBMSPersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBMSPersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = EFalse;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbPersonalityIdMS );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus ); 
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;    
+    STIF_LOG( "[STIF_LOG] <<<USBMSPersonalityTestL" );
+    }
+
+
+void CUSBLocodPluginTest::USBPTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBPTPPersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = EFalse;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbPersonalityIdPTP );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus ); 
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;   
+    STIF_LOG( "[STIF_LOG] <<<USBPTPPersonalityTestL" );
+    }
+
+
+void CUSBLocodPluginTest::USBMTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBMTPPersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = EFalse;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbPersonalityIdMTP );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus ); 
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;  
+    STIF_LOG( "[STIF_LOG] <<<USBMTPPersonalityTestL" );
+    }
+	
+
+// -----------------------------------------------------------------------------
+// CUSBLocodPluginTest::ExecuteBranchTest
+// -----------------------------------------------------------------------------
+	
+TInt CUSBLocodPluginTest::ExecuteBranchTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteBranchTest" );
+	
+    TInt res;
+    TUSBLocodPluginTestResult testResult;
+    TPtrC branchTestName( KNullDesC );
+
+    res = aItem.GetString( _L( "ExecuteBranchTest" ), branchTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+
+    TRAP( res, DoExecuteBranchTestL( branchTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteBranchTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteBranchTest" );
+    return KErrNone;
+    }
+
+	
+void CUSBLocodPluginTest::DoExecuteBranchTestL( TPtrC aBranchTestName, TUSBLocodPluginTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteBranchTestL" );
+    if ( !aBranchTestName.Compare( _L( "USBPCSuiteMTPPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Branch test type: USBPCSuiteMTPPersonalityTestL" );
+        USBPCSuiteMTPPersonalityTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Branch test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteBranchTestL" );
+    }
+	
+	
+void CUSBLocodPluginTest::USBPCSuiteMTPPersonalityTestL( TUSBLocodPluginTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>USBPCSuiteMTPPersonalityTestL" );
+    
+    User::LeaveIfNull( iLocodBearerPlugin );
+    TBool expectedLocodBearerStatus = ETrue;
+    TBool returnedLocodBearerStatus;
+    TInt res = iSelectedPersProperty -> Set( KUsbPersonalityIdPCSuiteMTP );
+    iLog -> Log( _L( "[STIF_LOG] Set selected personality property result: %d" ), res );
+    if ( res != KErrNone )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    iLocodBearerPluginObs -> ActivateObserver( returnedLocodBearerStatus ); 
+    
+    iLog -> Log( _L( "[STIF_LOG] Expected locod bearer status: %d, returned status: %d" ), 
+                                        expectedLocodBearerStatus, returnedLocodBearerStatus );
+    if ( returnedLocodBearerStatus != expectedLocodBearerStatus )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+
+    aTestResult = ETestCasePassed;    
+    STIF_LOG( "[STIF_LOG] <<<USBPCSuiteMTPPersonalityTestL" );
+    }
+	
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/bwins/usbotgwatcheru.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,5 @@
+EXPORTS
+	?IsDeviceA@CUsbOtgWatcher@@QAEHXZ @ 1 NONAME ; int CUsbOtgWatcher::IsDeviceA(void)
+	??1CUsbOtgWatcher@@UAE@XZ @ 2 NONAME ; CUsbOtgWatcher::~CUsbOtgWatcher(void)
+	?NewL@CUsbOtgWatcher@@SAPAV1@AAVRUsb@@@Z @ 3 NONAME ; class CUsbOtgWatcher * CUsbOtgWatcher::NewL(class RUsb &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/eabi/usbotgwatcheru.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN14CUsbOtgWatcher4NewLER4RUsb @ 1 NONAME
+	_ZN14CUsbOtgWatcher9IsDeviceAEv @ 2 NONAME
+	_ZTI14CUsbOtgWatcher @ 3 NONAME ; #<TI>#
+	_ZTI16CUsbNotifManager @ 4 NONAME ; #<TI>#
+	_ZTIN16CUsbNoteNotifier15CNotifierActiveE @ 5 NONAME ; #<TI>#
+	_ZTV14CUsbOtgWatcher @ 6 NONAME ; #<VT>#
+	_ZTV16CUsbNotifManager @ 7 NONAME ; #<VT>#
+	_ZTVN16CUsbNoteNotifier15CNotifierActiveE @ 8 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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:  Build information file for project usbotgwatcher
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+usbotgwatcher.mmp
+
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+
+../rom/usbotgwatcher.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbotgwatcher.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/group/usbotgwatcher.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* 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 usbotgwatcher
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET                  usbotgwatcher.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x2000AFFF
+
+CAPABILITY   LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ CommDD	
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+
+SOURCE                  cusbtimer.cpp
+
+SOURCE                  cusbidpinobserver.cpp
+SOURCE                  cusbvbusobserver.cpp
+SOURCE                  cusbotgstateobserver.cpp
+SOURCE                  cusbhosteventnotificationobserver.cpp
+SOURCE                  cusbmessagenotificationobserver.cpp
+SOURCE                  cusbbusactivityobserver.cpp
+
+SOURCE                  cusbotgwatcher.cpp
+SOURCE                  cusbservicecontrol.cpp
+
+SOURCE                  cusbstate.cpp
+SOURCE                  cusbstatehostabase.cpp
+SOURCE                  cusbstatehostainitiate.cpp
+SOURCE                  cusbstatehostahost.cpp
+SOURCE                  cusbstatehostaperipheral.cpp
+SOURCE                  cusbstatehosthandle.cpp
+SOURCE                  cusbstatehostdelayhandle.cpp
+SOURCE                  cusbstatehostdelayattachedhandle.cpp
+SOURCE                  cusbstatehostdelaynotattachedhandle.cpp
+SOURCE                  cusbstatehosthandledropping.cpp
+SOURCE                  cusbstatehostundefined.cpp
+
+SOURCE                  cusbwaitnotifier.cpp
+SOURCE                  cusbnotifmanager.cpp
+SOURCE                  cusbnotifier.cpp 
+SOURCE                  cusbnotenotifier.cpp 
+SOURCE                  cusbwarningnotifier.cpp 
+SOURCE                  cusbindicatornotifier.cpp
+
+USERINCLUDE             ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 euser.lib
+LIBRARY                 usbman.lib
+#if defined(MARM_ARMV5)
+LIBRARY                 usbdescriptors.lib
+LIBRARY                 usbdi_utils.lib
+#endif
+LIBRARY                 aknnotify.lib
+
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbbusactivityobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,139 @@
+/*
+ * 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:  Monitors USB activity
+ *
+ */
+
+#ifndef C_USBBUSACTIVITYOBSERVER_H
+#define C_USBBUSACTIVITYOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+/**
+ *  This interface has to be implemented by observer
+ *  to receive notifications from USB bus activity property
+ */
+NONSHARABLE_CLASS(MUsbBusActivityObserver)
+    {
+public:
+
+    /**
+     * Called when bus turn to idle
+     */
+    virtual void BusIdleL() = 0;
+
+    /**
+     * Called when when bus is in Idle, and some activity appears on the bus
+     */
+    virtual void BusActiveL() = 0;
+
+    /**
+     * Called when when error happened
+     * @param aError errorcode
+     */
+    virtual void BusActivityErrorL(TInt aError) = 0;
+
+    };
+
+/**
+ *  Class observes USB OTG State property
+ *
+ */
+NONSHARABLE_CLASS(CUsbBusActivityObserver) : public CActive
+    {
+
+public:
+
+    enum TBusActivity
+        {
+        EBusIdle = 0, EBusActive = 1
+        };
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbBusActivityObserver* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbBusActivityObserver();
+
+    /**
+     * Returns bus activity state
+     * @return bus activity
+     */
+    TBusActivity BusActivity();
+
+    /**
+     * Adds subscriber for the notification
+     * @param aObserver Observer
+     */
+    void SubscribeL(MUsbBusActivityObserver& aObserver);
+
+    /**
+     * Removes observer
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbBusActivityObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Called when request on bus activity completed
+     */
+    void RunL();
+
+    /**
+     * Called by framwork, when canceling outstanding request
+     */
+    void DoCancel();
+
+    /**
+     * Called when RunL leaves
+     * @param aError error code
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor
+     */
+    CUsbBusActivityObserver();
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * The observer reports state changes to own observers
+     * Not owns
+     */
+    RPointerArray<MUsbBusActivityObserver> iObservers;
+
+    /**
+     * The observer observes property change
+     */
+    RProperty iBusActivity;
+
+    };
+
+#endif //  C_USBOTGSTATEOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,161 @@
+/*
+ * 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:  Monitors host events
+ *
+ */
+
+#ifndef C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
+#define C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include <usbotgdefs.h>
+#include <usbhostdefs.h>
+
+class RUsb;
+
+/**
+ *  Observer must implement this interface to get notifications
+ *
+ */
+NONSHARABLE_CLASS( MUsbHostEventNotificationObserver)
+    {
+public:
+
+    /**
+     *  Called when device is attached
+     *  @param aInfo additional information
+     */
+    virtual void DeviceAttachedL(TDeviceEventInformation aInfo) = 0;
+
+    /**
+     *  Called when device is detached
+     *  @param aInfo additional information
+     */
+    virtual void DeviceDetachedL(TDeviceEventInformation aInfo) = 0;
+
+    /**
+     *  Called when drivers are loaded
+     *  @param aInfo additional information
+     */
+    virtual void DriverLoadSuccessL(TDeviceEventInformation aInfo) = 0;
+
+    /**
+     *  Called when drivers are loaded partially
+     *  @param aInfo additional information
+     */
+    virtual void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo) = 0;
+
+    /**
+     *  Called when drivers loading failed
+     *  @param aInfo additional information
+     */
+    virtual void DriverLoadFailureL(TDeviceEventInformation aInfo) = 0;
+
+    /**
+     *  Called when error happens while observing
+     *  @param aError error code
+     */
+    virtual void HostEventNotificationErrorL(TInt aError) = 0;
+
+    };
+
+/**
+ *  Class observes USB Notifications
+ */
+NONSHARABLE_CLASS( CUsbHostEventNotificationObserver ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUsb usbman
+     * @return this class instance
+     */
+    static CUsbHostEventNotificationObserver* NewL(RUsb* aUsb);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbHostEventNotificationObserver();
+
+    /**
+     * Add observer to list of observers
+     * @param aObserver observer
+     */
+    void SubscribeL(MUsbHostEventNotificationObserver& aObserver);
+
+    /**
+     * Removes observer from list of observers 
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbHostEventNotificationObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Called when request completed
+     */
+    void RunL();
+
+    /**
+     * Called when outstanding request cancelled
+     */
+    void DoCancel();
+
+    /**
+     * Called when RunL leaves
+     * @param aError errorcode from RunL
+     * @return aError errorcode
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor.
+     * @param aUsb usbman
+     */
+    CUsbHostEventNotificationObserver(RUsb* aUsb);
+
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * The observer reports changes to own observers
+     * Not owns
+     */
+    RPointerArray<MUsbHostEventNotificationObserver> iObservers;
+
+    /**
+     * Notifications come from USB
+     * Not own
+     */
+    RUsb* iUsb;
+
+    /**
+     * Info from notification comes to this member
+     */
+    TDeviceEventInformation iEventInfo;
+
+    };
+
+#endif //  C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbidpinobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,140 @@
+/*
+ * 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:  Monitors ID pin change
+ *
+ */
+
+#ifndef C_USBIDPINOBSERVER_H
+#define C_USBIDPINOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+/**
+ *  Obserber has to implement this interface to get ID Pin change notifications
+ *
+ */
+NONSHARABLE_CLASS( MUsbIdPinObserver)
+    {
+public:
+
+    /**
+     * IdPin disappeared
+     */
+    virtual void IdPinOffL() = 0;
+
+    /**
+     * IdPin appeared
+     */
+    virtual void IdPinOnL() = 0;
+
+    /**
+     * IdPin error
+     * @param aError error code
+     */
+    virtual void IdPinErrorL(TInt aError) = 0;
+
+    };
+
+/**
+ *  Class observes ID-PIN property
+ *
+ */
+NONSHARABLE_CLASS( CUsbIdPinObserver) : public CActive
+    {
+
+public:
+    enum TState
+        {
+        EIdPinOff = 0, EIdPinOn = 1
+        };
+
+    /**
+     * Two-phased constructor.
+     * @return instance of the objects of this class
+     */
+    static CUsbIdPinObserver* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbIdPinObserver();
+
+    /**
+     * Returns current state of the IdPin
+     * @return state
+     */
+    TState IdPin() /*  not const - read comment in cpp*/;
+
+    /**
+     * Add observer
+     * @param aObserver Observer
+     */
+    void SubscribeL(MUsbIdPinObserver& aObserver);
+
+    /**
+     * Remove observer
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbIdPinObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Request completed
+     */
+    void RunL();
+
+    /**
+     * Request cancelled
+     */
+    void DoCancel();
+
+    /**
+     * RunL leaved
+     * @param errorcode from RunL
+     * @return errorcode
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor.
+     */
+    CUsbIdPinObserver();
+
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     *  The observer reports state changes to its own observers
+     * Not own
+     */
+    RPointerArray<MUsbIdPinObserver> iObservers;
+
+    /**
+     * The observer observes property change
+     */
+    RProperty iIdPin;
+
+    };
+
+#endif //  C_USBIDPINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbindicatornotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,137 @@
+/*
+ * 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:  Blink/show Usb indicator notifier implementation
+ *
+ */
+
+#ifndef C_USBINDICATORNOTIFIER_H
+#define C_USBINDICATORNOTIFIER_H
+
+#include <e32base.h>
+#include <AknNotifyStd.h>       // SAknSmallIndicatorParams
+#include <AknNotifySignature.h> // SAknNotifierPackage
+#include <avkon.hrh>            // EAknIndicatorUSBConnection
+
+#include "cusbnotifier.h"
+#include "cusbvbusobserver.h"
+#include "cusbotgwatcher.h"
+
+/**
+ * Class implements functionality of showing/blinking usb indicator
+ * Class does not provide method to get response from the user
+ */
+NONSHARABLE_CLASS( CUsbIndicatorNotifier ): public CUsbNotifier, MUsbOtgWatcherStateObserver, MUsbVBusObserver
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * @param aNotifManager parent
+     * @param aOtgWatcher provides VBus observer and usb otg watcher state notifications
+     * @return Pointer to the new instance of CUsbIndicatorNotifier
+     */
+    static CUsbIndicatorNotifier* NewL(CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbIndicatorNotifier();
+
+    // From MUsbOtgWatcherStateObserver
+    /**
+     * Otg Watcher state changed call back
+     * @param aState new state
+     */
+    virtual void OtgWatcherStateChangedL(TUsbStateIds aState);
+
+    // From MUsbVBusObserver
+    /**
+     * VBus down event received
+     */
+    virtual void VBusDownL();
+    /**
+     * VBus up event received
+     */
+    virtual void VBusUpL();
+    /**
+     * error handler
+     * @param aError error code
+     */
+    virtual void VBusObserverErrorL(TInt aError);
+
+    // From base class CUsbNotifier
+    /**
+     * Start to show notifier
+     */
+    virtual void ShowL();
+
+    /**
+     * Stop showing notifier
+     */
+    virtual void Close();
+
+private:
+
+    /**
+     * Default constructor.
+     * @param aNotifManger parent
+     * @param aOtgWatcher Otg watcher
+     */
+    CUsbIndicatorNotifier(CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher);
+
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Set USB indicator On or Off
+     * @param aState Indicator states 
+     */
+    void SetIndicatorStateL(const TInt aState);
+
+    /**
+     * Show/hide static icon of the indicator. 
+     * If the indicator is blinking, stop blinking it and show/hide the static 
+     * form of the indicator.
+     * @param aVisible ETrue - Show the indicator, EFalse - Hide the indicator 
+     */
+    void ShowStaticL(TBool aVisible);
+
+    /**
+     * Blinks indicator
+     */
+    void BlinkL();
+
+    /**
+     * Sets indicator accordingly
+     */
+    void SetIndicatorL();
+
+private:
+    // data
+
+    /**
+     * OtgWatcher
+     * not own
+     */
+    CUsbOtgWatcher& iOtgWatcher;
+
+    /**
+     * Current indicator state
+     */
+    TInt iIndicatorState;
+
+    };
+
+#endif // C_USBINDICATORNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbmessagenotificationobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,158 @@
+/*
+ * 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:  Observes notifications from usb
+ *
+ */
+
+#ifndef C_USBMESSAGENOTIFICATIONOBSERVER_H
+#define C_USBMESSAGENOTIFICATIONOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include <usbotgdefs.h>
+
+class RUsb;
+
+/**
+ * Class implements functionality of showing/blinking usb indicator
+ * Class does not provide method to get response from the user
+ */
+NONSHARABLE_CLASS( MUsbMessageNotificationObserver)
+    {
+public:
+
+    /**
+     * Call back on message notification
+     * @param aMessage Message id
+     */
+    virtual void MessageNotificationReceivedL(TInt aMessage) = 0;
+
+    /**
+     * Called when BadHubPosition error happen
+     */
+    virtual void BadHubPositionL() = 0;
+
+    /**
+     * Callen if VBus error happen
+     */
+    virtual void VBusErrorL() = 0;
+
+    /**
+     * Called when SRP request received
+     */
+    virtual void SrpReceivedL() = 0;
+
+    /**
+     * Called when session requested
+     */
+    virtual void SessionRequestedL() = 0;
+
+    /**
+     * Called when error happened
+     * @param aError error code
+     */
+    virtual void MessageNotificationErrorL(TInt aError) = 0;
+    };
+
+/**
+ *  Class observes USB Notifications
+ *
+ */
+NONSHARABLE_CLASS( CUsbMessageNotificationObserver ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUsb usbman
+     */
+    static CUsbMessageNotificationObserver* NewL(RUsb* aUsb);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbMessageNotificationObserver();
+
+    /**
+     * Subscribes for notifications
+     * @param aObserver observer
+     */
+    void SubscribeL(MUsbMessageNotificationObserver& aObserver);
+
+    /**
+     * Unsubscribe from notifications
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbMessageNotificationObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Called by framework when outstanding request completed
+     *
+     */
+    void RunL();
+
+    /**
+     * Called when outstanding request camcelled
+     *
+     */
+    void DoCancel();
+
+    /**
+     * Called when RunL leaves
+     *
+     * @param aError error id
+     * @return error id 
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor
+     * @param aUsb usbman
+     */
+    CUsbMessageNotificationObserver(RUsb* aUsb);
+
+    /**
+     * Second phase construction
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * The observer reports to own observers
+     * Not owns
+     */
+    RPointerArray<MUsbMessageNotificationObserver> iObservers;
+
+    /**
+     * Notifications come from USB
+     * Not own
+     */
+    RUsb* iUsb;
+
+    /**
+     * Info from notification comes to this member
+     */
+    TInt iMessage;
+
+    };
+
+#endif //  C_USBMESSAGENOTIFICATIONOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbnotenotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,153 @@
+/*
+ * 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:  Base classes for Usb notifier wrapper  
+ *
+ */
+
+#ifndef C_CUSBNOTENOTIFIER_H
+#define C_CUSBNOTENOTIFIER_H
+
+#include <e32base.h>
+#include "cusbnotifier.h"
+
+class CUsbNotifManager;
+class RNotifier;
+
+/**
+ * Base class of wrapper for showing RNotifier note.
+ * Class implements showing note notifier by RNotifier API in asynchronized way 
+ * which doesn't block the caller. When user gives some feedback on the note, 
+ * the event will be forwarded to CUsbNotifManager and it does some handling.
+ */
+NONSHARABLE_CLASS( CUsbNoteNotifier) : public CUsbNotifier
+    {
+    /**
+     * Active object of asynchronous showing notifier 
+     */
+    class CNotifierActive : public CActive
+        {
+    public:
+        /**
+         * Default constructor
+         * @param aNotifier RNotifier API
+         * @param aUsbNoteNotifier the note notifier container
+         */
+        CNotifierActive(RNotifier& aNotifier, CUsbNoteNotifier& aUsbNoteNotifier);
+
+        /**
+         * Destructor
+         */
+        virtual ~CNotifierActive();
+
+        /**
+         * Start to show the notifier
+         */
+        void StartL();
+
+    protected:
+        // From base class CActive
+        /**
+         * Caled when outstanding request completed
+         */
+        void RunL();
+
+        /**
+         * Called when outstanding request cancelled
+         */
+        void DoCancel();
+
+        /**
+         * Called when RunL leaves   
+         * @param aError errorcode
+         * @return errorcode 
+         */
+        TInt RunError(TInt aError);
+
+    private:
+        // data
+
+        /**
+         * The note notifier container 
+         * Not Own 
+         */
+        CUsbNoteNotifier& iUsbNoteNotifier;
+
+        /**
+         * RNotifier API
+         * Not Own 
+         */
+        RNotifier& iNotifier;
+
+            /**
+             * Response from notifier 
+             */
+            TPckg<TInt> iRes;
+            
+            /**
+             * Notifier id pckg buffer
+             */
+            TPckgBuf<TInt> iNotifIdPckg;
+        };
+public:
+
+    /**
+     * Destructor
+     */
+    virtual ~CUsbNoteNotifier();
+
+    //From base class CUsbNotifier
+    /**
+     * Start to show notifier
+     */
+    virtual void ShowL();
+
+    /**
+     * Stop showing notifier
+     */
+    virtual void Close();
+
+protected:
+
+    /**
+     * Default constructor
+     * @param aNotifier RNotifier API
+     * @param aNotifManager Manager
+     * @param acat Category
+     * @param aNotidId id 
+     */
+    CUsbNoteNotifier(RNotifier& aNotifier, CUsbNotifManager& aNotifManager,
+            TUid aCat, TUint aNotifId);
+
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * Active object of handling RNotifier instance
+     * Own 
+     */
+    CNotifierActive* iNotifierActive;
+
+    /**
+     * RNotifier API
+     * Not Own 
+     */
+    RNotifier& iNotifier;
+    };
+
+#endif // C_CUSBNOTENOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,98 @@
+/*
+ * 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:  Base classes for Usb notifier wrapper  
+ *
+ */
+
+#ifndef C_CUSBNOTIFIER_H
+#define C_CUSBNOTIFIER_H
+
+#include <e32base.h>
+
+class CUsbNotifManager;
+
+/**
+ * Base class for usb notifiers.
+ * Define primitive methods needed for all kinds of notifiers such as Avkon 
+ * informative note, feedback-needed note, usb indicator etc.
+ * Some notifier needs feedback input from end-user such as waiting note, some 
+ * of them don't such as informative note and usb indicator. 
+ */
+NONSHARABLE_CLASS( CUsbNotifier) : public CBase
+    {
+public:
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbNotifier();
+
+    /**
+     * Start to show notifier
+     */
+    virtual void ShowL() = 0;
+
+    /**
+     * Stop showing notifier
+     */
+    virtual void Close() = 0;
+
+    /**
+     * Getter for returning if the notifier needs input from end-user
+     * @return ETrue-user feedback needed, EFalse-user feedback not needed. 
+     */
+    TBool IsFeedbackNeeded() const;
+
+protected:
+
+    /**
+     * Default constructor
+     * @param aNotifManager manager
+     * @param acat Category
+     * @param aNotidId id 
+     */
+    CUsbNotifier(CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId);
+
+    /**
+     * Set by child-class if the concrete notifier needs feedback from end-user
+     */
+    void SetFeedbackNeeded();
+
+protected:
+    //data
+
+    /**
+     * The manager of all usb notifieres.
+     * All notifiers are created, destroied and manupulated by the manager.  
+     * Not own 
+     */
+    CUsbNotifManager& iNotifManager;
+
+    /**
+     * Category of the notifier. Needed for cancelling 
+     */
+    TUid iCat;
+
+    /**
+     * The identifier of the notifier
+     */
+    TUint iNotifId;
+
+    /**
+     * If the notifier needs feedback from end-user. 
+     */
+    TBool iIsFeedbackNeeded;
+
+    };
+
+#endif // C_CUSBNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbnotifmanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,184 @@
+/*
+ * 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:  Manages notifiers
+ *
+ */
+
+#ifndef C_USBNOTIFMANAGER_H
+#define C_USBNOTIFMANAGER_H
+
+#include <e32base.h>
+
+// forward declaration
+class CUsbNotifier;
+class CUsbIndicatorNotifier;
+class CUsbOtgWatcher;
+
+// pause warning is visible for (ms)
+const TUint KPauseForWarnings = 1000000; // 1 sec
+
+/**
+ * Observer has to implement this interface to get feedback on user action
+ * Notification received when Whait notified completed (cancelled ot key pressed) 
+ */
+NONSHARABLE_CLASS( MWaitNotifierObserver)
+    {
+public:
+
+    /**
+     * feedback to observer
+     * @param aFeedback how notifier comleted 
+     */
+    virtual void WaitNotifierCompletedL(TInt aFeedback) = 0;
+    };
+
+/**
+ * this class contains information for wait notifier
+ * once notifier gets response from user, notif manager will send feedback data to caller
+ */
+NONSHARABLE_CLASS( CWaitNotifierInfo ) : public CBase
+    {
+public:
+
+    /**
+     * 2-phase construction
+     * @param aWaitNotifier owner
+     * aObserver will receive notification when completed 
+     */
+    static CWaitNotifierInfo* NewL(CUsbNotifier* aWaitNotifier,
+            MWaitNotifierObserver& aObserver);
+
+    /**
+     * Destructor
+     */
+    virtual ~CWaitNotifierInfo();
+
+    /**
+     * gets wait notifier
+     */
+    CUsbNotifier* WaitNotifier() const;
+
+    /**
+     * gets observer
+     */
+    MWaitNotifierObserver* Observer() const;
+
+private:
+
+    /**
+     * Default constructor
+     * @param aWaitNotifier Notifier
+     * @param aObserver Observer
+     */
+    CWaitNotifierInfo(CUsbNotifier* aWaitNotifier,
+            MWaitNotifierObserver& aObserver);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * notifier
+     * owns
+     */
+    CUsbNotifier* iWaitNotifier;
+
+    /**
+     * observer
+     * not owns
+     */
+    MWaitNotifierObserver& iObserver;
+    };
+
+/**
+ *  Function of the class is own and share RNotifier, own list of CWaitNotifier(s),
+ *	show notifiers, which are synchronous, and cancel it with a delay 
+ */
+class CUsbNotifManager : public CBase
+    {
+    friend class CUsbNotifManager;
+
+public:
+
+    /**
+     * 2phase construction
+     * @param aOtgWatcher OtgWatcher is a parent class
+     */
+    static CUsbNotifManager* NewL(CUsbOtgWatcher& aOtgWatcher);
+
+    /**
+     * Destructor
+     */
+    virtual ~CUsbNotifManager();
+
+    /**
+     * Shows notifier
+     * @param aCat Category
+     * @param aNotifId notifier id
+     * @param aObserver will receive notifications
+     */
+    void ShowNotifierL(TUid aCat, TUint aNotifId,
+            MWaitNotifierObserver* aObserver);
+
+    /**
+     * Closes and deletes all the notifiers
+     */
+    void CloseAllNotifiers();
+
+    /** 
+     * Calls back Notifier show is over
+     * @param aWaitNotifier wait notifier
+     * @param aResult result (was any errors or not)
+     * @param aFeedback user press (cancel or any other) 
+     */
+    void NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult,
+            TInt aFeedback);
+
+private:
+
+    /**
+     * Default construction
+     * @param aOtgWatcher otg watcher (parent class)
+     */
+    CUsbNotifManager();
+
+    /**
+     * Second phase construction
+     */
+    void ConstructL(CUsbOtgWatcher& aOtgWatcher);
+
+private:
+    // data
+
+    /**
+     * RNotifier API
+     */
+    RNotifier iNotifier;
+
+    /**
+     * List of notifiers waiting for user action
+     */
+    RPointerArray<CWaitNotifierInfo> iWaitNotifiers;
+
+    /**
+     * Own
+     * USB indicator
+     */
+    CUsbIndicatorNotifier* iIndicatorNotifier;
+    };
+
+#endif // C_USBNOTIFMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbotgstateobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,164 @@
+/*
+ * 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:  Observes OTG states
+ *
+ */
+
+#ifndef C_USBOTGSTATEOBSERVER_H
+#define C_USBOTGSTATEOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include <usbotgdefs.h>
+
+/**
+ *  Observer need to implement this interface to get OTG state change notifications
+ */
+NONSHARABLE_CLASS( MUsbOtgStateObserver)
+    {
+public:
+
+    /**
+     * Local device is A, and get to Idle state
+     */
+    virtual void AIdleL() = 0;
+
+    /**
+     * Local device is A, and get to Host state
+     */
+    virtual void AHostL() = 0;
+
+    /**
+     * Local device is A, and get to Peripheral state
+     */
+    virtual void APeripheralL() = 0;
+
+    /**
+     * Local device is A, and get VBus error
+     */
+    virtual void AVBusErrorL() = 0;
+
+    /**
+     * Local device is B, and get to Idle state
+     */
+    virtual void BIdleL() = 0;
+
+    /**
+     * Local device is B, and get to Peripheral state
+     */
+    virtual void BPeripheralL() = 0;
+
+    /**
+     * Local device is B, and get to Host state
+     */
+    virtual void BHostL() = 0;
+
+    /**
+     * Error handler
+     * @param aError error code
+     */
+    virtual void OtgStateErrorL(TInt aError) = 0;
+    };
+
+/**
+ *  Class observes OTG State property
+ *
+ */
+NONSHARABLE_CLASS( CUsbOtgStateObserver ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbOtgStateObserver* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbOtgStateObserver();
+
+    /**
+     * Gets current OTG state
+     * @return OTG state
+     */
+    TUsbOtgState OtgState();
+
+    /**
+     * Subscribes for getting notifications
+     * @param aObserver Observer
+     */
+    void SubscribeL(MUsbOtgStateObserver& aObserver);
+
+    /**
+     * Unsubscribes from getting notifications
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbOtgStateObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Called when outstanding request completed
+     *
+     */
+    void RunL();
+
+    /**
+     * Called when outstanding request is cancelled
+     *
+     */
+    void DoCancel();
+
+    /**
+     * Called when RunL leaves
+     *
+     * @param errorcode
+     * @return errorcode
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor
+     *
+     */
+    CUsbOtgStateObserver();
+
+    /**
+     * Second phase construction
+     *
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * The observer reports state changes to own observers
+     * Not owns
+     */
+    RPointerArray<MUsbOtgStateObserver> iObservers;
+
+    /**
+     * The observer observes property change
+     */
+    RProperty iOtgState;
+
+    };
+
+#endif //  C_USBOTGSTATEOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbotgwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,512 @@
+/*
+ * 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:  OTG watcher state machine owner
+ *
+ */
+
+#ifndef C_USBOTGWATCHER_H
+#define C_USBOTGWATCHER_H
+
+#include <e32base.h>
+
+#include <usbotgdefs.h>
+
+#include "definitions.h"  
+
+#ifndef STIF
+#include <usbman.h>
+#include "cusbidpinobserver.h"
+#include "cusbvbusobserver.h"
+#include "cusbotgstateobserver.h"
+#include "cusbbusactivityobserver.h"
+#include "cusbhosteventnotificationobserver.h"
+#include "cusbmessagenotificationobserver.h"
+#else
+#include "mockusbman.h"
+#include "mockcusbidpinobserver.h"
+#include "mockcusbvbusobserver.h"
+#include "mockcusbotgstateobserver.h"
+#include "mockcusbbusactivityobserver.h"
+#include "mockcusbhosteventnotificationobserver.h"
+#include "mockcusbmessagenotificationobserver.h"
+#endif
+
+#include "cusbservicecontrol.h" 
+
+class CUsbState;
+class CUsbStateHostHandle;
+
+class CUsbNotifManager;
+
+/**
+ * Observers for usb otg watcher state nachine
+ * Observers gets feedback by implementing this interface
+ */
+class MUsbOtgWatcherStateObserver
+    {
+
+public:
+
+    /**
+     * Observer must implement this interface
+     * which is called back when state changes
+     * @param aState new state id
+     */
+    virtual void OtgWatcherStateChangedL(TUsbStateIds aState) = 0;
+    };
+
+/**
+ *  UsbWatcher main class
+ *  Implements states machines and owns them
+ *
+ */
+class CUsbOtgWatcher : public CBase,
+        MUsbIdPinObserver,
+        MUsbVBusObserver,
+        MUsbOtgStateObserver,
+        MUsbBusActivityObserver,
+        MUsbHostEventNotificationObserver,
+        MUsbMessageNotificationObserver,
+        MUsbServiceControlObserver
+    {
+
+    // Making CUsbState friend secures changing states
+    // Methods to change state to be called only by CUsbStates children
+    friend class CUsbState;
+    friend class CtUsbOtgWatcher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUsb usbman API
+     */
+    IMPORT_C
+    static CUsbOtgWatcher* NewL(RUsb& aUsb);
+
+    /**
+     * Check ID-Pin state
+     * @return ETrue if the ID-Pin is present (A-Device)
+     */
+    IMPORT_C
+    TBool IsDeviceA();
+
+    /**
+     * Destructor.
+     */
+    IMPORT_C virtual ~CUsbOtgWatcher();
+
+    /**
+     * Sets personality
+     * @param aStatus for async. request
+     * @param aPersonalityID to be set
+     */
+    void SetPersonalityL(TRequestStatus& aStatus, TInt aPersonalityID);
+
+    /**
+     * Cancels setting personality async.
+     */
+    void CancelSetPersonalityL();
+
+    /**
+     *
+     * Sets previous personality
+     * @param aStatus Asynchronously
+     */
+    void SetPreviousPersonalityL(TRequestStatus& aStatus);
+
+    /**
+     * Sets previous personality
+     */
+    void SetPreviousPersonalityL();
+
+    /**
+     * Cancels async. set prev personality request
+     */
+    void CancelSetPreviousPersonalityL();
+
+    /**
+     * Sets prev. personality on disconnecting device
+     */
+    void SetPreviousPreviousPersonalityOnDisconnectL();
+
+    /**
+     * Policy for session start defined here
+     */
+    TBool CanStartSessionL();
+
+    /********************************************************************************/
+    // Events from observers come here
+
+    // From IdPin observer
+    /**
+     * Id Pin OFF
+     */
+    void IdPinOffL();
+    /**
+     * Id Pin On
+     */
+    void IdPinOnL();
+    /**
+     * Id Pin On
+     * @param aError
+     */
+    void IdPinErrorL(TInt aError);
+
+    // From VBus observer
+    /**
+     * VBus down
+     */
+    void VBusDownL();
+    /**
+     * VBus UP
+     */
+    void VBusUpL();
+    /**
+     * VBus observer error
+     * @param aError error code
+     */
+    void VBusObserverErrorL(TInt aError);
+
+    // From OTG state observer
+    /**
+     * Became to Idle when A
+     */
+    void AIdleL();
+    /**
+     * Became a Host when A
+     */
+    void AHostL();
+    /**
+     * Became a peripheral when A
+     */
+    void APeripheralL();
+    /**
+     * VBus error happen
+     */
+    void AVBusErrorL();
+    /**
+     * Became to Idle when B
+     */
+    void BIdleL();
+    /**
+     * Became a peripheral when B
+     */
+    void BPeripheralL();
+    /**
+     * Became a Host when B
+     */
+    void BHostL();
+
+    /**
+     * Error handler
+     * @param aError error code
+     */
+    void OtgStateErrorL(TInt aError);
+
+    // From bus activity observer
+    /**
+     * Bus is in idle
+     */
+    void BusIdleL();
+    /**
+     * Bus active
+     */
+    void BusActiveL();
+    /**
+     * error
+     * @param aError error happened
+     */
+    void BusActivityErrorL(TInt aError);
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    void DeviceAttachedL(TDeviceEventInformation aInfo);
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DeviceDetachedL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers successfully loaded
+     * @param aInfo Device event data
+     */
+    void DriverLoadSuccessL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers loaded partially
+     * @param aInfo Device event data
+     */
+    void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers loading failed
+     * @param aInfo Device event data
+     */
+    void DriverLoadFailureL(TDeviceEventInformation aInfo);
+    /**
+     * Error happened during observing
+     * @param aError error code
+     */
+    void HostEventNotificationErrorL(TInt aError);
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMassage message id
+     */
+    void MessageNotificationReceivedL(TInt aMessage);
+    /**
+     * Connected to hub in wrong level 
+     */
+    void BadHubPositionL();
+    /**
+     * VBus error happened
+     */
+    void VBusErrorL();
+    /**
+     * SRP request received
+     */
+    void SrpReceivedL();
+    /**
+     * Session request received
+     */
+    void SessionRequestedL();
+    /**
+     * Error handler
+     * @param error code
+     */
+    void MessageNotificationErrorL(TInt aError);
+
+    // From CUsbServiceControl
+    /**
+     * called when request for usb services is completed
+     * if there were few requests in a row, during operation, 
+     * only the last one's completion is notified
+     * @param aError error code
+     */
+    void UsbServiceControlReqCompletedL(TInt aError);
+
+    /******************************************************************************* */
+
+    // getters 
+
+    /**
+     * @return IdPin observer 
+     */
+    CUsbIdPinObserver* IdPinObserver() const;
+    /**
+     * @return VBus observer 
+     */
+    CUsbVBusObserver* VBusObserver() const;
+    /**
+     * @return OTG state observer 
+     */
+    CUsbOtgStateObserver* OtgStateObserver() const;
+    /**
+     * @return Bus Activity observer 
+     */
+    CUsbBusActivityObserver* BusActivityObserver() const;
+    /**
+     * @return HostEvent notification observer 
+     */
+    CUsbHostEventNotificationObserver* HostEventNotificationObserver() const;
+    /**
+     * @return Message notification observer 
+     */
+    CUsbMessageNotificationObserver* MessageNotificationObserver() const;
+    /**
+     * @return usbman
+     */
+    RUsb& Usb();
+    /**
+     * @return current device state 
+     */
+    CUsbState* CurrentState() const;
+    /**
+     * @return current host state 
+     */
+    CUsbState* CurrentHostState() const;
+    /**
+     * @param aStateId State Id
+     * @return state object by its id 
+     */
+    CUsbState* State(TUsbStateIds aStateId) const;
+    /**
+     * @return notif manager
+     */
+    CUsbNotifManager* NotifManager();
+    /**
+     * @return Handle state 
+     * @param aStateId state id 
+     */
+    CUsbStateHostHandle* HostHandle(TUsbStateIds aStateId) const;
+
+    /**
+     * Handles problems in host functioning
+     * @param aWhatKindOf problem Id to be handled
+     * @param aInState state id where to handle
+     */
+    void HandleHostProblemL(TInt aWhatKindOf, TUsbStateIds aInState);
+
+    /**
+     * Add observer to USb Otg state machine
+     * @param aObserver Observer
+     */
+    void SubscribeL(MUsbOtgWatcherStateObserver& aObserver);
+
+    /**
+     * Remove observer from UsbOtg state observer
+     * @param aObserver Observer
+     */
+    void UnsubscribeL(MUsbOtgWatcherStateObserver& aObserver);
+
+    /**
+     * Used for test purposes
+     */
+    void PrintStateToLog();
+
+private:
+
+    /**
+     * Default constructor
+     * @param aUsb usbman API 
+     */
+    CUsbOtgWatcher(RUsb& aUsb);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    /**
+     * Starts session
+     */
+    void StartSessionL();
+
+    /**
+     * Changes device's state machine state
+     *
+     * @param aNewStateId New state id
+     */
+    void ChangeStateL(TUsbStateIds aNewStateId);
+
+    /**
+     * Changes host's state machine state
+     *
+     * @param aNewStateId new host state (id)
+     */
+    void ChangeHostStateL(TUsbStateIds aNewStateId);
+
+    /**
+     * Used for test purposes
+     * @return KErrNone if test is OK, otherwise errorcode
+     */
+    TInt SelfTestL();
+
+private:
+    // data
+
+    /**
+     * usbman API
+     */
+    RUsb& iUsb;
+
+    /**
+     * Personality to be set in device role
+     */
+    TInt iPersonalityId;
+
+    /**
+     * Device state machine
+     * Own.  
+     */
+    CUsbState* iState;
+
+    /**
+     * Host state machine
+     * Own.  
+     */
+    CUsbState* iHostState;
+
+    /**
+     * Id pin Observer
+     * Own.  
+     */
+    CUsbIdPinObserver* iIdPinObserver;
+
+    /**
+     * vbus observer
+     * Own.  
+     */
+    CUsbVBusObserver* iVBusObserver;
+
+    /**
+     * otg state observer
+     * Own.  
+     */
+    CUsbOtgStateObserver* iOtgStateObserver;
+
+    /**
+     * bus activity observer
+     * Own.  
+     */
+    CUsbBusActivityObserver* iBusActivityObserver;
+
+    /**
+     * host event notification observer
+     * Own.  
+     */
+    CUsbHostEventNotificationObserver* iHostEventNotificationObserver;
+
+    /**
+     * message notification observer
+     * Own.  
+     */
+    CUsbMessageNotificationObserver* iMessageNotificationObserver;
+
+    /**
+     * All states objects kept here
+     * Own.  
+     */
+    RPointerArray<CUsbState> iStates;
+
+    /**
+     * notif manager
+     * Own.  
+     */
+    CUsbNotifManager* iNotifManager;
+
+    /**
+     * usb service control
+     * Starts and stops usb service, changes personalities 
+     * Own.  
+     */
+    CUsbServiceControl* iUsbServiceControl;
+
+    /**
+     * The observer reports state changes to its own observers
+     * Not Own
+     */
+    RPointerArray<MUsbOtgWatcherStateObserver> iOtgStateObservers;
+
+    /**
+     * The observer reports state changes to its own observers
+     * Not Own
+     */
+    CUsbServiceControl::TUsbServiceRequest iUsbServiceRequest;
+    };
+
+#endif //  C_USBOTGWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbservicecontrol.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,148 @@
+/*
+ * 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:  Implementation 
+ *
+ */
+
+#ifndef C_USBSERVICECONTROL_H
+#define C_USBSERVICECONTROL_H
+
+#include <e32base.h>
+
+class RUsb;
+
+/**
+ *  usb service control observer interface, to get feedback on usb service state change
+ *
+ */
+NONSHARABLE_CLASS( MUsbServiceControlObserver)
+    {
+public:
+
+    /**
+     * called when request for usb services is completed
+     * if there were few requests in a row, during operation, 
+     * only the last one's completion is notified
+     * @param aError error code
+     */
+    virtual void UsbServiceControlReqCompletedL(TInt aError) = 0;
+
+    };
+
+/**
+ *  This class implements starting/stopping usb services 
+ *
+ */
+NONSHARABLE_CLASS( CUsbServiceControl ) : public CActive
+    {
+
+public:
+
+    enum TUsbServiceRequest
+        {
+        ERequestUndefined,
+        EStartUsbService,
+        EStopUsbService
+        };
+
+    /**
+     * Two-phased constructor.
+     * @param aObserver Observer
+     * @param aUsb RUsb API
+     */
+    static CUsbServiceControl* NewL(MUsbServiceControlObserver& aObserver,
+            RUsb& aUsb);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbServiceControl();
+
+    /**
+     * Starts usb service. When service is started call back function 
+     * MUsbServiceControlObserver::UsbServiceControlReqCompletedL will be called.
+     * Client should not worry is usb service already started, or not,
+     * and which one personality is started. Just request this API 
+     * @param aPersonalityId personality id (required by RUsb API to start usb services) 
+     * @return error code
+     */
+    TInt StartL(TInt aPersonalityId);
+
+    /**
+     * Stops service. When service is stopped call back function 
+     * MUsbServiceControlObserver::UsbServiceControlReqCompletedL will be called
+     * @return error code
+     */
+    TInt StopL();
+
+public:
+
+    // from base class CActive
+    /**
+     * Called when request is completed
+     */
+    void RunL();
+
+    /**
+     * called when RunL leaves
+     * @param aError error code
+     * @return error code
+     */
+    TInt RunError(TInt aError);
+
+    /**
+     * Called when request is cancelled
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Default constructor
+     * @param aObserver receives call back when service started or stopped
+     * @param aUsb usbman API
+     */
+    CUsbServiceControl(MUsbServiceControlObserver& aObserver, RUsb& aUsb);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Observer
+     * not own
+     */
+    MUsbServiceControlObserver& iObserver;
+
+    /**
+     * RUsb API
+     */
+    RUsb& iUsb;
+
+    /**
+     * personality ID, to be started
+     */
+    TInt iPersonalityId;
+
+    /**
+     * Service state
+     */
+    TUsbServiceState iServiceState; // required as a parameter for service states notifications 
+
+    };
+
+#endif //  C_USBSTATEHOSTAHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstate.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,263 @@
+/*
+ * 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:  Base class for states in state machine
+ *
+ */
+
+#ifndef C_USBSTATE_H
+#define C_USBSTATE_H
+
+#include <e32base.h>
+#include <usbotgdefs.h>
+#include <usbman.h>
+
+#include "definitions.h"
+
+class CUsbOtgWatcher;
+
+/**
+ *  Base class for usb states
+ *  Defines default implementation for events
+ *  Class is C, due to there are possible future extentions
+ *  for the class to own heap-based data. Class is not inherited
+ *  from CActive, due to not all states are active objects. 
+ *  If concrete state need to be an active object, it can aggregate CActive,
+ *  rather than inherit (due to multiple inheritence of C classes is not allowed)
+ *
+ */
+NONSHARABLE_CLASS( CUsbState ) : public CBase
+
+    {
+
+    /**
+     *  Only UsbOtgWatcher intended to call any of protected methods from the class
+     * (except ChangeState and ChangeHostState, called by concrete subclasses),
+     *	and those methods are protected, due to have to be re-implemented in subclasses
+     * Class is not intended for instantiation, that's why no any public construction methods
+     */
+    friend class CUsbOtgWatcher;
+
+    /******************************************************************************* */
+public:
+
+    /**
+     * This function is needed to find a real state by id
+     * This might be used in switching states in watcher. New state object searched by its id
+     * @return Id
+     */
+    virtual TUsbStateIds Id() = 0;
+
+    /**
+     * Destruction
+     */
+    virtual ~CUsbState();
+
+protected:
+    /**
+     * default constructor is protected to be able to be inherited be child classes
+     * @param aOwner owner of the state
+     */
+    CUsbState(CUsbOtgWatcher& aOwner);
+
+    /* *
+     * Changes state in Device state machine
+     * @param aNewStateId new state id
+     */
+    void ChangeStateL(TUsbStateIds aNewStateId);
+
+    /**
+     * Changes state in host state machine
+     * @param aNewStateId new host state
+     */
+    void ChangeHostStateL(TUsbStateIds aNewStateId);
+
+    /**
+     * Handles special situation (error, or something else)
+     * @param aWhat to hande (id)
+     * @param aWhereTohandle state id where to handle
+     */
+    virtual void HandleL(TInt aWhat, TUsbStateIds aWhereTohandle);
+
+    /**
+     * State machine calls this, state object to perform any initial  
+     * activity, once just entered this state
+     *
+     */
+    virtual void JustAdvancedToThisStateL();
+
+    /**
+     * State machine calls this, state object to perform any initial  
+     * activity, just before leaving this state
+     *
+     */
+    virtual void JustBeforeLeavingThisStateL();
+
+    /**
+     * Following virtual functions are called by UsbOtgWatcher
+     * on getting accodring event. Those are implemented in concret states.
+     */
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    /**
+     * Sets personality
+     */
+    virtual void SetPersonalityL();
+
+    /**
+     * Cancels setting personality async.
+     */
+    virtual void CancelSetPersonalityL();
+
+    /**
+     *
+     * Sets previous personality
+     */
+    virtual void SetPreviousPersonalityL();
+
+    /**
+     * Cancels async. set prev personality request
+     */
+    virtual void CancelSetPreviousPersonalityL();
+
+    /**
+     *
+     * Sets prev. personality on disconnecting device
+     */
+    virtual void SetPreviousPreviousPersonalityOnDisconnectL();
+
+    /**
+     * Id Pin OFF
+     */
+    virtual void IdPinOffL();
+    /**
+     * Id Pin On
+     */
+    virtual void IdPinOnL();
+
+    // From VBus observer
+    /**
+     * VBus down
+     */
+    virtual void VBusDownL();
+    /**
+     * VBus UP
+     */
+    virtual void VBusUpL();
+
+    // From OTG state observer
+    /**
+     * Became to Idle when A
+     */
+    virtual void AIdleL();
+    /**
+     * Became a Host when A
+     */
+    virtual void AHostL();
+    /**
+     * Became a peripheral when A
+     */
+    virtual void APeripheralL();
+    /**
+     * VBus error happen
+     */
+    virtual void AVBusErrorL();
+    /**
+     * Became to Idle when B
+     */
+    virtual void BIdleL();
+    /**
+     * Became a peripheral when B
+     */
+    virtual void BPeripheralL();
+    /**
+     * Became a Host when B
+     */
+    virtual void BHostL();
+
+    // From bus activity observer
+    /**
+     * Bus is in idle
+     */
+    virtual void BusIdleL();
+    /**
+     * Bus active
+     */
+    virtual void BusActiveL();
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    virtual void DeviceAttachedL(TDeviceEventInformation aInfo);
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    virtual void DeviceDetachedL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers successfully loaded
+     * @param aInfo Device event data
+     */
+    virtual void DriverLoadSuccessL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers loaded partially
+     * @param aInfo Device event data
+     */
+    virtual void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers loading failed
+     * @param aInfo Device event data
+     */
+    virtual void DriverLoadFailureL(TDeviceEventInformation aInfo);
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMessage message id
+     */
+    virtual void MessageNotificationReceivedL(TInt aMessage);
+    /**
+     * Connected to hub in wrong level 
+     */
+    virtual void BadHubPositionL();
+    /**
+     * VBus error happened
+     */
+    virtual void VBusErrorL();
+    /**
+     * SRP request received
+     */
+    virtual void SrpReceivedL();
+    /**
+     * Session request received
+     */
+    virtual void SessionRequestedL();
+
+protected:
+    // data
+
+    /**
+     * Owner
+     * Not own.  
+     */
+    CUsbOtgWatcher& iWatcher;
+
+    };
+
+#endif // C_USBSTATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostabase.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,116 @@
+/*
+ * 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:  Implementation of the conctet state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTABASE_H
+#define C_USBSTATEHOSTABASE_H
+
+#include "cusbstate.h"
+#include "definitions.h"
+
+class CUsbOtgWatcher;
+/**
+ *  This class implements basic behaviour for states in Host role
+ */
+NONSHARABLE_CLASS( CUsbStateHostABase ) : public CUsbState
+    {
+
+public:
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostABase();
+
+protected:
+    /**
+     * default construction
+     * @param aWatcher owner
+     */
+    CUsbStateHostABase(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * second phase construction
+     */
+    void ConstructL();
+
+    // From VBus observer
+    /**
+     * VBus down
+     */
+    virtual void VBusDownL();
+
+    // From OTG state observer
+    /**
+     * Became to Idle when A
+     */
+    virtual void AIdleL();
+
+    /**
+     * VBus error happen
+     */
+    virtual void AVBusErrorL();
+
+    /**
+     * Become A host
+     */
+    virtual void AHostL();
+
+    /**
+     * become A peripheral
+     */
+    virtual void APeripheralL();
+
+    // From bus activity observer
+    /**
+     * Bus is in idle
+     */
+    virtual void BusIdleL();
+    /**
+     * Bus active
+     */
+    virtual void BusActiveL();
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMessage message id
+     */
+    virtual void MessageNotificationReceivedL(TInt aMessage);
+
+    /**
+     * SRP request received
+     */
+    virtual void SrpReceivedL();
+
+    /**
+     * Connected to hub in wrong level 
+     */
+    virtual void BadHubPositionL();
+
+    /**
+     * VBus error happened
+     */
+    virtual void VBusErrorL();
+
+    /**
+     * Session request received
+     */
+    virtual void SessionRequestedL();
+
+    };
+
+#endif //  C_USBSTATEHOSTABASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostahost.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,96 @@
+/*
+ * 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:  Implementation of the concret state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTAHOST_H
+#define C_USBSTATEHOSTAHOST_H
+
+#include "cusbstatehostabase.h"
+
+class CUsbOtgWatcher;
+
+/**
+ *  This class implements behaviour in Host state (Drivers loaded, device is in Host role)
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostAHost ) : public CUsbStateHostABase
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher Owner
+     */
+    static CUsbStateHostAHost* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostAHost();
+
+private:
+
+    /**
+     * Default construction
+     * @param aWatcher owner
+     */
+    CUsbStateHostAHost(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    //from CUsbState
+    /**
+     * State id
+     * @return state id
+     */
+    TUsbStateIds Id();
+
+    /**
+     * This is called when switched to this state, 
+     * because If all conditions for transition to another state exist, nothing will 
+     * trigger it and transition will not happen. This forces the transition in such cases.
+     *
+     */
+    virtual void JustAdvancedToThisStateL();
+
+    /**
+     * State machine calls this, state object to perform any initial  
+     * activity, just before leaving this state
+     *
+     */
+    virtual void JustBeforeLeavingThisStateL();
+
+    // From Host Event notification observer
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    virtual void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    // From message notification observer
+    /**
+     * Connected to hub in wrong level 
+     */
+    virtual void BadHubPositionL();
+
+private:
+    // data
+    };
+
+#endif //  C_USBSTATEHOSTAHOST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,148 @@
+/*
+ * 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:  Implementation of the concret state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTAINITIATE_H
+#define C_USBSTATEHOSTAINITIATE_H
+
+#include "cusbstatehostabase.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+class CUsbOtgWatcher;
+
+/**
+ *  This class implements behaviour when Id pin just detected (initiating host role, loading drivers)
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostAInitiate ) : public CUsbStateHostABase,
+MUsbTimerObserver
+    {
+    friend class CtUsbOtgWatcher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostAInitiate* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostAInitiate();
+
+private:
+
+    // From MUsbTimerObserver
+    /**
+     * timer expired call back
+     * @param aTimerId timer id
+     */
+    void TimerElapsedL(TUsbTimerId aTimerId);
+
+    /**
+     * default construction
+     * @param aWatcher owner
+     */
+    CUsbStateHostAInitiate(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    //from CUsbState
+    /**
+     * state id
+     * @return state id
+     */
+    TUsbStateIds Id();
+
+    /**
+     * This is called when switched to this state, 
+     * because If all conditions for transition to another state exist, nothing will 
+     * trigger it and transition will not happen. This forces the transition in such cases.
+     *
+     */
+    void JustAdvancedToThisStateL();
+
+    /**
+     * This is called when switched to this state, 
+     * because If all conditions for transition to another state exist, nothing will 
+     * trigger it and transition will not happen. This forces the transition in such cases.
+     *
+     */
+    void JustBeforeLeavingThisStateL();
+
+    // From VBus observer
+    /**
+     * VBus up
+     */
+    void VBusUpL();
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    void DeviceAttachedL(TDeviceEventInformation aInfo);
+    
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DriverLoadSuccessL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers loaded partially
+     * @param aInfo Device event data
+     */
+    void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers loading failed
+     * @param aInfo Device event data
+     */
+    void DriverLoadFailureL(TDeviceEventInformation aInfo);
+
+private:
+    // data
+
+    /*
+     * attachment timer
+     * own
+     */
+    CUsbTimer* iAttachmentTimer;
+
+    /*
+     * attachment attribute
+     */
+    TBool iDeviceAttached;
+    };
+
+#endif //  C_USBSTATEHOSTINITIATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,81 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTAPERIPHERAL_H
+#define C_USBSTATEHOSTAPERIPHERAL_H
+
+#include "cusbstatehostabase.h"
+
+class CUsbOtgWatcher;
+
+/**
+ *  This class implements behaviour when A device performs peripheral role, from OTG point of view
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostAPeripheral ) : public CUsbStateHostABase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostAPeripheral* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostAPeripheral();
+
+private:
+
+    /**
+     * default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostAPeripheral(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    //from CUsbState
+    /**
+     * state id
+     * @return state id
+     */
+    TUsbStateIds Id();
+
+    // From OTG state observer
+    /**
+     * Became a host when A
+     */
+    void AHostL();
+    
+    /**
+     * Became to Idle when A
+     */
+    void AIdleL();
+
+private:
+    // data
+
+    };
+
+#endif //  C_USBSTATEHOSTAPERIPHERAL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelayattachedhandle.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,108 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTDALAYATTACHEDHANDLE_H
+#define C_USBSTATEHOSTDALAYATTACHEDHANDLE_H
+
+#include "cusbstatehostdelayhandle.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+class CUsbOtgWatcher;
+
+/**
+ *  problem handling, device is attached, vbus not dropping
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostDelayAttachedHandle ) : public CUsbStateHostDelayHandle,
+public MUsbTimerObserver
+    {
+    friend class CtUsbOtgWatcher;
+    friend class CUsbOtgWatcher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostDelayAttachedHandle* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostDelayAttachedHandle();
+
+protected:
+
+    // From MUsbTimerObserver
+    /**
+     * Call back when timer expired
+     * @param aTimerId timer id
+     */
+    void TimerElapsedL(TUsbTimerId aTimerId);
+
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    virtual void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    //from CUsbState
+    /**
+     * State id
+     * @return state id
+     */
+    virtual TUsbStateIds Id();
+
+    /**
+     * This is called when leaving this state, 
+     *
+     */
+    virtual void JustBeforeLeavingThisStateL();
+
+    /**
+     * handles issue
+     */
+    virtual void DoHandleL();
+
+    /**
+     * Default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostDelayAttachedHandle(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    // data
+
+private:
+    /** 
+     * drivers not found
+     * own
+     */
+    CUsbTimer* iDriversNotFoundTimer;
+    };
+
+#endif //  C_USBSTATEHOSTDELAYATTACHEDHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelayhandle.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,72 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTDELAYHANDLE_H
+#define C_USBSTATEHOSTDELAYHANDLE_H
+
+#include "cusbstatehosthandle.h"
+
+class CUsbOtgWatcher;
+
+/**
+ *  problem handling, vbus not dropping
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostDelayHandle ) : public CUsbStateHostHandle
+    {
+    friend class CtUsbOtgWatcher;
+    friend class CUsbOtgWatcher;
+
+public:
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostDelayHandle();
+
+protected:
+
+    // From VBus observer
+    /**
+     * VBus up
+     */
+    virtual void VBusUpL();
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    virtual void DeviceAttachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostDelayHandle(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    // data
+
+private:
+    };
+
+#endif //  C_USBSTATEHOSTDELAYHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelaynotattachedhandle.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,113 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTDELAYANOTTTACHEDHANDLE_H
+#define C_USBSTATEHOSTDELAYNOTATTACHEDHANDLE_H
+
+#include "cusbstatehostdelayhandle.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+class CUsbOtgWatcher;
+/**
+ *  problem handling, device is not attached, vbus not dropping
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostDelayNotAttachedHandle ) : public CUsbStateHostDelayHandle,
+MUsbTimerObserver
+    {
+    friend class CtUsbOtgWatcher;
+    friend class CUsbOtgWatcher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostDelayNotAttachedHandle* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostDelayNotAttachedHandle();
+
+private:
+
+    // From MUsbTimerObserver
+    /**
+     * Call back when timer expired
+     * @param aTimerId timer id
+     */
+    void TimerElapsedL(TUsbTimerId aTimerId);
+
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    // From OTG state observer
+    /**
+     * Became to Idle when A
+     */
+    void AIdleL();
+
+    //from CUsbState
+    /**
+     * State id
+     * @return state id
+     */
+    TUsbStateIds Id();
+
+    /**
+     * This is called when leaving this state, 
+     *
+     */
+    void JustBeforeLeavingThisStateL();
+
+    /**
+     * handles issue
+     */
+    void DoHandleL();
+
+    /**
+     * Default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostDelayNotAttachedHandle(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    // data
+
+    /** 
+     * too much power timer
+     * own
+     */
+    CUsbTimer* iTooMuchPowerTimer;
+
+    };
+
+#endif //  C_USBSTATEHOSTDELAYNOTATTACHEDHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehosthandle.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,95 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTHANDLE_H
+#define C_USBSTATEHOSTHANDLE_H
+
+#include "cusbstatehostabase.h"
+
+class CUsbOtgWatcher;
+
+/**
+ *  problem handling base class
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostHandle ) : public CUsbStateHostABase
+    {
+    friend class CtUsbOtgWatcher;
+    friend class CUsbOtgWatcher;
+
+public:
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostHandle();
+
+    /**
+     * Sets id of the issue to be handled
+     * @param aWhat issue id
+     */
+    void SetWhat(TInt aWhat);
+
+protected:
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMessage message id
+     */
+    virtual void MessageNotificationReceivedL(TInt aMessage);
+
+    /**
+     * Session request received
+     */
+    virtual void SessionRequestedL();
+
+    /**
+     * This is called when switched to this state, 
+     * because If all conditions for transition to another state exist, nothing will 
+     * trigger it and transition will not happen. This forces the transition in such cases.
+     *
+     */
+    virtual void JustAdvancedToThisStateL();
+
+    /**
+     * handles issue
+     */
+    virtual void DoHandleL() = 0;
+
+    /**
+     * Default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostHandle(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    // data
+
+    /**
+     * identifies situation to be handled
+     */
+    TInt iWhat;
+
+private:
+    };
+
+#endif //  C_USBSTATEHOSTHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehosthandledropping.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,155 @@
+/*
+ * 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:  Implements concrete state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTHANDLEDROPPING_H
+#define C_USBSTATEHOSTHANDLEDROPPING_H
+
+#include "cusbstatehosthandle.h"
+
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#else
+#include "mockcusbnotifmanager.h"
+#endif
+
+class CUsbOtgWatcher;
+
+/**
+ *  problem handling class, dropping vbus
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostHandleDropping ) : public CUsbStateHostHandle,
+MWaitNotifierObserver
+// this means only one wait notifier at a time can be shown by this state, might be redesigned
+
+    {
+    friend class CtUsbOtgWatcher;
+    friend class CUsbOtgWatcher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostHandleDropping* NewL(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbStateHostHandleDropping();
+
+private:
+
+    // from MWaitNotifierObserver
+    /**
+     * Callback when notifier is completed
+     * @param aFeedback how notifier completed
+     */
+    void WaitNotifierCompletedL(TInt aFeedback);
+
+    // From VBus observer
+    /**
+     * VBus up
+     */
+    void VBusUpL();
+
+    /**
+     * VBus down
+     */
+    void VBusDownL();
+
+    /**
+     * VBus error happen
+     */
+    void AVBusErrorL();
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    void DeviceAttachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers successfully loaded
+     * @param aInfo Device event data
+     */
+    void DriverLoadSuccessL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers loaded partially
+     * @param aInfo Device event data
+     */
+    void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers loading failed
+     * @param aInfo Device event data
+     */
+    void DriverLoadFailureL(TDeviceEventInformation aInfo);
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMessage message id
+     */
+    void MessageNotificationReceivedL(TInt aMessage);
+
+    /**
+     * VBus error happened
+     */
+    void VBusErrorL();
+
+    //from CUsbState
+    /**
+     * State id
+     * @return state id
+     */
+    TUsbStateIds Id();
+
+    /**
+     * This is called when leaving this state, 
+     *
+     */
+    void JustBeforeLeavingThisStateL();
+
+    /**
+     * handles issue
+     */
+    void DoHandleL();
+
+    /**
+     * Default constructor
+     * @param aWatcher owner
+     */
+    CUsbStateHostHandleDropping(CUsbOtgWatcher& aWatcher);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+    };
+
+#endif //  C_USBSTATEHOSTDROPPINGHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostundefined.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,149 @@
+/*
+ * 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:  Implementation of the concret state
+ *
+ */
+
+#ifndef C_USBSTATEHOSTUNDEFINED_H
+#define C_USBSTATEHOSTUNDEFINED_H
+
+#include "cusbstatehostabase.h"
+
+class CUsbOtgWatcher;
+/**
+ *  This class implements behaviour in undefined state (when host)
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostUndefined ) : public CUsbStateHostABase
+    {
+public:
+
+    /**
+     * Destruction
+     */
+    virtual ~CUsbStateHostUndefined();
+
+    /**
+     * Two-phased constructor.
+     * @param aWatcher owner
+     */
+    static CUsbStateHostUndefined* NewL(CUsbOtgWatcher& aWatcher);
+
+private:
+    /**
+     * default constructor is protected to be able to be inherited by child classes
+     * @param aOwner owner of the state
+     */
+    CUsbStateHostUndefined(CUsbOtgWatcher& aOwner);
+
+    /**
+     * Second phase construction
+     */
+    void ConstructL();
+
+    /**
+     * This function is needed to find a real state by id
+     * This might be used in switching states in watcher. New state object searched by its id
+     * @return Id
+     */
+    TUsbStateIds Id();
+
+    // From VBus observer
+    /**
+     * VBus down
+     */
+    void VBusDownL();
+
+    /**
+     * VBus UP
+     */
+    void VBusUpL();
+
+    /**
+     * VBus error
+     */
+    void VBusErrorL();
+
+    /**
+     * AVBus Error
+     */
+    void AVBusErrorL();
+
+    /**
+     * Became to Idle when B
+     */
+    void BIdleL();
+
+    /**
+     * Became to Peripheral when B
+     */
+    void BPeripheralL();
+
+    // From Host Event notification observer
+    /**
+     * Device is attached
+     * @param aInfo Device event data
+     */
+    void DeviceAttachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Device is detached
+     * @param aInfo Device event data
+     */
+    void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers successfully loaded
+     * @param aInfo Device event data
+     */
+    void DriverLoadSuccessL(TDeviceEventInformation aInfo);
+
+    /**
+     * Drivers loaded partially
+     * @param aInfo Device event data
+     */
+    void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo);
+    /**
+     * Drivers loading failed
+     * @param aInfo Device event data
+     */
+    void DriverLoadFailureL(TDeviceEventInformation aInfo);
+
+    // From message notification observer
+    /**
+     * Message received
+     * @param aMessage message id
+     */
+    void MessageNotificationReceivedL(TInt aMessage);
+
+    /**
+     * SRP request received
+     */
+    void SrpReceivedL();
+
+    /**
+     * Connected to hub in wrong level 
+     */
+    void BadHubPositionL();
+
+    /**
+     * Session request received
+     */
+    void SessionRequestedL();
+
+private:
+    // data
+    };
+
+#endif //  C_USBSTATEHOSTUNDEFINED_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbtimer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,136 @@
+/*
+ * 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:  timer
+ *
+ */
+
+#ifndef C_USBTIMER_H
+#define C_USBTIMER_H
+
+#include <e32base.h>
+
+class CUsbTimer;
+
+/**
+ * timer ids for usbotgwatcher
+ */
+enum TUsbTimerId
+    {
+    EDeviceAttachmentTimer,
+    EInactiveTimer,
+    EIconBlinkingTimer,
+    ETooMuchPowerRequiredTimer,
+    EDriversNotFoundTimer
+    };
+
+/**
+ * Observers gets feedback by implementing this interface
+ */
+class MUsbTimerObserver
+    {
+    friend class CtUsbOtgWatcher;
+
+public:
+
+    /**
+     * Observer must implement this interace
+     * which is called back when timer expires
+     * @param timer id
+     */
+    virtual void TimerElapsedL(TUsbTimerId aTimerId) = 0;
+    };
+
+/* *
+ * Wrapper class, will report to MUsbTimerObserver once time is over
+ * Name CUsbTimer is given due to CTimer name already used
+ */
+NONSHARABLE_CLASS(CUsbTimer) : public CActive
+    {
+public:
+
+    /**
+     * Two-phased constructor
+     *
+     * @param aObserver will get call back
+     * @param aTimerId timer id
+     */
+    static CUsbTimer * NewL(MUsbTimerObserver& aObserver,
+            TUsbTimerId aTimerId);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbTimer();
+
+    /**
+     * calls RunL after aMilliseconds
+     * @param aMilliseconds time in millisecs
+     */
+    void After(TInt aMilliseconds);
+
+public:
+
+    // from base class CActive
+    /**
+     * Called when request is completed
+     */
+    void RunL();
+
+    /**
+     * called when RunL leaves
+     * @param aError error code
+     * @return error code
+     */
+    TInt RunError(TInt aError);
+
+    /**
+     * Called when request is cancelled
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Default constructor
+     * @param aObserver will get call back
+     * @param aTimerId timer id 
+     */
+    CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * Observer
+     * not own
+     */
+    MUsbTimerObserver& iObserver;
+
+    /**
+     * RTimer API
+     */
+    RTimer iTimer;
+
+    /**
+     * timer id
+     */
+    TUsbTimerId iTimerId;
+    };
+
+#endif //  C_USBTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbvbusobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,141 @@
+/*
+ * 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:  Implements VBus observer
+ *
+ */
+
+#ifndef C_USBVBUSOBSERVER_H
+#define C_USBVBUSOBSERVER_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+/**
+ * Observers of this class have to implement this interface
+ * to get call back on VBus events
+ */
+NONSHARABLE_CLASS( MUsbVBusObserver)
+    {
+public:
+
+    /**
+     * VBus down event received
+     */
+    virtual void VBusDownL() = 0;
+    /**
+     * VBus up event received
+     */
+    virtual void VBusUpL() = 0;
+    /**
+     * error handler
+     * @param aError error code
+     */
+    virtual void VBusObserverErrorL(TInt aError)=0;
+
+    };
+
+/**
+ *  Class observes VBUS property
+ *
+ */
+NONSHARABLE_CLASS( CUsbVBusObserver ) : public CActive
+    {
+
+public:
+    enum TState
+        {
+        EVBusDown = 0, EVBusUp = 1
+
+        };
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbVBusObserver* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbVBusObserver();
+
+    /**
+     * VBus state getter
+     * @return VBus state
+     */
+    TState VBus() /* not const. read comment in impl*/;
+
+    /**
+     * Adds observer to a list
+     * @param aObserver observer
+     */
+    void SubscribeL(MUsbVBusObserver& aObserver);
+
+    /**
+     * removes observer from list
+     * @param aObserver observer
+     */
+    void UnsubscribeL(MUsbVBusObserver& aObserver);
+
+private:
+
+    // From CActive
+    /**
+     * Called when request completed
+     *
+     */
+    void RunL();
+
+    /**
+     * Called when request is cancelled
+     *
+     */
+    void DoCancel();
+
+    /**
+     * Called when RunL leaves
+     * @param aError error code
+     * @return error code
+     *
+     */
+    TInt RunError(TInt aError);
+
+private:
+
+    /**
+     * Default constructor
+     */
+    CUsbVBusObserver();
+
+    /**
+     * 2nd phase constructor
+     */
+    void ConstructL();
+
+private:
+    // data
+
+    /**
+     * The observer reports state changes to own observers
+     * Not owns
+     */
+    RPointerArray<MUsbVBusObserver> iObservers;
+
+    /**
+     * The observer observes property change
+     */
+    RProperty iVBus;
+
+    };
+
+#endif //  C_USBVBUSOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbwaitnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,66 @@
+/*
+ * 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:  Usb waiting notifier implementation
+ *
+ */
+
+#ifndef C_USBWAITNOTIFIER_H
+#define C_USBWAITNOTIFIER_H
+
+#include <e32base.h>
+
+#include "cusbnotenotifier.h"
+
+/**
+ *  Class implements functionality of the notifier which wait for answer from user
+ *	Class does not provide method to get response from the user
+ */
+NONSHARABLE_CLASS( CUsbWaitNotifier) : public CUsbNoteNotifier
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aNotifier RNotifier API
+     * @param aNotifManager Owner of the class, will destroy the object when needed
+     * @param aNotifId Id of the notifier
+     * @return Pointer to the new instance of CUsbWaitNotifier
+     */
+    static CUsbWaitNotifier* NewL(RNotifier& aNotifier,
+            CUsbNotifManager& aNotifManager, TUint aNotifId);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbWaitNotifier();
+
+private:
+
+    /**
+     * Default constructor
+     * @param aNotifier RNotifier API
+     * @param aNotifManager Owner of the class, will destroy the object when needed
+     * @param aNotifId Id of the notifier
+     */
+    CUsbWaitNotifier(RNotifier& aNotifier, CUsbNotifManager& aNotifManager,
+            TUint aNotifId);
+
+    /**
+     * 2nd phase constructor
+     */
+    void ConstructL();
+
+    };
+
+#endif //  C_USBWAITNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbwarningnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,70 @@
+/*
+ * 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:  Usb warning notifier implementation
+ *
+ */
+
+#ifndef C_USBWARNINGNOTIFIER_H
+#define C_USBWARNINGNOTIFIER_H
+
+#include <e32base.h>
+
+#include "cusbnotenotifier.h"
+#include "cusbtimer.h"
+
+/**
+ *  Class implements functionality of the notifier which wait for answer from user
+ *	Class does not provide method to get response from the user
+ */
+NONSHARABLE_CLASS( CUsbWarningNotifier ) : public CUsbNoteNotifier
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aNotifier RNotifier API
+     * @param aNotifManager Owner of the class, will destroy the object when needed
+     * @param aNotifId Id of the notifier
+     * @return Pointer to the new instance of CUsbWarningNotifier
+     */
+    static CUsbWarningNotifier* NewL(RNotifier& aNotifier,
+            CUsbNotifManager& aNotifManager, TUint aNotifId);
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbWarningNotifier();
+
+private:
+
+    /**
+     * Default constructor
+     * @param aNotifier RNotifier API
+     * @param aNotifManager Owner of the class, will destroy the object when needed
+     * @param aNotifId Id of the notifier
+     */
+    CUsbWarningNotifier(RNotifier& aNotifier,
+            CUsbNotifManager& aNotifManager, TUint aNotifId);
+
+    /**
+     * 2nd phase construction
+     */
+    void ConstructL();
+
+private:
+    // Data
+
+    };
+
+#endif //  C_USBWARNINGNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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:  Debug macros and declarations. 
+*
+*/
+
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+//////////////////////////////////////////////////////////////////////////////
+// Here are parameters need to be modified. 
+// Component name 
+#define MODULE_NAME "USBOTGWATCHER"
+//////////////////////////////////////////////////////////////////////////////
+
+
+// For handling unicode strings as L##MACRO is interpreted as LMACRO
+#define WIDEN2( x ) L##x
+#define WIDEN( x ) WIDEN2( x )
+
+_LIT( KUsbPanicModule, ""WIDEN( MODULE_NAME ) );
+
+#ifdef _DEBUG
+
+// Comment this line out if using real-time debugging
+//#define LOG_TO_FILE 
+// ===========================================================================
+#if defined ( LOG_TO_FILE )
+// ===========================================================================
+// Add corresponding libabry in mmp file
+// LIBRARY    flogger.lib    
+// The log file is located at  
+// c:\logs\usb\MODULE_NAME.txt
+
+#include <flogger.h>
+
+#define DESC( x ) TPtrC( ( const TText* ) ( x ) )
+#define DESC8( x ) TPtrC8( ( const TUint8* ) ( x ) )
+_LIT( KUsbLogDir, "USB" );
+_LIT( KUsbLogFile, ""WIDEN(MODULE_NAME)L".txt" );
+
+// s: c string. 
+#define LOG(s) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "["MODULE_NAME"] "##s ) )
+
+// s: c string contains "%x"
+// v: varaible corresponding to %x
+#define LOG1(s, v) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "["MODULE_NAME"] "##s ), v)
+// s: c string contains "%x%y"
+// v1: varaible corresponding to %x
+// v2: varaible corresponding to %y
+#define LOG2(s, v1, v2) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "["MODULE_NAME"] "##s ), v1, v2)
+
+// s: c string contains "%x%y%z"
+// v1: varaible corresponding to %x
+// v2: varaible corresponding to %y
+// v3: varaible corresponding to %z
+#define LOG3(s, v1, v2, v3) RFileLogger::WriteFormat( KUsbLogDir, \
+            KUsbLogFile, EFileLoggingModeAppend, \
+            DESC8( "["MODULE_NAME"] "##s ), v1, v2, v3 )
+
+class TFuncLogger
+    {
+public:
+    TFuncLogger(const TDesC8& aFuncName)
+        {
+        iFuncName.Set( aFuncName );
+        RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile, EFileLoggingModeAppend, 
+                DESC8( "["MODULE_NAME"] >>%s" ), iFuncName.Ptr() );
+        }
+    ~TFuncLogger()
+        {
+        RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile, 
+                EFileLoggingModeAppend, 
+                DESC8( "["MODULE_NAME"] <<%s" ), iFuncName.Ptr() );
+        }
+private:
+    TPtrC8 iFuncName;
+    };
+// ===========================================================================
+#else //LOG_TO_FILE not defined
+// ===========================================================================
+#include <e32debug.h>
+
+// Paramters same as above.
+#define LOG( str ) { RDebug::Printf( "["MODULE_NAME"] %s", str  ); }
+
+#define LOG1( s, v ) { RDebug::Printf( "["MODULE_NAME"] "##s , v ); }
+
+#define LOG2( s, v1,v2 ) { RDebug::Printf( "["MODULE_NAME"] "##s , v1, v2 ); }
+
+#define LOG3( s, v1, v2, v3 ) { RDebug::Printf( "["MODULE_NAME"] "##s , \
+        v1, v2, v3); }
+
+class TFuncLogger
+    {
+public:
+    TFuncLogger(const TPtrC8& aFuncName) : iFuncName( aFuncName )
+        {
+        RDebug::Printf( "["MODULE_NAME"] >>%s", iFuncName.Ptr());
+        }
+    ~TFuncLogger()
+        {
+        RDebug::Printf( "["MODULE_NAME"] <<%s", iFuncName.Ptr());
+        }
+private:
+    TPtrC8 iFuncName;
+    };
+#endif // LOG_TO_FILE
+
+#define LEAVE( exp )  {volatile TInt err_ = exp; \
+        LOG3( "LEAVE(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\
+        User::Leave( err_ );}
+
+#define LEAVEIFERROR( exp ) {volatile TInt err__ = exp; \
+        if(err__ < 0) LEAVE(err__);}
+
+#define PANIC( exp ) {volatile TInt err_ = exp; \
+        LOG3( "PANIC(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\
+        User::Panic( KUsbPanicModule, err_ );} 
+
+#define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__));
+
+#define ASSERT_PANIC( exp, code ) {if(!(exp)) PANIC(code)}
+
+#else // _DEBUG not defined 
+// ===========================================================================
+
+#define LOG( s )
+#define LOG1( s, v ) 
+#define LOG2( s, v1, v2 )
+#define LOG3( s, v1, v2, v3 )
+#define LOG_FUNC_ENTRY 
+#define LOG_FUNC_EXIT 
+#define LEAVE( exp ) User::Leave( exp );
+#define LEAVEIFERROR( exp ) User::LeaveIfError( exp );
+#define PANIC( err ) // in non-debug builds PANICs are silent
+#define LOG_FUNC
+#define ASSERT_PANIC( exp, code )
+// ===========================================================================
+#endif // _DEBUG
+// ===========================================================================
+#endif // DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/definitions.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Definitions for otgwatcher
+ *
+ */
+
+#ifndef DEFENITIONS_H
+#define DEFENITIONS_H
+
+#include <e32base.h>
+
+const TInt KTimeToWaitForDeviceAttachment = 25000000; // 25 sec
+const TInt KTimeToDiscreteNote = 2000000; // 2 sec
+const TInt KMaxTimeAllowedForBusInactivity = 10000000; // 10 sec
+const TInt KUsbIndicatorBlinkingInterval = 600000; // 0.6 sec
+const TInt KTimeTooMuchPowerRequired = 10000000; // 10 sec
+const TInt KTimeDriversNotFound = 25000000; // 25 sec
+
+const TUint KFirst = 1;
+
+/**
+ * Types of states
+ * Types of states are needed here, to make transition from one state to another by state Id
+ * not by setting real state pointer to a state machine. States do not have access to
+ * one another states objects, they just know ids
+ */
+enum TUsbStateIds
+    {
+    EUsbStateHostUndefined,
+
+    EUsbStateHostAInitiate,
+    EUsbStateHostAHost,
+    EUsbStateHostAPeripheral,
+
+    EUsbStateHostDelayAttachedHandle,
+    EUsbStateHostDelayNotAttachedHandle,
+    EUsbStateHostHandleDropping
+    };
+
+const TInt KUsbWatcherPeripheralIsNotConnected = 0; // means not(KUsbWatcherPeripheralIsConnected)
+const TInt KUsbWatcherPeripheralIsConnected = 1; // means drivers loaded and session ON at least for one peripheral
+
+#endif //  DEFENITIONS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/errors.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,49 @@
+/*
+ * 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:  File contains error codes, from Watcher perspective
+ *
+ */
+
+#ifndef ERRORS_H
+#define ERRORS_H
+
+#include <e32base.h>
+
+enum TUsbWatcherErrors
+    {
+    EUsbWatcherUndefined, //0	
+    EUsbWatcherErrDriversNotFound, //1
+    EUsbWatcherHubsNotSupported, //2
+    EUsbWatcherErrDeviceRequiresTooMuchPower, //3
+    EUsbWatcherErrUnsupportedDevice, //4
+    EUsbWatcherConnectedToOTG, //5
+    EUsbWatcherErrDandlingCable, //6
+    EUsbWatcherNoActivity, //7
+    EUsbWatcherErrorInConnection, //8
+    EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration, //9
+    EUsbWatcherCanNotStartUsbServices, //10
+    EUsbWatcherIdPinError,
+    EUsbWatcherVBusObserverError,
+    EUsbWatcherHostEventNotificationError,
+    EUsbWatcherOtgStateError,
+    EUsbWatcherMessageNotificationError,
+    EUsbWatcherCanNotStartSession,
+    EUsbWatcherCanNotEnableDriverLoading,
+    EUsbWatcherCanNotClearBusError,
+    EUsbWatcherCanNotRaiseVBus,
+    EUsbWatcherNoMemory
+
+    };
+
+#endif //  ERRRORS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/panic.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,123 @@
+/*
+ * 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:  Central place for debug-type macros & functions
+ *
+ */
+#ifndef C_PANIC_H
+#define C_PANIC_H
+
+#include <e32base.h>
+#include <e32debug.h>
+
+_LIT(KUsbWatcherPanic, "UsbOTGWatcher");
+
+enum TUsbWatcherPanic
+    {
+    ECanNotGetIdPinProperty, //0
+    EWrongIdPinState, //1
+    ECanNotGetVBusProperty, //2
+    EWrongVBusState, //3
+    ECanNotGetOtgStateProperty, //4
+    ENotifierIsActiveAlready, //5
+    EWrongNotifierCategory, //6
+    EUsbWatcherBadErrorCode, //7
+    ECanNotFindIdPinObserver, //8
+    ECanNotFindVBusObserver, //9
+    EWrongOtgState, //10
+    ECanNotGetBusActivityProperty, //11
+    EWrongBusState, //12
+    ECanNotFindBusActivityObserver, //13
+    EWrongDriverLoadStatus, //14
+    EWrongHostEventNotification, //15
+    ECanNotFindMessageNotificationObserver, //16
+    ECanNotFindOtgStateObserver, //17
+    EBadState, //18
+    EBadHostState, // 19
+
+    //From IdPin observer
+    EIdPinOnNotExpected, //20
+    EIdPinOffNotExpected, //21
+
+    // From VBus observer
+    EVBusDownNotExpected, //22
+    EVBusUpNotExpected, //23
+
+    // From OTG state observer
+    EAIdleNotExpected, //24
+    EAHostNotExpected, //25
+    EAPeripheralNotExpected, //26
+    EAVBusErrorNotExpected, //27
+    EBIdleNotExpected, //28
+    EBPeripheralNotExpected, //29
+    EBHostNotExpected, //30
+
+    // From bus activity observer
+    EBusIdleNotExpected, //31
+    EBusActiveNotExpected, //32
+
+    // From Host Event notification observer
+    EDeviceAttachedNotExpected, //33
+    EDeviceDetachedNotExpected, //34
+    EDriverLoadSuccessNotExpected, //35
+    EDriverLoadPartialSuccessNotExpected, //36
+    EDriverLoadFailureNotExpected, //37
+
+    // From message notification observer
+    EMessageNotificationNotExpected, //38
+    EBadHubPositionNotExpected, //39
+    EVBusErrorNotExpected, //40
+    ESrpNotExpected, //41
+    ESessionRequestNotExpected, //42
+
+    EIdPinObserverNULLPointer, //43
+    ECanNotStartUsbServices, //44
+    ECanNotStopUsbServices, //45
+
+    EDanglingCable, //46
+    EPartiallySupportedDevice, //47
+    EDriversLoadingFail, //48
+    EUnsupportedDevice, //49
+    EBadHubPosition, //50
+    ETooMuchPower, //51
+    EBusRespondSrpError, //52
+    EEnableFunctionDriverLoadingError, //53
+    EErrorInConnection, //54
+    EWatcherDriverLoadPartialSuccess, //55
+    EUnsupportedDeviceOrErrorInConnection, //56
+    EBusRequestError, //57
+    EAttachmentError, //58
+    EVBusError, // 59
+    ENoActivity, //60
+    EDeviceDetached, //61
+    EBadHubPositionEventNotExpected, //62
+    EUnhandledMessage, //63
+    EUnexpectedSituationToHandle, //64
+    EConnectedToOTGNotExpected, //65
+
+    EWrongTimerId, //66
+    EUnexpectedNotifId, //67
+    EUnknownUsbServiceState, //68
+    EUnexpectedUsbServiceState, //69
+    EUnexpectedUsbSwitchPersonalityState, //70
+
+    ECanNotFindUsbOtgWatcherStateObserver, //71
+    ENoObserverToUnsubscribe, // 72
+    EObserverAlreadyExists, //73
+    EIdForNotDefinedStateRequested, //74
+    ECanNotFindHostEventNotificationObserver, //75
+    ENoTimersDefinedForThisClass    //76
+
+    };
+
+#endif // C_PANIC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/rom/errrd	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1 @@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/rom/usbotgwatcher.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Image description file for project UsbOtgWatcher
+*
+*/
+
+
+#ifndef USBOTGWATCHER_IBY__
+#define USBOTGWATCHER_IBY__
+
+#ifdef __USB
+
+file=ABI_DIR\BUILD_DIR\usbotgwatcher.dll    PROGRAMS_DIR\usbotgwatcher.dll
+	#ifdef _DEBUG
+	// allows to show extended panic codes
+	file=ABI_DIR\BUILD_DIR\errrd    						c:\resource\errrd
+	#endif
+
+#endif // __USB
+
+#endif // USBOTGWATCHER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbbusactivityobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,234 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbotgdefs.h>
+
+#include "cusbbusactivityobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::CUsbBusActivityObserver() :
+    CActive(EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(iBusActivity.Attach(KUidUsbManCategory,
+            KUsbOtgConnectionIdleProperty));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver* CUsbBusActivityObserver::NewL()
+    {
+    LOG_FUNC
+
+    CUsbBusActivityObserver* self = new (ELeave) CUsbBusActivityObserver();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::~CUsbBusActivityObserver()
+
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iBusActivity.Close();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::TBusActivity CUsbBusActivityObserver::BusActivity()
+    {
+
+    TInt val(0);
+
+    TInt err = iBusActivity.Get(val);
+
+    if (KErrNone != err)
+        {
+        LOG("ECanNotGetBusActivityProperty" );
+        PANIC( ECanNotGetBusActivityProperty);
+        }
+
+    return (0 == val ? EBusActive : EBusIdle);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::SubscribeL(MUsbBusActivityObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG( "Observer already exists" );
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iBusActivity.Subscribe(iStatus);
+        SetActive();
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::UnsubscribeL(MUsbBusActivityObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG( "Observer not found" );
+        PANIC( ECanNotFindBusActivityObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no observers anymore
+        {
+        // cancel pending request
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
+
+    // if error occured, inform observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->BusActivityErrorL(iStatus.Int());
+            }
+        }
+
+    // re-issue request first
+    iBusActivity.Subscribe(iStatus);
+    SetActive();
+
+    // then process property change
+    TBusActivity state(BusActivity());
+
+    switch (state)
+        {
+        case EBusIdle:
+            {
+            LOG("BusIdle");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BusIdleL();
+                }
+            break;
+            }
+
+        case EBusActive:
+            {
+            LOG("BusActive");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BusActiveL();
+                }
+            break;
+            }
+
+        default:
+            {
+            LOG("WrongBusState" );
+            PANIC( EWrongBusState);
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::DoCancel()
+    {
+    iBusActivity.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbBusActivityObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d", aError );
+
+    // try to continue	
+    return KErrNone;
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,266 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbman.h>
+
+#include "cusbhosteventnotificationobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver::CUsbHostEventNotificationObserver(
+        RUsb* aUsb) :
+    CActive(EPriorityStandard), iUsb(aUsb)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver* CUsbHostEventNotificationObserver::NewL(
+        RUsb* aUsb)
+    {
+    LOG_FUNC
+
+    CUsbHostEventNotificationObserver* self =
+            new (ELeave) CUsbHostEventNotificationObserver(aUsb);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::SubscribeL(
+        MUsbHostEventNotificationObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG("Observer already exists" );
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iUsb->HostEventNotification(iStatus, iEventInfo);
+        SetActive();
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::UnsubscribeL(
+        MUsbHostEventNotificationObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG("Observer not found");
+        PANIC( ECanNotFindHostEventNotificationObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no observers anymore
+        {
+        // cancel pending request
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d", iStatus.Int());
+
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->HostEventNotificationErrorL(iStatus.Int());
+            }
+        return;
+        }
+
+    TDeviceEventInformation dei(iEventInfo);
+
+    // re-issue request first
+    iUsb->HostEventNotification(iStatus, iEventInfo);
+    SetActive();
+
+    // Log the event
+    LOG1( "iEventInfo.iDeviceId         = %d" , dei.iDeviceId);
+    LOG1( "iEventInfo.iEventType        = %d" , dei.iEventType);
+    LOG1( "iEventInfo.iError            = %d" , dei.iError);
+    LOG1( "iEventInfo.iDriverLoadStatus = %d" , dei.iDriverLoadStatus);
+    LOG1( "iEventInfo.iVid              = %d" , dei.iVid);
+    LOG1( "iEventInfo.iPid              = %d" , dei.iPid);
+
+    // then process property change
+    switch (dei.iEventType)
+        {
+        case EDeviceAttachment:
+            {
+            LOG("DeviceAttachment" );
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->DeviceAttachedL(dei);
+                }
+            break;
+            }
+
+        case EDeviceDetachment:
+            {
+            LOG( "DeviceDetachment" );
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->DeviceDetachedL(dei);
+                }
+            break;
+            }
+
+        case EDriverLoad:
+            {
+            switch (dei.iDriverLoadStatus)
+                {
+                case EDriverLoadSuccess:
+                    {
+                    LOG( "DriverLoadSuccess" );
+
+                    for (TInt i(0); i < iObservers.Count(); ++i)
+                        {
+                        iObservers[i]->DriverLoadSuccessL(dei);
+                        }
+
+                    break;
+                    }
+                case EDriverLoadPartialSuccess:
+                    {
+                    LOG( "DriverLoadPartialSuccess" );
+
+                    for (TInt i(0); i < iObservers.Count(); ++i)
+                        {
+                        iObservers[i]->DriverLoadPartialSuccessL(dei);
+                        }
+
+                    break;
+                    }
+                case EDriverLoadFailure:
+                    {
+                    LOG( "DriverLoadFailure");
+
+                    for (TInt i(0); i < iObservers.Count(); ++i)
+                        {
+                        iObservers[i]->DriverLoadFailureL(dei);
+                        }
+                    break;
+                    }
+                default:
+                    {
+                    LOG("WrongDriverLoadStatus" );
+                    PANIC( EWrongDriverLoadStatus);
+                    }
+                }
+            break;
+
+            }
+        default:
+            {
+            LOG( "WrongHostEventNotification" );
+            PANIC( EWrongHostEventNotification);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::DoCancel()
+    {
+    iUsb->HostEventNotificationCancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbHostEventNotificationObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d" , aError);
+
+    // try to recover and continue	
+    return KErrNone;
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbidpinobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,234 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbotgdefs.h>
+
+#include "cusbidpinobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::CUsbIdPinObserver() :
+    CActive(EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(iIdPin.Attach(KUidUsbManCategory,
+            KUsbOtgIdPinPresentProperty));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver* CUsbIdPinObserver::NewL()
+    {
+    LOG_FUNC
+
+    CUsbIdPinObserver* self = new (ELeave) CUsbIdPinObserver();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::~CUsbIdPinObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iIdPin.Close();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::TState CUsbIdPinObserver::IdPin()
+/* this getter is not const, because for some reason RProperty::Get is not const */
+    {
+
+    TInt val(0);
+
+    TInt err = iIdPin.Get(val);
+
+    if (KErrNone != err)
+        {
+        LOG("CanNotGetIdPinProperty" );
+        PANIC( ECanNotGetIdPinProperty);
+        }
+
+    return (EFalse == val ? EIdPinOff : EIdPinOn);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//   
+void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG("Observer already exists" );
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iIdPin.Subscribe(iStatus);
+        SetActive();
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG("Observer not found");
+        PANIC( ECanNotFindIdPinObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no observers anymore
+        {
+        // cancel pending request
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
+
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->IdPinErrorL(iStatus.Int());
+            }
+        return;
+        }
+
+    // re-issue request first
+    iIdPin.Subscribe(iStatus);
+    SetActive();
+
+    // then process property change
+    TState state(IdPin());
+
+    // report change   
+    switch (state)
+        {
+        case EIdPinOn:
+            {
+            LOG("IdPin ON");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->IdPinOnL();
+                }
+            break;
+            }
+
+        case EIdPinOff:
+            {
+            LOG("IdPin OFF");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->IdPinOffL();
+                }
+            break;
+            }
+
+        default:
+            {
+            LOG("WrongIdPinState");
+            PANIC( EWrongIdPinState);
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::DoCancel()
+    {
+    iIdPin.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbIdPinObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d", aError);
+
+    // try to continue	
+    return KErrNone;
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,234 @@
+/*
+ * 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:  Blink/show Usb indicator notifier implementation
+ *
+ */
+
+#include <AknSmallIndicator.h>
+#include <avkon.hrh>
+#include <usbuinotif.h>
+
+#include "cusbindicatornotifier.h"
+#include "cusbstate.h"
+#include "definitions.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier* CUsbIndicatorNotifier::NewL(
+        CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher)
+    {
+    LOG_FUNC
+
+    CUsbIndicatorNotifier* self = new (ELeave) CUsbIndicatorNotifier(
+            aNotifManager, aOtgWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier::~CUsbIndicatorNotifier()
+    {
+    LOG_FUNC
+
+    Close();
+
+    if (iOtgWatcher.VBusObserver())
+        {
+        TRAP_IGNORE(iOtgWatcher.VBusObserver()->UnsubscribeL(*this));
+        }
+
+    // Unsubscribe from otg watcher states change notifications
+    TRAP_IGNORE(iOtgWatcher.UnsubscribeL(*this));
+    }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier::CUsbIndicatorNotifier(CUsbNotifManager& aNotifManager,
+        CUsbOtgWatcher& aOtgWatcher) :
+    CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher(
+            aOtgWatcher)
+    {
+    LOG_FUNC
+
+    //To be changed to EAknIndicatorStateAnimate and remove iIconBlinkingTimer
+    //when AVKON implements animation form of usb indicator.
+    iIndicatorState = EAknIndicatorStateOn;
+    }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::ConstructL()
+    {
+    LOG_FUNC
+
+    // Subscribe for VBus change notifications
+    iOtgWatcher.VBusObserver()->SubscribeL(*this);
+
+    // Subscribe for otg watcher states change notifications
+    iOtgWatcher.SubscribeL(*this);
+
+    // check here for condition to set usb indicator
+    SetIndicatorL();
+    }
+
+// ---------------------------------------------------------------------------
+// Show/hide static icon of the indicator. 
+// If the indicator is blinking, stop blinking it and show/hide the static 
+// form of the indicator.
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::ShowStaticL(TBool aVisible)
+    {
+    LOG_FUNC
+
+    LOG1("aVisible = %d" , aVisible);
+
+    SetIndicatorStateL(aVisible
+                                ? EAknIndicatorStateOn
+                                   : EAknIndicatorStateOff);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::BlinkL()
+    {
+    LOG_FUNC
+
+    SetIndicatorStateL( EAknIndicatorStateAnimate );
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::ShowL()
+    {
+    LOG_FUNC
+
+    ShowStaticL(ETrue);
+    }
+
+// ---------------------------------------------------------------------------
+// From CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::Close()
+    {
+    LOG_FUNC
+
+    TRAP_IGNORE( ShowStaticL(EFalse) );
+    }
+
+// ---------------------------------------------------------------------------
+// Set USB indicator On or Off
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::SetIndicatorStateL(const TInt aState)
+    {
+
+    LOG1( "USB indicator State = %d" , aState);
+
+    CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC(TUid::Uid(
+            EAknIndicatorUSBConnection));
+    indicator->SetIndicatorStateL(aState);
+    CleanupStack::PopAndDestroy(indicator); //indicator    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState)
+    {
+    SetIndicatorL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::VBusDownL()
+    {
+    SetIndicatorL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::VBusUpL()
+    {
+    SetIndicatorL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CUsbIndicatorNotifier::VBusObserverErrorL(TInt aError)
+    {
+    // do nothing
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CUsbIndicatorNotifier::SetIndicatorL()
+    {
+    if (!(iOtgWatcher.IsDeviceA()) || iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAPeripheral)
+        {
+        // if B or peripheral, than other party (usbwatcher) takes care of usb indicator
+        // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator 
+        return;
+        }
+
+    // if VBus Up and we are host -> show indicator
+    if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
+            && (iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAHost))
+        {
+        ShowStaticL(ETrue);
+        }
+    // if VBus up and we are not host -> Blink indicator
+    else if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
+            && (iOtgWatcher.CurrentHostState()->Id() != EUsbStateHostAHost))
+        {
+        BlinkL();
+        }
+    else
+    // Otherwise do not show indicator
+        {
+        ShowStaticL(EFalse);
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,236 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbman.h>
+#include <d32usbdi_errors.h>
+#include <d32otgdi_errors.h>
+
+#include "cusbmessagenotificationobserver.h"
+
+#include "definitions.h" 
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver::CUsbMessageNotificationObserver(RUsb* aUsb) :
+    CActive(EPriorityStandard), iUsb(aUsb)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver* CUsbMessageNotificationObserver::NewL(
+        RUsb* aUsb)
+    {
+    LOG_FUNC
+
+    CUsbMessageNotificationObserver* self =
+            new (ELeave) CUsbMessageNotificationObserver(aUsb);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver::~CUsbMessageNotificationObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::SubscribeL(
+        MUsbMessageNotificationObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG("Observer already exists");
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iUsb->MessageNotification(iStatus, iMessage);
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::UnsubscribeL(
+        MUsbMessageNotificationObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG("Observer not found" )
+        PANIC( ECanNotFindMessageNotificationObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no items
+        {
+        // cancel pending request
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::RunL()
+    {
+    // Log the event
+    LOG1( "Message notification observer iMessage = %d" , iMessage);
+
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->MessageNotificationErrorL(iStatus.Int());
+            }
+        return;
+        }
+
+    TInt message(iMessage);
+
+    // re-issue request first
+    iUsb->MessageNotification(iStatus, iMessage);
+    SetActive();
+
+    // then process property change
+    switch (message)
+        {
+        case KErrUsbBadHubPosition:
+            {
+            LOG("HubBadPosition" );
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BadHubPositionL();
+                }
+            break;
+            }
+        case KErrUsbOtgVbusError:
+            {
+            LOG( "VBusError");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->VBusErrorL();
+                }
+            break;
+            }
+        case KUsbMessageSrpReceived:
+            {
+            LOG("SRP received" );
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->SrpReceivedL();
+                }
+            break;
+            }
+        case KUsbMessageRequestSession:
+            {
+            LOG("Session requested" );
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->SessionRequestedL();
+                }
+            break;
+            }
+            // notify states with other messages  
+        default:
+            {
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->MessageNotificationReceivedL(message);
+                }
+            break;
+            }
+
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::DoCancel()
+    {
+    iUsb->MessageNotificationCancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbMessageNotificationObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d" , aError);
+
+    // try to recover and continue	
+    return KErrNone;
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbnotenotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,168 @@
+/*
+ * 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:  Base classes for Usb notifier wrapper
+ *
+ */
+
+#include "cusbnotifmanager.h"
+#include "cusbnotenotifier.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbNoteNotifier::CUsbNoteNotifier(RNotifier& aNotifier,
+        CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId) :
+    CUsbNotifier(aNotifManager, aCat, aNotifId), iNotifier(aNotifier)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::ConstructL()
+    {
+    LOG_FUNC
+
+    iNotifierActive = new (ELeave) CUsbNoteNotifier::CNotifierActive(
+            iNotifier, *this);
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbNoteNotifier::~CUsbNoteNotifier()
+    {
+    LOG_FUNC
+
+    delete iNotifierActive;
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::ShowL()
+    {
+    LOG_FUNC
+
+    LOG2( "aCat = 0x%X aNotifId = 0x%X" , iCat, iNotifId);
+
+    iNotifierActive->StartL();
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::Close()
+    {
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// C++ default constructor
+// ---------------------------------------------------------------------------
+//
+CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier,
+        CUsbNoteNotifier& aUsbNoteNotifier) :
+    CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard),
+            iUsbNoteNotifier(aUsbNoteNotifier), iNotifier(aNotifier), iRes(0)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbNoteNotifier::CNotifierActive::~CNotifierActive()
+    {
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// Start to show the notifier
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::CNotifierActive::StartL()
+    {
+    LOG_FUNC
+
+    if (IsActive())
+        {
+        PANIC( ENotifierIsActiveAlready);
+        return;
+        }
+
+    iNotifIdPckg() = iUsbNoteNotifier.iNotifId;
+    iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier.iCat,
+            iNotifIdPckg, iRes);
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CActive
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::CNotifierActive::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
+
+    // if error occured, deal with it in RunError
+    LEAVEIFERROR(iStatus.Int());
+
+    iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
+
+    // report to owner that show is over
+    iUsbNoteNotifier.iNotifManager.NotifierShowCompletedL(iUsbNoteNotifier,
+            KErrNone, iRes());
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CActive
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::CNotifierActive::DoCancel()
+    {
+    iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
+    }
+
+// ---------------------------------------------------------------------------
+// From base class CActive
+// ---------------------------------------------------------------------------
+//
+TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1("aError = %d" , aError);
+
+    iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
+
+    // try to continue  
+    return KErrNone;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,64 @@
+/*
+ * 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:  Base classes for Usb notifier wrapper
+ *
+ */
+
+#include "cusbnotifmanager.h"
+#include "cusbnotifier.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Desctructor
+// ---------------------------------------------------------------------------
+//
+CUsbNotifier::~CUsbNotifier()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// Getter for returning if the notifier needs input from end-user
+// ---------------------------------------------------------------------------
+//
+TBool CUsbNotifier::IsFeedbackNeeded() const
+    {
+    return iIsFeedbackNeeded;
+    }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbNotifier::CUsbNotifier(CUsbNotifManager& aNotifManager, TUid aCat,
+        TUint aNotifId) :
+    iNotifManager(aNotifManager), iCat(aCat), iNotifId(aNotifId),
+            iIsFeedbackNeeded(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Set by child-classe if the concrete notifier needs feedback from end-user
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifier::SetFeedbackNeeded()
+    {
+    iIsFeedbackNeeded = ETrue;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbnotifmanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,241 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbuinotif.h> 
+
+#include "cusbnotifmanager.h"
+#include "cusbwaitnotifier.h"
+#include "cusbwarningnotifier.h"
+#include "cusbindicatornotifier.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CWaitNotifierInfo::CWaitNotifierInfo(CUsbNotifier* aWaitNotifier,
+        MWaitNotifierObserver& aObserver) :
+    iWaitNotifier(aWaitNotifier), iObserver(aObserver)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CWaitNotifierInfo::ConstructL()
+    {
+    LOG_FUNC
+    // owenrship for iWaitNotifier transferred in default constructor.
+    // this object is responsible for deletion of the iWaitNotifier then	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CWaitNotifierInfo* CWaitNotifierInfo::NewL(CUsbNotifier* aWaitNotifier,
+        MWaitNotifierObserver& aObserver)
+    {
+    LOG_FUNC
+
+    CWaitNotifierInfo* self = new (ELeave) CWaitNotifierInfo(aWaitNotifier,
+            aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CWaitNotifierInfo::~CWaitNotifierInfo()
+    {
+    LOG_FUNC
+    delete iWaitNotifier;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbNotifier* CWaitNotifierInfo::WaitNotifier() const
+    {
+    return iWaitNotifier;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+MWaitNotifierObserver* CWaitNotifierInfo::Observer() const
+    {
+    return &iObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher& aOtgWatcher)
+    {
+    LOG_FUNC
+
+    CUsbNotifManager* self = new (ELeave) CUsbNotifManager();
+    CleanupStack::PushL(self);
+    self->ConstructL(aOtgWatcher);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ConstructL(CUsbOtgWatcher& aOtgWatcher)
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(iNotifier.Connect());
+
+    iIndicatorNotifier = CUsbIndicatorNotifier::NewL(*this, aOtgWatcher);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::CUsbNotifManager()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::~CUsbNotifManager()
+    {
+    LOG_FUNC
+
+    CloseAllNotifiers();
+
+    delete iIndicatorNotifier;
+
+    iNotifier.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId,
+        MWaitNotifierObserver* aObserver)
+    {
+    LOG_FUNC
+
+    LOG3( "aCat = 0x%X aNotifId = %d, aObserver=0x%X" , aCat, aNotifId, aObserver);
+
+    // remove non-feedback notifiers from the list
+    for (TUint i(0); i < iWaitNotifiers.Count(); ++i)
+        {
+        CWaitNotifierInfo* waitNotifierInfo = iWaitNotifiers[i];
+        if (!(waitNotifierInfo->WaitNotifier()->IsFeedbackNeeded()))
+            {
+            delete waitNotifierInfo;
+            iWaitNotifiers.Remove(i);
+            }
+        }
+    //If not suspened a short while between closing a present note and showing a new one,
+    //error - CUsbWaitNotifier::RunL iStatus = 4 - will happen. Necessary here to pause a while 
+    //to allow notfier framework to do some cleaning work.
+    //Should find another way to solve this problem.
+    const TUint KTenthOfASecond = 100000;
+    User::After(TTimeIntervalMicroSeconds32(KTenthOfASecond));
+
+    // can not have switch-case selector here, due to constants are of type Uids
+    // notifier requires feedback => create CWaitNotifier for it
+    // As notifiers can be more than two types such as warning, error, indicator ...
+    // to create concret notifiers according to categories instead of checking aObserver null
+    CUsbNotifier* notifier(NULL);
+    if (aCat == KUsbUiNotifOtgError)
+        {
+        ASSERT_PANIC(aObserver != NULL, EWrongNotifierCategory);
+        notifier = CUsbWaitNotifier::NewL(iNotifier, *this, aNotifId);
+        }
+    else if (aCat == KUsbUiNotifOtgWarning)
+        {
+        notifier = CUsbWarningNotifier::NewL(iNotifier, *this, aNotifId);
+        }
+    else
+        {
+        LOG1("Unexpected aCat = 0x%X", aCat );
+        PANIC(EWrongNotifierCategory);
+        }
+
+    CleanupStack::PushL(notifier);
+
+    iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, *aObserver));
+
+    notifier->ShowL();
+
+    CleanupStack::Pop(notifier);
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier& aWaitNotifier,
+        TInt aResult, TInt aFeedback)
+    {
+    LOG_FUNC
+
+    LOG1( "aResult = %d", aResult);
+
+    // remove Notifier from the list
+    for (TUint i(0); i < iWaitNotifiers.Count(); ++i)
+        {
+        if (&aWaitNotifier == iWaitNotifiers[i]->WaitNotifier())
+            {
+            MWaitNotifierObserver* observer = iWaitNotifiers[i]->Observer();
+
+            delete iWaitNotifiers[i];
+            iWaitNotifiers.Remove(i);
+
+            if (observer)
+                observer->WaitNotifierCompletedL(aFeedback);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::CloseAllNotifiers()
+    {
+    LOG_FUNC
+
+    iWaitNotifiers.ResetAndDestroy();
+    iIndicatorNotifier->Close();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,277 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbotgstateobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::CUsbOtgStateObserver() :
+    CActive(EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(iOtgState.Attach(KUidUsbManCategory,
+            KUsbOtgStateProperty));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver* CUsbOtgStateObserver::NewL()
+    {
+    LOG_FUNC
+
+    CUsbOtgStateObserver* self = new (ELeave) CUsbOtgStateObserver();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::~CUsbOtgStateObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iOtgState.Close();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbOtgState CUsbOtgStateObserver::OtgState()
+    {
+    TInt val(0);
+
+    TInt err = iOtgState.Get(val);
+
+    if (KErrNone != err)
+        {
+        LOG("CanNotGetOtgStateProperty" );
+        PANIC( ECanNotGetOtgStateProperty);
+        }
+
+    return (TUsbOtgState) val;
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG( "Observer already exists"  );
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iOtgState.Subscribe(iStatus);
+        SetActive();
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG("Observer not found");
+        PANIC( ECanNotFindOtgStateObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no observers anymore
+        {
+        // cancel pending request
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
+
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->OtgStateErrorL(iStatus.Int());
+            }
+        return;
+        }
+
+    // re-issue request first
+    iOtgState.Subscribe(iStatus);
+    SetActive();
+
+    // then process property change
+    TUsbOtgState state(OtgState());
+
+    switch (state)
+        {
+        case EUsbOtgStateReset:
+            {
+            LOG("OTGState == RESET" );
+            break;
+            }
+        case EUsbOtgStateAIdle:
+            {
+            LOG("OTGState == AIdle" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->AIdleL();
+                }
+            break;
+            }
+        case EUsbOtgStateAHost:
+            {
+            LOG( "OTGState == AHost");
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->AHostL();
+                }
+            break;
+            }
+        case EUsbOtgStateAPeripheral:
+            {
+            LOG("OTGState == APeripheral" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->APeripheralL();
+                }
+            break;
+            }
+        case EUsbOtgStateAVbusError:
+            {
+            LOG("OTGState == AVBusError" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->AVBusErrorL();
+                }
+            break;
+            }
+        case EUsbOtgStateBIdle:
+            {
+            LOG( "OTGState == BIdle" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BIdleL();
+                }
+            break;
+            }
+        case EUsbOtgStateBPeripheral:
+            {
+            LOG("OTGState == BPeripheral" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BPeripheralL();
+                }
+            break;
+            }
+        case EUsbOtgStateBHost:
+            {
+            LOG("OTGState == BHost" );
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->BHostL();
+                }
+            break;
+            }
+        default:
+            {
+            LOG("WrongOtgState" );
+            PANIC( EWrongOtgState);
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::DoCancel()
+    {
+    iOtgState.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbOtgStateObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d" , aError);
+
+    // try to continue	
+    return KErrNone;
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbotgwatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1126 @@
+/*
+ * 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:  Implementation
+ *
+ */
+#include <usbpersonalityids.h>
+#include <usbuinotif.h>
+#include <UsbWatcherInternalPSKeys.h>
+#include "cusbotgwatcher.h"
+#include "cusbstate.h"
+#include "cusbstatehostainitiate.h"
+#include "cusbstatehostahost.h"
+#include "cusbstatehostaperipheral.h"
+#include "cusbstatehosthandle.h"
+#include "cusbstatehostdelayhandle.h"
+#include "cusbstatehostdelayattachedhandle.h"
+#include "cusbstatehostdelaynotattachedhandle.h"
+#include "cusbstatehosthandledropping.h"
+#include "cusbstatehostundefined.h"
+#include "cusbwarningnotifier.h"
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#else
+#include "mockcusbnotifmanager.h"
+#endif
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+_LIT_SECURITY_POLICY_PASS( KAlwaysPassPolicy );
+_LIT_SECURITY_POLICY_C1( KLocalServicesPolicy, ECapabilityLocalServices );
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgWatcher::CUsbOtgWatcher(RUsb& aUsbMan) :
+    iUsb(aUsbMan), iPersonalityId(KUsbPersonalityIdMTP), iUsbServiceRequest(
+            CUsbServiceControl::ERequestUndefined)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ConstructL()
+    {
+    LOG_FUNC
+
+#ifdef _DEBUG
+    SelfTestL();
+#endif
+
+#ifndef STIF
+    LEAVEIFERROR(RProperty::Define(KPSUidUsbWatcher,
+                    KUsbWatcherIsPeripheralConnected, RProperty::EInt,
+                    KAlwaysPassPolicy, KLocalServicesPolicy));
+
+    LEAVEIFERROR(RProperty::Set(KPSUidUsbWatcher,
+                    KUsbWatcherIsPeripheralConnected,
+                    KUsbWatcherPeripheralIsNotConnected));
+#endif
+
+    iUsbServiceControl = CUsbServiceControl::NewL(*this, iUsb);
+
+    LEAVEIFERROR(iStates.Append(CUsbStateHostUndefined::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAInitiate::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAHost::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAPeripheral::NewL(*this)));
+
+    LEAVEIFERROR(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL(
+                            *this)));
+    LEAVEIFERROR(iStates.Append(
+                    CUsbStateHostDelayNotAttachedHandle::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(
+                    CUsbStateHostHandleDropping::NewL(*this)));
+
+    iIdPinObserver = CUsbIdPinObserver::NewL();
+    iVBusObserver = CUsbVBusObserver::NewL();
+    iOtgStateObserver = CUsbOtgStateObserver::NewL();
+    iBusActivityObserver = CUsbBusActivityObserver::NewL();
+    iHostEventNotificationObserver = CUsbHostEventNotificationObserver::NewL(
+            &iUsb);
+    iMessageNotificationObserver = CUsbMessageNotificationObserver::NewL(
+            &iUsb);
+
+    iHostState = iStates[EUsbStateHostUndefined];
+
+    // Notif manager must be created at least after VBus observer and iHostState initialization
+    // to allow USb indicator subscribe to its notifications at construction and check their's current states
+    iNotifManager = CUsbNotifManager::NewL(*this);
+
+    iVBusObserver->SubscribeL(*this);
+    iOtgStateObserver->SubscribeL(*this);
+    iBusActivityObserver->SubscribeL(*this);
+    iHostEventNotificationObserver->SubscribeL(*this);
+    iMessageNotificationObserver->SubscribeL(*this);
+    iIdPinObserver->SubscribeL(*this);
+
+    if (CUsbIdPinObserver::EIdPinOn == iIdPinObserver->IdPin())
+        {
+        StartSessionL();
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CUsbOtgWatcher::IsDeviceA()
+    {
+    ASSERT_PANIC(iIdPinObserver != NULL, EIdPinObserverNULLPointer);
+    return (iIdPinObserver->IdPin() == CUsbIdPinObserver::EIdPinOn
+                                                                   ? ETrue
+                                                                      : EFalse);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUsbOtgWatcher* CUsbOtgWatcher::NewL(RUsb& aUsbMan)
+    {
+    LOG_FUNC
+
+    CUsbOtgWatcher* self = new (ELeave) CUsbOtgWatcher(aUsbMan);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgWatcher::~CUsbOtgWatcher()
+    {
+    LOG_FUNC
+
+#ifndef STIF
+    RProperty::Delete(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected);
+#endif
+
+    // delete Notif manager before VBus observer, due to USB indicator observes VBus
+    delete iNotifManager;
+
+    if (iIdPinObserver)
+        {
+        TRAP_IGNORE(iIdPinObserver->UnsubscribeL(*this));
+        }
+
+    if (iVBusObserver)
+        {
+        TRAP_IGNORE(iVBusObserver->UnsubscribeL(*this));
+        }
+    if (iOtgStateObserver)
+        {
+        TRAP_IGNORE(iOtgStateObserver->UnsubscribeL(*this));
+        }
+    if (iBusActivityObserver)
+        {
+        TRAP_IGNORE(iBusActivityObserver->UnsubscribeL(*this));
+        }
+    if (iHostEventNotificationObserver)
+        {
+        TRAP_IGNORE(iHostEventNotificationObserver->UnsubscribeL(*this));
+        }
+    if (iMessageNotificationObserver)
+        {
+        TRAP_IGNORE(iMessageNotificationObserver->UnsubscribeL(*this));
+        }
+
+    delete iIdPinObserver;
+    delete iVBusObserver;
+    delete iOtgStateObserver;
+    delete iBusActivityObserver;
+    delete iHostEventNotificationObserver;
+    delete iMessageNotificationObserver;
+
+    iOtgStateObservers.Close();
+
+    // Destroy states
+    iStates.ResetAndDestroy();
+    iStates.Close();
+
+    delete iUsbServiceControl;
+
+    iUsb.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPersonalityL(TRequestStatus& /*aStatus*/,
+        TInt aPersonality)
+    {
+    LOG_FUNC
+
+    LOG1( "aPersonality = %d" , aPersonality);
+
+    // watcher keeps this value, no need to pass it to request object
+    // state can read it from watcher when needed
+    iPersonalityId = aPersonality;
+
+    // more complex processing has to be here, remember aStatus, etc.
+    // pass the request to device state machine
+    iState->SetPersonalityL();
+
+    // the request is not passed to host state machine due to host ignores SetPersonality
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::CancelSetPersonalityL()
+    {
+    LOG_FUNC
+
+    iState->CancelSetPersonalityL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPersonalityL(TRequestStatus& /*aStatus*/)
+    {
+    LOG_FUNC
+
+    // maybe more complex processing needed here
+    iState->SetPreviousPersonalityL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPersonalityL()
+    {
+    LOG_FUNC
+
+    iState->SetPreviousPersonalityL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::CancelSetPreviousPersonalityL()
+    {
+    LOG_FUNC
+
+    iState->CancelSetPreviousPersonalityL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPreviousPersonalityOnDisconnectL()
+    {
+    LOG_FUNC
+
+    }
+
+// From IdPin observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::StartSessionL()
+    {
+    LOG_FUNC
+
+    if (!CanStartSessionL())
+        {
+        HandleHostProblemL(EUsbWatcherCanNotStartSession,
+                EUsbStateHostHandleDropping);
+        return;
+        }
+
+    iUsbServiceRequest = CUsbServiceControl::EStartUsbService;
+    TInt err = iUsbServiceControl->StartL(iPersonalityId);
+    if (KErrNone != err)
+        {
+        LOG1( "Can not start usb services. err = %d" , err);
+        HandleHostProblemL(EUsbWatcherCanNotStartUsbServices,
+                EUsbStateHostHandleDropping);
+        return;
+        }
+
+    // call back from iUsbServiceControl->Start(iPersonalityId) call is UsbServiceControlReqCompletedL(TInt aError)
+    // so, continue there if everything is OK
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::HandleHostProblemL(TInt aWhatKindOf,
+        TUsbStateIds aInState)
+    {
+    LOG_FUNC
+    HostHandle(aInState)->SetWhat(aWhatKindOf);
+    ChangeHostStateL(aInState);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinOnL()
+    {
+    LOG_FUNC
+    StartSessionL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinOffL()
+    {
+    LOG_FUNC
+
+    ChangeHostStateL(EUsbStateHostUndefined);
+
+    iNotifManager->CloseAllNotifiers();
+
+    Usb().DisableFunctionDriverLoading();
+
+    iUsbServiceRequest = CUsbServiceControl::EStopUsbService;
+    TInt err = iUsbServiceControl->StopL();
+
+    LOG1( "iUsbServiceControl->Stop() err = %d", err );
+
+    if (KErrNone != err)
+        {
+        LOG( "ErrorStoppingUsbServices" );
+        PANIC(ECanNotStopUsbServices);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    HandleHostProblemL(EUsbWatcherIdPinError, EUsbStateHostHandleDropping);
+
+    }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusDownL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->VBusDownL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusUpL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->VBusUpL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusObserverErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    HandleHostProblemL(EUsbWatcherVBusObserverError,
+            EUsbStateHostHandleDropping);
+    }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AIdleL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->AIdleL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AHostL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->AHostL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::APeripheralL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->APeripheralL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AVBusErrorL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->AVBusErrorL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BIdleL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BIdleL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BPeripheralL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BPeripheralL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BHostL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BHostL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::OtgStateErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    HandleHostProblemL(EUsbWatcherOtgStateError, EUsbStateHostHandleDropping);
+    }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusIdleL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BusIdleL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusActiveL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BusActiveL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusActivityErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    // no action, continue
+    }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DeviceAttachedL(TDeviceEventInformation aTdi)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->DeviceAttachedL(aTdi);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DeviceDetachedL(TDeviceEventInformation aTdi)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->DeviceDetachedL(aTdi);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadSuccessL(TDeviceEventInformation aTdi)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->DriverLoadSuccessL(aTdi);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadPartialSuccessL(TDeviceEventInformation aTdi)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->DriverLoadPartialSuccessL(aTdi);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadFailureL(TDeviceEventInformation aTdi)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->DriverLoadFailureL(aTdi);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::HostEventNotificationErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    HandleHostProblemL(EUsbWatcherHostEventNotificationError,
+            EUsbStateHostHandleDropping);
+    }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::MessageNotificationReceivedL(TInt aMessage)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->MessageNotificationReceivedL(aMessage);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BadHubPositionL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->BadHubPositionL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusErrorL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->VBusErrorL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SrpReceivedL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->SrpReceivedL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SessionRequestedL()
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    iHostState->SessionRequestedL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::MessageNotificationErrorL(TInt aError)
+    {
+    ASSERT_PANIC(iHostState != NULL, EBadHostState);
+    HandleHostProblemL(EUsbWatcherMessageNotificationError,
+            EUsbStateHostHandleDropping);
+    }
+
+// ---------------------------------------------------------------------------
+// getters
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver* CUsbOtgWatcher::IdPinObserver() const
+    {
+    return iIdPinObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver* CUsbOtgWatcher::VBusObserver() const
+    {
+    return iVBusObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver* CUsbOtgWatcher::OtgStateObserver() const
+    {
+    return iOtgStateObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver* CUsbOtgWatcher::BusActivityObserver() const
+    {
+    return iBusActivityObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver* CUsbOtgWatcher::HostEventNotificationObserver() const
+    {
+    return iHostEventNotificationObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver* CUsbOtgWatcher::MessageNotificationObserver() const
+    {
+
+    return iMessageNotificationObserver;
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+RUsb& CUsbOtgWatcher::Usb()
+    {
+    return iUsb;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbState* CUsbOtgWatcher::CurrentState() const
+    {
+    return iState;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbState* CUsbOtgWatcher::CurrentHostState() const
+    {
+    return iHostState;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbState* CUsbOtgWatcher::State(TUsbStateIds aStateId) const
+    {
+    return iStates[aStateId];
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle* CUsbOtgWatcher::HostHandle(TUsbStateIds aInState) const
+    {
+    ASSERT_PANIC(iStates[aInState] != NULL, EBadState);
+
+    return (CUsbStateHostHandle*) iStates[aInState];
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ChangeStateL(TUsbStateIds aNewStateId)
+    {
+    LOG_FUNC
+
+    LOG1( "aNewState = %d" , aNewStateId);
+
+    if (NULL != iState)
+        {
+        iState->JustBeforeLeavingThisStateL();
+        }
+
+    // sets new state	
+
+    // be careful to add states into States in exactly the same order as they enumerated
+    // this method will work right as long as states, which in the enumeration, is added 
+    // to the list iStates in the same order as they enumerated and no one state is added,
+    // if all previous states are not added. no need to add all states, but if added - 
+    // previous all must be added.
+    // For the general case, when some states added, some not, this method has to implement search by state ID. for this CUsbOtgWatcher::Id() is maintained.
+
+    iState = iStates[aNewStateId];
+
+    ASSERT_PANIC(iState != NULL, EBadState);
+
+    iState->JustAdvancedToThisStateL(); // do any initial activity, once advanced to the state
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ChangeHostStateL(TUsbStateIds aNewStateId)
+    {
+    LOG_FUNC
+
+    LOG1( "aNewState = %d", aNewStateId);
+
+    if (NULL != iHostState)
+        {
+        iHostState->JustBeforeLeavingThisStateL();
+        }
+
+    // set new state	
+
+    // be careful to add states into States in exactly the same order as they enumerated
+    // this method will work right as long as states, which in the enumeration, is added 
+    // to the list iStates in the same order as they enumerated and no one state is added,
+    // if all previous states are not added. no need to add all states, but if added - 
+    // previous all must be added.
+    // For the general case, when some states added, some not, this method has to implement search by state ID. for this CUsbOtgWatcher::Id() is maintained.
+
+    iHostState = iStates[aNewStateId];
+
+    ASSERT_PANIC(iHostState != NULL, EBadState)
+
+    iHostState->JustAdvancedToThisStateL(); // checks if there are conditions for advancing to another state(s)
+
+    // notify state change to observers
+    for (TInt i(0); i < iOtgStateObservers.Count(); ++i)
+        {
+        iOtgStateObservers[i]->OtgWatcherStateChangedL(iHostState->Id());
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CUsbOtgWatcher::CanStartSessionL()
+    {
+    // define policy here
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::PrintStateToLog()
+    {
+    LOG1( "Current state id  = %d" , iHostState->Id());
+    LOG1( "IdPin             = %d" , iIdPinObserver->IdPin());
+    LOG1( "VBus              = %d" , iVBusObserver->VBus());
+    LOG1( "OtgState          = %d" , iOtgStateObserver->OtgState());
+    LOG1( "BusActivity       = %d" , iBusActivityObserver->BusActivity());
+
+    TInt isPeripheralConnected(KUsbWatcherPeripheralIsNotConnected);
+
+    RProperty::Get(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected,
+            isPeripheralConnected);
+
+    LOG1( "IsPeripheralConnected = %d" , isPeripheralConnected);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager* CUsbOtgWatcher::NotifManager()
+    {
+    return iNotifManager;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::UsbServiceControlReqCompletedL(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d" , aError);
+
+    iUsbServiceRequest = CUsbServiceControl::ERequestUndefined;
+
+    switch (aError)
+        {
+        case KErrInUse:
+            // usb services already started (this might happen if more than one idpin on event come)
+            {
+            return;
+            }
+
+        case KErrNone:
+            {
+            break; // do normal routine
+            }
+        case KErrNoMemory:
+            {
+            HandleHostProblemL(EUsbWatcherNoMemory,
+                    EUsbStateHostHandleDropping);
+            return;
+            }
+
+        default:
+            // handle the issue
+            {
+            if (iUsbServiceRequest == CUsbServiceControl::EStartUsbService) // Handle only start issues
+                {
+                HandleHostProblemL(EUsbWatcherNoMemory,
+                        EUsbStateHostHandleDropping);
+                }
+
+            iUsbServiceRequest = CUsbServiceControl::ERequestUndefined;
+            return;
+            }
+        }
+
+    iUsbServiceRequest = CUsbServiceControl::ERequestUndefined;
+
+    TUsbServiceState serviceState;
+    TInt err = iUsb.GetServiceState(serviceState);
+
+    if (KErrNone != err)
+        {
+        LOG1( "Error when requesting GetServiceState = %d" , err);
+        HandleHostProblemL(EUsbWatcherCanNotStartUsbServices,
+                EUsbStateHostHandleDropping);
+        return;
+        }
+
+    switch (serviceState)
+        {
+        case EUsbServiceIdle: // just stopped usb service
+
+            {
+            LOG("UsbServiceState == EUsbServiceIdle" );
+            // do nothing
+            break;
+            }
+
+        case EUsbServiceStarted: // just started usb service
+
+            {
+            LOG( "UsbServiceState == EUsbServiceStarted" );
+
+            ChangeHostStateL(EUsbStateHostAInitiate);
+
+            break;
+            }
+        case EUsbServiceStarting:
+            {
+            LOG("UsbServiceState == EUsbServiceStarting" );
+            // should not receive that, due to call back is called when service stopped or started
+            // therefore scream
+            PANIC(EUnexpectedUsbServiceState);
+            break;
+            }
+        case EUsbServiceStopping:
+            {
+            LOG("UsbServiceState == EUsbServiceStopping" );
+            // should not receive that, due to call back is called when service stopped or started
+            // therefore scream
+            PANIC(EUnexpectedUsbServiceState);
+            break;
+            }
+        case EUsbServiceFatalError:
+            {
+            LOG( "UsbServiceState == EUsbServiceFatalError" );
+            PANIC(EUnexpectedUsbServiceState);
+            break;
+            }
+
+        default:
+            {
+            PANIC(EUnknownUsbServiceState);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbOtgWatcher::SelfTestL()
+    {
+#ifdef _DEBUG
+    LOG_FUNC
+
+    // create all the observers
+    iIdPinObserver = CUsbIdPinObserver::NewL();
+    iVBusObserver = CUsbVBusObserver::NewL();
+    iOtgStateObserver = CUsbOtgStateObserver::NewL();
+    iBusActivityObserver = CUsbBusActivityObserver::NewL();
+    iHostEventNotificationObserver = CUsbHostEventNotificationObserver::NewL(
+            &iUsb);
+    iMessageNotificationObserver = CUsbMessageNotificationObserver::NewL(
+            &iUsb);
+
+    LOG( "Observers getters" );
+
+    if (iIdPinObserver != IdPinObserver())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    if (iOtgStateObserver != OtgStateObserver())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    if (iBusActivityObserver != BusActivityObserver())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    if (iHostEventNotificationObserver != HostEventNotificationObserver())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    if (iMessageNotificationObserver != MessageNotificationObserver())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    LOG( "Observers destructors" );
+
+    // idpinobserver is deleted later        
+    // Vbus observer is deleted later
+
+    delete iOtgStateObserver;
+    iOtgStateObserver = 0;
+    delete iBusActivityObserver;
+    iBusActivityObserver = 0;
+    delete iHostEventNotificationObserver;
+    iHostEventNotificationObserver = 0;
+    delete iMessageNotificationObserver;
+    iMessageNotificationObserver = 0;
+
+    LOG("Creating states");
+
+    LEAVEIFERROR(iStates.Append(CUsbStateHostUndefined::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAInitiate::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAHost::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostAPeripheral::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL(
+            *this)));
+    LEAVEIFERROR(iStates.Append(
+            CUsbStateHostDelayNotAttachedHandle::NewL(*this)));
+    LEAVEIFERROR(iStates.Append(
+            CUsbStateHostHandleDropping::NewL(*this)));
+
+    LOG("Check State()" );
+
+    if (iStates[EUsbStateHostAInitiate] != State(EUsbStateHostAInitiate))
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    LOG("Check CurrentHostState()" );
+
+    iHostState = iStates[EUsbStateHostAInitiate];
+
+    if (iStates[EUsbStateHostAInitiate] != CurrentHostState())
+        {
+        LEAVE(KErrGeneral);
+        }
+
+    LOG("NotifManager and WarningNotifier." );
+
+    CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL(*this);
+    RNotifier rnotifier;
+    LEAVEIFERROR(rnotifier.Connect());
+    CUsbWarningNotifier* usbnotifier = CUsbWarningNotifier::NewL(rnotifier,
+            *usbnotifmanager, EUsbOtgPartiallySupportedDevice);
+    usbnotifier->IsFeedbackNeeded();
+
+    LOG( "NotifManager and WarningNotifier destruction." );
+
+    delete usbnotifier;
+    rnotifier.Close();
+    delete usbnotifmanager;
+
+    // VBus observer is deleted here, due to it is used by usbnotifmanager.usbindicatornotifier
+    delete iVBusObserver;
+    iVBusObserver = 0;
+
+    // id pin observer is deleted here due to it is used by usbnotifmanager.usbindicatornotifier
+    delete iIdPinObserver;
+    iIdPinObserver = 0;
+
+    LOG("Destructing states");
+
+    iStates.ResetAndDestroy();
+
+    LOG( "Check UsbServiceControl" );
+
+    CUsbServiceControl* usbServiceControl = CUsbServiceControl::NewL(*this,
+            iUsb);
+    usbServiceControl->RunError(KErrNone);
+    delete usbServiceControl;
+
+    LOG("All completed OK" );
+#endif
+    return KErrNone;
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//   
+void CUsbOtgWatcher::SubscribeL(MUsbOtgWatcherStateObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iOtgStateObservers.Find(&aObserver))
+        {
+        LOG( "Observer already exists" );
+        PANIC(EObserverAlreadyExists);
+        return;
+        }
+    iOtgStateObservers.AppendL(&aObserver);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::UnsubscribeL(MUsbOtgWatcherStateObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iOtgStateObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG( "Observer not found" );
+        PANIC(ECanNotFindUsbOtgWatcherStateObserver);
+        return;
+        }
+
+    iOtgStateObservers.Remove(i);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbservicecontrol.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,406 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbman.h>
+
+#include "cusbservicecontrol.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbServiceControl::CUsbServiceControl(MUsbServiceControlObserver& aObserver,
+        RUsb& aUsb) :
+    CActive(CActive::EPriorityStandard), iObserver(aObserver), iUsb(aUsb),
+            iPersonalityId(0)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbServiceControl::~CUsbServiceControl()
+    {
+    LOG_FUNC
+
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::ConstructL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbServiceControl* CUsbServiceControl::NewL(
+        MUsbServiceControlObserver& aObserver, RUsb& aUsb)
+    {
+    LOG_FUNC
+
+    CUsbServiceControl* self = new (ELeave) CUsbServiceControl(aObserver,
+            aUsb);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self); // pop self
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::StartL(TInt aPersonalityId)
+    {
+    LOG_FUNC
+
+    LOG1( "aPersonalityId = %d" , aPersonalityId);
+
+    TUsbServiceState serviceState;
+    TInt err = iUsb.GetServiceState(serviceState);
+
+    if (KErrNone != err)
+        {
+        return err;
+        }
+
+    switch (serviceState)
+        {
+        case EUsbServiceIdle:
+            {
+            LOG( "UsbServiceState == EUsbServiceIdle" );
+
+            iPersonalityId = aPersonalityId; // when request completed, this will indicate that we started what we wanted
+            if (IsActive())
+                {
+                LOG("Request is outstanding, cancelling first" );
+                Cancel();
+                }
+            iUsb.TryStart(aPersonalityId, iStatus);
+            SetActive();
+            break;
+            }
+
+        case EUsbServiceStarted:
+            {
+            LOG("UsbServiceState == EUsbServiceStarted");
+
+            TInt currentPersonality(0);
+            err = iUsb.GetCurrentPersonalityId(currentPersonality);
+            if (KErrNone != err)
+                {
+                LOG1( "Error getting current personality err = %d" , err);
+                return err;
+                }
+
+            if (aPersonalityId == currentPersonality) // already started
+                {
+                LOG("Personality already started" );
+                iObserver.UsbServiceControlReqCompletedL(KErrInUse);
+                return KErrNone;
+                }
+
+            // we need to stop current personality and start service with new personailty id
+            iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality after
+
+            StopL();
+
+            // start new personality in RunL() when state is Idle
+
+            break;
+            }
+        case EUsbServiceStarting:
+            {
+            LOG("UsbServiceState == EUsbServiceStarting" );
+            // do exactly the same as in case of EUsbServiceStopping;
+            // break statement is not required here
+            }
+        case EUsbServiceStopping:
+            {
+            LOG( "UsbServiceState == EUsbServiceStopping" );
+
+            // subscribe for usb service state change, and start new usb service once current one started/stopped
+            iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality
+
+            // this check is needed due to usb service might be stopping by other client  
+            if (IsActive())
+                {
+                LOG( "Request outstanding. Waiting for completion" );
+                return KErrNone; // when the outstanding request get completed, we start usb services with iPersonalityId
+                }
+
+            // otherwise, monitor usb service state
+            iUsb.ServiceStateNotification(iServiceState, iStatus);
+            SetActive();
+
+            break;
+            }
+        case EUsbServiceFatalError:
+            {
+            LOG( "UsbServiceState == EUsbServiceFatalError" );
+            return KErrGeneral;
+            }
+        default:
+            {
+            PANIC( EUnknownUsbServiceState);
+            }
+        }
+
+    return KErrNone;
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::StopL()
+    {
+    LOG_FUNC
+
+    TUsbServiceState serviceState;
+    TInt err = iUsb.GetServiceState(serviceState);
+
+    LOG2("err = %d; serviceState = %d" , err, serviceState);
+
+    if (KErrNone != err)
+        {
+        return err;
+        }
+
+    switch (serviceState)
+        {
+        case EUsbServiceIdle:
+            {
+            LOG("UsbServiceState == EUsbServiceIdle" );
+
+            return KErrNone;
+            }
+
+        case EUsbServiceStarted:
+            {
+            LOG("UsbServiceState == EUsbServiceStarted" );
+
+            if (IsActive())
+                {
+                LOG("Request is outstanding, cancelling it" );
+                Cancel();
+                }
+            iUsb.TryStop(iStatus);
+            SetActive();
+
+            break;
+            }
+        case EUsbServiceStopping:
+            {
+            LOG( "UsbServiceState == EUsbServiceStopping" );
+            // do exactly the same as in case of EUsbServiceStarting;
+            // break statement is not required here
+            }
+        case EUsbServiceStarting:
+            {
+            LOG("UsbServiceState == EUsbServiceStarting" );
+
+            // subscribe for usb service state change, and stop usb service once current one started
+            iPersonalityId = 0; // this will indicate that we do not want to start this personality
+
+            // this check is needed due to usb service might be starting by other client  
+            if (IsActive())
+                {
+                LOG("Request is outstanding, waiting for completion" );
+                return KErrNone; // when this request get completed, we request to stop usb services
+                }
+
+            // otherwise, monitor usb service state
+            iUsb.ServiceStateNotification(iServiceState, iStatus);
+            SetActive();
+
+            break;
+            }
+        case EUsbServiceFatalError:
+            {
+            LOG("UsbServiceState == EUsbServiceFatalError" );
+            return KErrGeneral;
+            }
+        default:
+            {
+            PANIC( EUnknownUsbServiceState);
+            }
+        }
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::RunL()
+    {
+    LOG_FUNC
+
+    LOG1("iStatus = %d" , iStatus.Int());
+
+    if (KErrNone != iStatus.Int())
+        {
+        iObserver.UsbServiceControlReqCompletedL(iStatus.Int());
+        return;
+        }
+
+    TUsbServiceState serviceState;
+    TInt err = iUsb.GetServiceState(serviceState);
+
+    if (KErrNone != err)
+        {
+        LOG1("Error while getting service state %d" , err);
+        iObserver.UsbServiceControlReqCompletedL(err);
+        return;
+        }
+
+    switch (serviceState)
+        {
+        case EUsbServiceIdle: // usb service stopped
+            {
+            LOG("UsbServiceState == EUsbServiceIdle" );
+
+            if (iPersonalityId != 0) // during service stopping, requested to start it
+                {
+                LOG1("Requested to start personality %d. Starting it." , iPersonalityId);
+                TInt personalityId = iPersonalityId;
+                iPersonalityId = 0; // reset
+                err = StartL(personalityId);
+                if (KErrNone != err)
+                    {
+                    iObserver.UsbServiceControlReqCompletedL(err);
+                    }
+                return;
+                }
+
+            // otherwise, we've done, notify
+            iObserver.UsbServiceControlReqCompletedL(KErrNone);
+            break;
+            }
+
+        case EUsbServiceStarted:
+            {
+            LOG("UsbServiceState == EUsbServiceStarted" );
+
+            TInt currentPersonality(0);
+            err = iUsb.GetCurrentPersonalityId(currentPersonality);
+            if (KErrNone != err)
+                {
+                LOG1("Error while getting PersonalityId err = %d" , err);
+                iObserver.UsbServiceControlReqCompletedL(err);
+                return;
+                }
+
+            if (iPersonalityId == currentPersonality) // already done
+                {
+                LOG("Personality already started" );
+                iPersonalityId = 0;
+                iObserver.UsbServiceControlReqCompletedL(KErrNone);
+                return;
+                }
+
+            if (iPersonalityId == 0) // during service start requested to stop it
+                {
+                LOG("Requested to stop personality. Stopping." );
+                err = StopL();
+                if (KErrNone != err)
+                    {
+                    LOG1("Error while stopping personality err = %d" , err);
+                    iObserver.UsbServiceControlReqCompletedL(err);
+                    }
+                return;
+                }
+
+            // otherwise, during service start, requested to start it with another personality
+            LOG1( "Requested to start personality %d. Starting it.", iPersonalityId);
+            TInt personalityId = iPersonalityId;
+            iPersonalityId = 0; // reset
+            err = StartL(personalityId);
+            if (KErrNone != err)
+                {
+                LOG1("Error while starting personality err = %d" , err);
+                iObserver.UsbServiceControlReqCompletedL(err);
+                }
+            break;
+            }
+
+        case EUsbServiceStarting:
+            {
+            // do exactly same as in EUsbServiceStopping
+            // break statement is not required here
+            LOG("State == EUsbServiceStarting. Continue." );
+            }
+        case EUsbServiceStopping:
+            {
+            // we are not interested in these states, just continue monitoring
+            LOG("State == EUsbServiceStopping. Continue." );
+            iUsb.ServiceStateNotification(iServiceState, iStatus);
+            SetActive();
+            break;
+            }
+        case EUsbServiceFatalError:
+            {
+            LOG("UsbServiceState == EUsbServiceFatalError" );
+            iObserver.UsbServiceControlReqCompletedL(KErrGeneral);
+            break;
+            }
+        default:
+            {
+            PANIC( EUnknownUsbServiceState);
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::RunError(TInt aError)
+    {
+    LOG_FUNC
+    LOG1("aError = %d", aError );
+    TRAP_IGNORE(iObserver.UsbServiceControlReqCompletedL(aError));
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::DoCancel()
+    {
+    LOG( "Cancelling interest to Usb TryStart.")
+    iUsb.CancelInterest(RUsb::ETryStart);
+    LOG( "Cancelling interest to Usb TrySop.")
+    iUsb.CancelInterest(RUsb::ETryStop);
+    LOG("Cancelling interest to usb states notifications.")
+    iUsb.ServiceStateNotificationCancel();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstate.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,377 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbotgwatcher.h"
+#include "cusbstate.h"
+
+#include "panic.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbState::CUsbState(CUsbOtgWatcher& aWatcher) :
+    iWatcher(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbState::~CUsbState()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::ConstructL()
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::JustAdvancedToThisStateL()
+    {
+    iWatcher.PrintStateToLog();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::JustBeforeLeavingThisStateL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::ChangeStateL(TUsbStateIds aNewStateId)
+    {
+
+    iWatcher.ChangeStateL(aNewStateId);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::ChangeHostStateL(TUsbStateIds aNewStateId)
+    {
+
+    iWatcher.ChangeHostStateL(aNewStateId);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::HandleL(TInt aWhat, TUsbStateIds aWhereToHandle)
+    {
+    LOG_FUNC
+
+    LOG2( "aWhat = %d aWhere = %d" , aWhat, aWhereToHandle);
+
+    iWatcher.HandleHostProblemL(aWhat, aWhereToHandle);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPersonalityL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::CancelSetPersonalityL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPreviousPersonalityL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::CancelSetPreviousPersonalityL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPreviousPreviousPersonalityOnDisconnectL()
+    {
+    }
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+// From IdPin observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::IdPinOffL()
+    {
+    LOG_FUNC
+    PANIC(EIdPinOffNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::IdPinOnL()
+    {
+    LOG_FUNC
+    PANIC(EIdPinOnNotExpected);
+    }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusDownL()
+    {
+    LOG_FUNC
+    PANIC(EVBusDownNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusUpL()
+    {
+    LOG_FUNC
+    PANIC(EVBusUpNotExpected);
+    }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AIdleL()
+    {
+    LOG_FUNC
+    PANIC(EAIdleNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AHostL()
+    {
+    LOG_FUNC
+    PANIC(EAHostNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::APeripheralL()
+    {
+    LOG_FUNC
+    PANIC(EAPeripheralNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AVBusErrorL()
+    {
+    LOG_FUNC
+    PANIC(EAVBusErrorNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BIdleL()
+    {
+    LOG_FUNC
+    PANIC(EBIdleNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BPeripheralL()
+    {
+    LOG_FUNC
+    PANIC(EBPeripheralNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BHostL()
+    {
+    LOG_FUNC
+    PANIC(EBHostNotExpected);
+    }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BusIdleL()
+    {
+    LOG_FUNC
+    PANIC(EBusIdleNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BusActiveL()
+    {
+    LOG_FUNC
+    PANIC(EBusActiveNotExpected);
+    }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DeviceAttachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC(EDeviceAttachedNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DeviceDetachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC(EDeviceDetachedNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC(EDriverLoadSuccessNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadPartialSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC(EDriverLoadPartialSuccessNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadFailureL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC(EDriverLoadFailureNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BadHubPositionL()
+    {
+    LOG_FUNC
+    PANIC(EBadHubPositionNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusErrorL()
+    {
+    LOG_FUNC
+    PANIC(EVBusErrorNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::MessageNotificationReceivedL(TInt)
+    {
+    LOG_FUNC
+    PANIC(EMessageNotificationNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SrpReceivedL()
+    {
+    LOG_FUNC
+    PANIC(ESrpNotExpected);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SessionRequestedL()
+    {
+    LOG_FUNC
+    PANIC(ESessionRequestNotExpected);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostabase.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,282 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <e32base.h> 
+#include <usbhosterrors.h>
+#include <d32otgdi_errors.h>
+#include <d32usbdi_errors.h>
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostabase.h"
+#include "cusbstatehosthandledropping.h"
+
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostABase::CUsbStateHostABase(CUsbOtgWatcher& aWatcher) :
+    CUsbState(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::ConstructL()
+    {
+    LOG_FUNC
+    CUsbState::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostABase::~CUsbStateHostABase()
+    {
+    LOG_FUNC
+    }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+// VBus can be dropped by lower leyer in case of a critical problem
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::VBusDownL()
+    {
+    LOG_FUNC
+    HandleL(EUsbWatcherErrorInConnection, EUsbStateHostHandleDropping);
+    }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::AIdleL()
+    {
+    LOG_FUNC
+    // do nothing
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::AHostL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::APeripheralL()
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAPeripheral);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::AVBusErrorL()
+    {
+    LOG_FUNC
+    // No need to handle BusClearError error code, due to Bus will be dropped anyway
+    iWatcher.Usb().BusClearError();
+    HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower,
+            EUsbStateHostHandleDropping);
+    }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BusIdleL()
+    {
+    LOG_FUNC
+    //do nothing
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BusActiveL()
+    {
+    LOG_FUNC
+    // do nothing
+    }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::MessageNotificationReceivedL(TInt aMessage)
+    {
+    LOG_FUNC
+    LOG1( "aMessage = %d" , aMessage);
+
+    switch (aMessage)
+        {
+
+        // OTGDI
+        case KErrUsbOtgStackNotStarted://            = -6680;
+        case KErrUsbOtgHnpNotResponding://           = -6683;
+        case KErrUsbOtgBusControlProblem://          = -6685;
+        case KErrUsbOtgVbusPowerUpError://           = -6686;
+        case KErrUsbOtgHnpEnableProblem://           = -6687;
+        case KErrUsbOtgVbusError://                  = -6690;
+
+            // hosterrors.h
+        case KErrUsbConfigurationHasNoInterfaces:
+        case KErrUsbInterfaceCountMismatch:
+        case KErrUsbDuplicateInterfaceNumbers:
+        case KErrUsbBadDescriptor:
+        case KErrUsbDeviceDetachedDuringDriverLoading:
+        case KErrUsbAttachmentFailureGeneralError:
+            {
+            LOG( "ErrorInConnection" );
+            HandleL(EUsbWatcherErrorInConnection, EUsbStateHostHandleDropping);
+            break;
+            }
+
+            // OTGDI
+        case KErrUsbOtgPeriphNotSupported: //        = -6688, for OPT only
+
+            // USBDI
+        case KErrUsbRequestsPending:
+        case KErrUsbBadAddress:
+        case KErrUsbNoAddress:
+        case KErrUsbSetAddrFailed:
+        case KErrUsbNoPower:
+        case KErrUsbTooDeep:
+        case KErrUsbIOError:
+        case KErrUsbNotConfigured:
+        case KErrUsbTimeout:
+        case KErrUsbStalled:
+        case KErrUsbTestFailure:
+        case KErrUsbBadState:
+        case KErrUsbDeviceSuspended:
+        case KErrUsbBadDescriptorTopology:
+        case KErrUsbDeviceRejected:
+        case KErrUsbDeviceFailed:
+        case KErrUsbBadDevice: // = -6656
+        case KErrUsbBadHub:
+        case KErrUsbEventOverflow:
+        case KErrUsbBadDeviceAttached:
+
+            // hosterrors.h
+        case KErrUsbUnsupportedDevice:
+            {
+            LOG( "UnsupportedDevice" );
+            HandleL(EUsbWatcherErrUnsupportedDevice,
+                    EUsbStateHostHandleDropping);
+            break;
+            }
+        default:
+            {
+            LOG1( "Unhandled message = %d" , aMessage);
+            break;
+            }
+
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BadHubPositionL()
+    {
+    LOG_FUNC
+    HandleL(EUsbWatcherHubsNotSupported, EUsbStateHostHandleDropping);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::VBusErrorL()
+    {
+    LOG_FUNC
+    // No error code handling after BusClearError call, due to bus will be dropped anyway
+    iWatcher.Usb().BusClearError();
+    HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower,
+            EUsbStateHostHandleDropping);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::SrpReceivedL()
+    {
+    LOG_FUNC
+
+    if (iWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
+        {
+        LOG( "Session is ongoing (VBus high); ignore SRP request." );
+        return;
+        }
+
+    TInt err = iWatcher.Usb().BusRespondSrp();
+    LOG1( "BusRespondSrp() error = %d" , err );
+
+    if (KErrNone != err && KErrUsbOtgVbusAlreadyRaised != err)
+        {
+        iWatcher.HandleHostProblemL(EUsbWatcherErrorInConnection,
+                EUsbStateHostHandleDropping);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::SessionRequestedL()
+    {
+    LOG_FUNC
+
+    if (iWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
+        {
+        // session already ongoing; BusRequest() in this case returns KErrUsbOtgBadState...
+        LOG( "Session is ongoing (VBus high); ignore Session Request." );
+        return;
+        }
+
+    TInt err = iWatcher.Usb().BusRequest();
+    LOG1( "BusRequest() err = %d" , err);
+
+    if (KErrNone != err && KErrUsbOtgVbusAlreadyRaised != err)
+        {
+        iWatcher.HandleHostProblemL(EUsbWatcherErrorInConnection,
+                EUsbStateHostHandleDropping);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostahost.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,136 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <e32base.h>
+#include <UsbWatcherInternalPSKeys.h>
+#include <e32property.h>
+
+#include "cusbstatehostahost.h"
+#include "cusbnotifmanager.h"
+
+#include "definitions.h"
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostABase(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostABase::ConstructL();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost::~CUsbStateHostAHost()
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAHost::Id()
+    {
+    return EUsbStateHostAHost;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::JustAdvancedToThisStateL()
+    {
+    LOG_FUNC
+
+    // do general things 
+    CUsbStateHostABase::JustAdvancedToThisStateL();
+
+    LEAVEIFERROR(RProperty::Set(KPSUidUsbWatcher,
+            KUsbWatcherIsPeripheralConnected,
+            KUsbWatcherPeripheralIsConnected));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::JustBeforeLeavingThisStateL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(RProperty::Set(KPSUidUsbWatcher,
+            KUsbWatcherIsPeripheralConnected,
+            KUsbWatcherPeripheralIsNotConnected));
+
+    // do general things 
+    CUsbStateHostABase::JustBeforeLeavingThisStateL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::BadHubPositionL()
+    {
+    LOG_FUNC
+    PANIC( EBadHubPositionEventNotExpected);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,335 @@
+/*
+ * 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:  Implementation
+ *
+ */
+#include <usbuinotif.h>
+#include <usbhosterrors.h>
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostainitiate.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#include "cusbnotifmanager.h"
+#else
+#include "mockcusbnotifmanager.h"
+#include "mockcusbtimer.h"
+#endif
+
+#include "definitions.h"
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiate::CUsbStateHostAInitiate(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostABase(aWatcher), iDeviceAttached(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostABase::ConstructL();
+
+    iAttachmentTimer = CUsbTimer::NewL(*this, EDeviceAttachmentTimer);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiate* CUsbStateHostAInitiate::NewL(CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostAInitiate* self = new (ELeave) CUsbStateHostAInitiate(
+            aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiate::~CUsbStateHostAInitiate()
+    {
+    LOG_FUNC
+
+    delete iAttachmentTimer;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAInitiate::Id()
+    {
+    return EUsbStateHostAInitiate;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::JustBeforeLeavingThisStateL()
+    {
+    LOG_FUNC
+
+    iAttachmentTimer->Cancel();
+
+    // do general things 
+    CUsbStateHostABase::JustBeforeLeavingThisStateL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::JustAdvancedToThisStateL()
+    {
+    LOG_FUNC
+
+    // do general things 
+    CUsbStateHostABase::JustAdvancedToThisStateL();
+
+    // clear this attribute, and wait for attachment
+    // one attchment has to correspond to only one detachment
+    iDeviceAttached = EFalse; // to catch not corresponding Detachment, if any 
+
+    TInt err = iWatcher.Usb().EnableFunctionDriverLoading();
+
+    if (KErrNone != err)
+        {
+        LOG1( "EnableFunctionDriverLoading err = %d", err );
+        iWatcher.HandleHostProblemL(EUsbWatcherCanNotEnableDriverLoading,
+                EUsbStateHostHandleDropping);
+        return;
+        }
+
+    // do BusRequest, if down
+
+    if (CUsbVBusObserver::EVBusUp != iWatcher.VBusObserver()->VBus())
+        {
+        const TUint maxTrial = 3;
+        TInt busReqErr(KErrGeneral);
+        TUint count(0);
+
+        while (count < maxTrial && KErrNone != busReqErr)
+            {
+            busReqErr = iWatcher.Usb().BusRequest();
+            LOG1( "BusRequest() busReqErr = %d" , busReqErr);
+
+            if (KErrNone != busReqErr)
+                {
+                err = iWatcher.Usb().BusClearError();
+                if (KErrNone != err)
+                    {
+                    iWatcher.HandleHostProblemL(
+                            EUsbWatcherCanNotClearBusError,
+                            EUsbStateHostHandleDropping);
+                    return;
+                    }
+                }
+            ++count;
+            }
+        if (KErrNone != busReqErr)
+            {
+            iWatcher.HandleHostProblemL(EUsbWatcherCanNotRaiseVBus,
+                    EUsbStateHostHandleDropping);
+            return;
+            }
+        }
+
+    // start timer, waiting for device attachment
+    iAttachmentTimer->After(KTimeToWaitForDeviceAttachment);
+
+    }
+
+// From TimerObserver
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::TimerElapsedL(TUsbTimerId aTimerId)
+    {
+    LOG_FUNC
+
+    switch (aTimerId)
+        {
+        case EDeviceAttachmentTimer:
+            {
+            LOG("AttachmentTimer" );
+            HandleL(EUsbWatcherErrDandlingCable, EUsbStateHostHandleDropping);
+            break;
+            }
+        default:
+            {
+            LOG1( "Unknown timer id = %d", aTimerId );
+            PANIC( EWrongTimerId);
+            }
+        }
+    }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::VBusUpL()
+    {
+    LOG_FUNC
+    }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::DeviceAttachedL(TDeviceEventInformation aTdi)
+    {
+    LOG_FUNC
+
+    iDeviceAttached = ETrue;
+    iAttachmentTimer->Cancel();
+
+    // check if an OTG device connected
+    TOtgDescriptor otgDescriptor;
+
+    // ignore all the errors, assume we connected to not otg
+    TInt err = iWatcher.Usb().GetOtgDescriptor(aTdi.iDeviceId, otgDescriptor);
+    LOG1("GetOtgDescriptor() err = %d", err );
+
+    TBool hnpSupported(otgDescriptor.iAttributes & EUsbOtgHNPSupported);
+    TBool srpSupported(otgDescriptor.iAttributes & EUsbOtgSRPSupported);
+
+    // OTG device supports both hnp and srp
+    if (hnpSupported && srpSupported)
+        {
+
+        HandleL(EUsbWatcherConnectedToOTG, EUsbStateHostHandleDropping);
+        return;
+        }
+
+    switch (aTdi.iError)
+        // error in attachement
+        {
+        case KErrNone:
+            {
+            break;
+            }
+        case KErrUsbDeviceDetachedDuringDriverLoading:
+            {
+            //do not show error, due to device is already detached
+            // Device Detachment will not come after this (it was not attached yet)
+            // therefore emulate detachment
+            // content of aTdi is not important, due to detachment anyway
+            DeviceDetachedL(aTdi);
+            break;
+            }
+        case KErrBadPower:
+            {
+            LOG( "TooMuchPower" );
+            HandleL(EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration,
+                    EUsbStateHostDelayNotAttachedHandle);
+            break;
+            }
+        default:
+            {
+            LOG1("AttachmentError aTdi.iError = %d" , aTdi.iError );
+            HandleL(EUsbWatcherErrUnsupportedDevice,
+                    EUsbStateHostHandleDropping);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::DeviceDetachedL(TDeviceEventInformation aTdi)
+    {
+    LOG_FUNC
+
+    // iDeviceAttached is used here to avoid one more state creation (init->attached->detached)
+    // due to purpose of this state only to wait for drivers load
+    if (!iDeviceAttached)
+        {
+        PANIC(EDeviceDetachedNotExpected)
+        }
+
+    // go out, and go in to the same state
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::DriverLoadSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAHost);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::DriverLoadPartialSuccessL(
+        TDeviceEventInformation aDei)
+    {
+    LOG_FUNC
+
+    switch (aDei.iError)
+        {
+        case KErrUsbDeviceDetachedDuringDriverLoading:
+            {
+            //do not show warning, due to device is already detached
+            break;
+            }
+        default:
+            {
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgWarning,
+                    EUsbOtgPartiallySupportedDevice, NULL);
+            }
+        }
+    ChangeHostStateL( EUsbStateHostAHost);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::DriverLoadFailureL(TDeviceEventInformation aDei)
+    {
+    LOG_FUNC
+
+    HandleL(EUsbWatcherErrDriversNotFound, EUsbStateHostDelayAttachedHandle);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,100 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbuinotif.h>
+
+#include "cusbstatehostaperipheral.h"
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral::CUsbStateHostAPeripheral(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostABase(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostABase::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral* CUsbStateHostAPeripheral::NewL(
+        CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostAPeripheral* self = new (ELeave) CUsbStateHostAPeripheral(
+            aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral::~CUsbStateHostAPeripheral()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAPeripheral::Id()
+    {
+    return EUsbStateHostAPeripheral;
+    }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::AHostL()
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::AIdleL()
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostdelayattachedhandle.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,171 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbuinotif.h>
+
+#include "cusbstatehostdelayattachedhandle.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayAttachedHandle::CUsbStateHostDelayAttachedHandle(
+        CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostDelayHandle(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayAttachedHandle* CUsbStateHostDelayAttachedHandle::NewL(
+        CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostDelayAttachedHandle* self =
+            new (ELeave) CUsbStateHostDelayAttachedHandle(aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayAttachedHandle::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostDelayHandle::ConstructL();
+    iDriversNotFoundTimer = CUsbTimer::NewL(*this, EDriversNotFoundTimer);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayAttachedHandle::~CUsbStateHostDelayAttachedHandle()
+    {
+    LOG_FUNC
+
+    delete iDriversNotFoundTimer;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostDelayAttachedHandle::Id()
+    {
+    return EUsbStateHostDelayAttachedHandle;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayAttachedHandle::JustBeforeLeavingThisStateL()
+    {
+    LOG_FUNC
+
+    iDriversNotFoundTimer->Cancel();
+
+    // do general things 
+    CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayAttachedHandle::DoHandleL()
+    {
+    LOG_FUNC
+    LOG1( "iWhat = %d" , iWhat);
+
+    switch (iWhat)
+        {
+        case EUsbWatcherErrDriversNotFound:
+            {
+            LOG("DriversNotFound" );
+
+            iDriversNotFoundTimer->After(KTimeDriversNotFound);
+            break;
+
+            }
+
+        default:
+            {
+            LOG1("Unexpected request id = %d" , iWhat );
+            PANIC( EUnexpectedSituationToHandle);
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayAttachedHandle::DeviceDetachedL(
+        TDeviceEventInformation)
+    {
+    LOG_FUNC
+
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
+
+// From TimerObserver
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayAttachedHandle::TimerElapsedL(TUsbTimerId aTimerId)
+    {
+    LOG_FUNC
+
+    switch (aTimerId)
+        {
+        case EDriversNotFoundTimer:
+            {
+            LOG( "EDriversNotFoundTimer" );
+            HandleL(EUsbWatcherErrUnsupportedDevice,
+                    EUsbStateHostHandleDropping);
+
+            break;
+            }
+        default:
+            {
+            LOG1( "Unknown timer id = %d", aTimerId );
+            PANIC( EWrongTimerId);
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,79 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostdelayhandle.h"
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayHandle::CUsbStateHostDelayHandle(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostHandle(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayHandle::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostHandle::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayHandle::~CUsbStateHostDelayHandle()
+    {
+    LOG_FUNC
+    }
+
+/////////////////////////////////////////////////////////////////////////////////////
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayHandle::VBusUpL()
+    {
+    LOG_FUNC
+    // this is not expected, due to in this state vbus already up, since entering the state
+    PANIC( EVBusUpNotExpected);
+    }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayHandle::DeviceAttachedL(
+        TDeviceEventInformation aDevEventInfo)
+    {
+    LOG_FUNC
+
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    iWatcher.DeviceAttachedL(aDevEventInfo);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostdelaynotattachedhandle.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,176 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbstatehostdelaynotattachedhandle.h"
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayNotAttachedHandle::CUsbStateHostDelayNotAttachedHandle(
+        CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostDelayHandle(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayNotAttachedHandle* CUsbStateHostDelayNotAttachedHandle::NewL(
+        CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostDelayNotAttachedHandle* self =
+            new (ELeave) CUsbStateHostDelayNotAttachedHandle(aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostDelayHandle::ConstructL();
+
+    iTooMuchPowerTimer = CUsbTimer::NewL(*this, ETooMuchPowerRequiredTimer);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostDelayNotAttachedHandle::~CUsbStateHostDelayNotAttachedHandle()
+    {
+    LOG_FUNC
+
+    delete iTooMuchPowerTimer;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostDelayNotAttachedHandle::Id()
+    {
+    return EUsbStateHostDelayNotAttachedHandle;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::JustBeforeLeavingThisStateL()
+    {
+    LOG_FUNC
+
+    iTooMuchPowerTimer->Cancel();
+
+    // do general things 
+    CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::DoHandleL()
+    {
+    LOG_FUNC
+    LOG1( "iWhat = %d" , iWhat);
+
+    switch (iWhat)
+        {
+        case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
+            {
+            LOG("EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" );
+
+            iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired);
+            break;
+            }
+
+        default:
+            {
+            LOG1("Unexpected request id = %d", iWhat);
+            PANIC( EUnexpectedSituationToHandle);
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::AIdleL()
+    {
+    LOG_FUNC
+
+    // Exit on AIdle, due to Detachment not comes,
+    // because no corresponding attachment with err == KErrNone
+    ChangeHostStateL( EUsbStateHostAInitiate);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::DeviceDetachedL(
+        TDeviceEventInformation)
+    {
+    LOG_FUNC
+    PANIC( EDeviceDetachedNotExpected);
+
+    }
+
+// From TimerObserver
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostDelayNotAttachedHandle::TimerElapsedL(TUsbTimerId aTimerId)
+    {
+    LOG_FUNC
+    switch (aTimerId)
+        {
+        case ETooMuchPowerRequiredTimer:
+            {
+            LOG("ETooMuchPowerRequiredTimer" );
+            HandleL(EUsbWatcherErrUnsupportedDevice,
+                    EUsbStateHostHandleDropping);
+            break;
+            }
+        default:
+            {
+            LOG1("Unknown timer id = %d", aTimerId );
+            PANIC( EWrongTimerId);
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,98 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbstatehosthandle.h"
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle::CUsbStateHostHandle(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostABase(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostABase::ConstructL();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle::~CUsbStateHostHandle()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::JustAdvancedToThisStateL()
+    {
+    LOG_FUNC
+
+    // first do general things
+    CUsbStateHostABase::JustAdvancedToThisStateL();
+
+    // then, do specific things
+    DoHandleL();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::SetWhat(TInt aWhat)
+    {
+    iWhat = aWhat;
+    }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::MessageNotificationReceivedL(TInt aMessage)
+    {
+    LOG_FUNC
+    LOG1( "Unhandled message aMessage = %d" , aMessage);
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::SessionRequestedL()
+    {
+    LOG_FUNC
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehosthandledropping.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,412 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbuinotif.h>
+#include <d32usbdi_errors.h>
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehosthandledropping.h"
+
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#else
+#include "mockcusbnotifmanager.h"
+#endif
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandleDropping::CUsbStateHostHandleDropping(
+        CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostHandle(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandleDropping* CUsbStateHostHandleDropping::NewL(
+        CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostHandleDropping* self =
+            new (ELeave) CUsbStateHostHandleDropping(aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::ConstructL()
+    {
+    LOG_FUNC
+    CUsbStateHostHandle::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandleDropping::~CUsbStateHostHandleDropping()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostHandleDropping::Id()
+    {
+    return EUsbStateHostHandleDropping;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::JustBeforeLeavingThisStateL()
+    {
+    LOG_FUNC
+
+    iWatcher.NotifManager()->CloseAllNotifiers();
+
+    // do general things 
+    CUsbStateHostHandle::JustBeforeLeavingThisStateL();
+    }
+
+// this means only one wait notifier at a time can be shown by this state
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::WaitNotifierCompletedL(TInt /*aFeedback*/)
+    {
+    LOG_FUNC
+
+    switch (iWhat)
+        {
+        case EUsbWatcherHubsNotSupported:
+            {
+            LOG( "EUsbWatcherHubsNotSupported" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherErrDeviceRequiresTooMuchPower:
+            {
+            LOG( "EUsbWatcherErrDeviceRequiresTooMuchPower" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherErrUnsupportedDevice:
+            {
+            LOG("EUsbWatcherErrUnsupportedDevice" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherConnectedToOTG:
+            {
+            LOG("EUsbWatcherConnectedToOTG" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherErrDandlingCable:
+            {
+            LOG("EUsbWatcherErrDandlingCable" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherNoActivity:
+            {
+            LOG("EUsbWatcherNoActivity" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+        case EUsbWatcherErrorInConnection:
+            {
+            LOG( "EUsbWatcherErrorInConnection" );
+            ChangeHostStateL( EUsbStateHostAInitiate);
+            break;
+            }
+
+            // fatal errors
+        case EUsbWatcherCanNotStartUsbServices:
+            {
+            LOG( "EUsbWatcherCanNotStartUsbServices" );
+
+            // no break here                     
+            }
+
+            // no break statement for following cases 
+        case EUsbWatcherNoMemory:
+        case EUsbWatcherIdPinError:
+        case EUsbWatcherVBusObserverError:
+        case EUsbWatcherHostEventNotificationError:
+        case EUsbWatcherOtgStateError:
+        case EUsbWatcherMessageNotificationError:
+        case EUsbWatcherCanNotStartSession:
+        case EUsbWatcherCanNotEnableDriverLoading:
+        case EUsbWatcherCanNotClearBusError:
+        case EUsbWatcherCanNotRaiseVBus:
+            {
+            LOG("Fatal error" );
+            ChangeHostStateL( EUsbStateHostUndefined);
+            break;
+            }
+        default:
+            {
+            LOG1("Unexpected situation to be handled iWhat = %d" , iWhat );
+            PANIC( EUnexpectedSituationToHandle);
+            break;
+            }
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DoHandleL()
+    {
+    LOG_FUNC
+
+    LOG1( "iWhat = %d" , iWhat);
+
+    // Drop VBus first    
+    // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
+    iWatcher.Usb().BusDrop();
+
+    switch (iWhat)
+        {
+
+        case EUsbWatcherHubsNotSupported:
+            {
+            LOG("EUsbWatcherHubsNotSupported" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgHubUnsupported, this);
+            break;
+            }
+        case EUsbWatcherErrDeviceRequiresTooMuchPower:
+            {
+            LOG("EUsbWatcherErrDeviceRequiresTooMuchPower" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgTooMuchPower, this);
+            break;
+            }
+        case EUsbWatcherErrUnsupportedDevice:
+            {
+            LOG("EUsbWatcherErrUnsupportedDevice" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgUnsupportedDevice, this);
+            break;
+            }
+        case EUsbWatcherConnectedToOTG:
+            {
+            LOG("EUsbWatcherConnectedToOTG" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgUnsupportedDevice, this);
+
+            break;
+            }
+        case EUsbWatcherErrDandlingCable:
+            {
+            LOG( "EUsbWatcherErrDandlingCable" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgErrorAttachTimedOut, this);
+            break;
+            }
+        case EUsbWatcherNoActivity:
+            {
+            LOG( "EUsbWatcherNoActivity" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgUnsupportedDevice, this);
+
+            break;
+            }
+        case EUsbWatcherErrorInConnection:
+            {
+            LOG("EUsbWatcherErrorInConnection" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgErrorInConnection, this);
+            break;
+            }
+        case EUsbWatcherNoMemory:
+            {
+            LOG("EUsbWatcherNoMemory" );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgErrorNoMemory, this);
+            break;
+            }
+        case EUsbWatcherCanNotStartUsbServices:
+            {
+            LOG("EUsbWatcherCanNotStartUsbServices" );
+            // no break here
+            }
+            // no break in following cases
+        case EUsbWatcherIdPinError:
+        case EUsbWatcherVBusObserverError:
+        case EUsbWatcherHostEventNotificationError:
+        case EUsbWatcherOtgStateError:
+        case EUsbWatcherMessageNotificationError:
+        case EUsbWatcherCanNotStartSession:
+        case EUsbWatcherCanNotEnableDriverLoading:
+        case EUsbWatcherCanNotClearBusError:
+        case EUsbWatcherCanNotRaiseVBus:
+            {
+            LOG1( "Fatal error iWhat = %d", iWhat );
+            iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+                    EUsbOtgErrorInConnection, this);
+            break;
+            }
+        default:
+            {
+            LOG1("Unexpected situation to be handled iWhat = %d", iWhat );
+            PANIC( EUnexpectedSituationToHandle);
+            break;
+            }
+        }
+    }
+
+/////////////////////////////////////////////////////////////////////////////////////
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::VBusUpL()
+    {
+    LOG_FUNC
+    ChangeHostStateL( EUsbStateHostAInitiate);
+    }
+
+// ---------------------------------------------------------------------------
+// this is expected in the state, for example after calling BusDrop
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::VBusDownL()
+    {
+    LOG_FUNC
+    }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::AVBusErrorL()
+    {
+    LOG_FUNC
+    iWatcher.Usb().BusClearError();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DeviceAttachedL(
+        TDeviceEventInformation aDevEventInfo)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DeviceDetachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DriverLoadSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DriverLoadPartialSuccessL(
+        TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::DriverLoadFailureL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::MessageNotificationReceivedL(TInt aMessage)
+    {
+    LOG_FUNC
+
+    LOG1( "aMessage = %d", aMessage )
+
+    switch (aMessage)
+        {
+        // USBDI
+        case KEventUsbBadDeviceDetached:
+            {
+            LOG("BadDeviceDetached" );
+            ChangeHostStateL( EUsbStateHostUndefined);
+            break;
+            }
+        default:
+            {
+            LOG1( "Unhandled message aMessage = %d" , aMessage);
+            break;
+            }
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandleDropping::VBusErrorL()
+    {
+    LOG_FUNC
+    iWatcher.Usb().BusClearError();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostundefined.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,222 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostundefined.h"
+
+#include "definitions.h"
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostUndefined::CUsbStateHostUndefined(CUsbOtgWatcher& aWatcher) :
+    CUsbStateHostABase(aWatcher)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostUndefined* CUsbStateHostUndefined::NewL(CUsbOtgWatcher& aWatcher)
+    {
+    LOG_FUNC
+
+    CUsbStateHostUndefined* self = new (ELeave) CUsbStateHostUndefined(
+            aWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbStateHostABase::ConstructL();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostUndefined::~CUsbStateHostUndefined()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostUndefined::Id()
+    {
+    return EUsbStateHostUndefined;
+    }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::VBusDownL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::VBusUpL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::VBusErrorL()
+    {
+    LOG_FUNC
+    iWatcher.Usb().BusClearError();
+    }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CUsbStateHostUndefined::AVBusErrorL()
+    {
+    LOG_FUNC
+    iWatcher.Usb().BusClearError();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::BIdleL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::BPeripheralL()
+    {
+    LOG_FUNC
+    }
+
+// From host state observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::DeviceAttachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::DeviceDetachedL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::DriverLoadSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::DriverLoadPartialSuccessL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::DriverLoadFailureL(TDeviceEventInformation)
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::SrpReceivedL()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::SessionRequestedL()
+    {
+    LOG_FUNC
+    }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::MessageNotificationReceivedL(TInt aMessage)
+    {
+    LOG_FUNC
+    LOG1( "Unhandled message aMessage = %d" , aMessage);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostUndefined::BadHubPositionL()
+    {
+    LOG_FUNC
+    PANIC( EBadHubPositionNotExpected);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbtimer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,119 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include "cusbtimer.h"
+
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbTimer::CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId) :
+    CActive(CActive::EPriorityStandard), iObserver(aObserver), iTimerId(
+            aTimerId)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbTimer::~CUsbTimer()
+    {
+    LOG_FUNC
+    Cancel();
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::ConstructL()
+    {
+    LOG_FUNC
+    LEAVEIFERROR(iTimer.CreateLocal());
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbTimer* CUsbTimer::NewL(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId)
+    {
+    LOG_FUNC
+
+    CUsbTimer* self = new (ELeave) CUsbTimer(aObserver, aTimerId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self); // pop self
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::After(TInt aMilliseconds)
+    {
+    if (IsActive())
+        {
+        Cancel();
+        }
+
+    // RunL will be called after KInactiveTimeForShutDown milliseconds
+    iTimer.After(iStatus, TTimeIntervalMicroSeconds32(aMilliseconds));
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::RunL()
+    {
+
+    if (KErrNone != iStatus.Int())
+        {
+        LEAVE(iStatus.Int());
+        }
+
+    iObserver.TimerElapsedL(iTimerId);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbTimer::RunError(TInt aError)
+    {
+    LOG_FUNC
+    LOG1( "aError = %d" , aError );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::DoCancel()
+    {
+    iTimer.Cancel();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbvbusobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,233 @@
+/*
+ * 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:  Implementation
+ *
+ */
+
+#include <usbotgdefs.h>
+
+#include "cusbvbusobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::CUsbVBusObserver() :
+    CActive(EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR(iVBus.Attach(KUidUsbManCategory,
+            KUsbOtgVBusPoweredProperty));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver* CUsbVBusObserver::NewL()
+    {
+    LOG_FUNC
+
+    CUsbVBusObserver* self = new (ELeave) CUsbVBusObserver();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::~CUsbVBusObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+
+    iVBus.Close();
+
+    iObservers.Close();
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* not const, because for some reason RProperty::Get is not const */
+    {
+
+    TInt val(0);
+
+    TInt err = iVBus.Get(val);
+
+    if (KErrNone != err)
+        {
+        LOG("CanNotGetVBusProperty" )
+        PANIC( ECanNotGetVBusProperty);
+        }
+
+    return (0 == val ? EVBusDown : EVBusUp);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::SubscribeL(MUsbVBusObserver& aObserver)
+    {
+    LOG_FUNC
+
+    // check if the same observer already exist in a list
+    if (KErrNotFound != iObservers.Find(&aObserver))
+        {
+        LOG( "Observer already exists" );
+        PANIC( EObserverAlreadyExists);
+        return;
+        }
+
+    iObservers.AppendL(&aObserver);
+
+    if (KFirst == iObservers.Count()) // first item
+        {
+        iVBus.Subscribe(iStatus);
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver& aObserver)
+    {
+    LOG_FUNC
+
+    TInt i(iObservers.Find(&aObserver));
+    if (KErrNotFound == i)
+        {
+        LOG("Observer not found" );
+        PANIC( ECanNotFindVBusObserver);
+        return;
+        }
+
+    iObservers.Remove(i);
+
+    if (0 == iObservers.Count()) // no observers anymore
+        {
+        // cancel pending request, if any
+        Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
+
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
+            {
+            iObservers[i]->VBusObserverErrorL(iStatus.Int());
+            }
+        return;
+        }
+
+    // re-issue request first
+    iVBus.Subscribe(iStatus);
+    SetActive();
+
+    // then process property change
+    TState state(VBus());
+
+    // report change   
+    switch (state)
+        {
+        case EVBusUp:
+            {
+            LOG("VBus UP");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->VBusUpL();
+                }
+            break;
+            }
+            ;
+
+        case EVBusDown:
+            {
+            LOG("VBus DOWN");
+
+            for (TInt i(0); i < iObservers.Count(); ++i)
+                {
+                iObservers[i]->VBusDownL();
+                }
+            break;
+            }
+            ;
+
+        default:
+            {
+            LOG("WrongVBusState");
+            PANIC( EWrongVBusState);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::DoCancel()
+    {
+    iVBus.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CUsbVBusObserver::RunError(TInt aError)
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d" , aError);
+
+    // try to continue	
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,77 @@
+/*
+ * 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:  Usb waiting notifier implementation
+ *
+ */
+
+#include <e32std.h>
+#include <usbuinotif.h>
+
+#include "cusbnotifmanager.h"
+#include "cusbwaitnotifier.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbWaitNotifier* CUsbWaitNotifier::NewL(RNotifier& aNotifier,
+        CUsbNotifManager& aNotifManager, TUint aNotifId)
+    {
+    LOG_FUNC
+
+    CUsbWaitNotifier* self = new (ELeave) CUsbWaitNotifier(aNotifier,
+            aNotifManager, aNotifId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUsbWaitNotifier::~CUsbWaitNotifier()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbWaitNotifier::CUsbWaitNotifier(RNotifier& aNotifier,
+        CUsbNotifManager& aNotifManager, TUint aNotifId) :
+    CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgError, aNotifId)
+    {
+    SetFeedbackNeeded();
+    }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbWaitNotifier::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbNoteNotifier::ConstructL();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,81 @@
+/*
+ * 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:  Usb warning notifier implementation
+ *
+ */
+
+#include <e32std.h>
+#include <usbuinotif.h>
+
+#include "cusbnotifmanager.h"
+#include "cusbnotifier.h"
+#include "cusbwarningnotifier.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbWarningNotifier* CUsbWarningNotifier::NewL(RNotifier& aNotifier,
+        CUsbNotifManager& aNotifManager, TUint aNotifId)
+    {
+    LOG_FUNC
+
+    LOG1( "aNotifId = %d" , aNotifId);
+
+    CUsbWarningNotifier* self = new (ELeave) CUsbWarningNotifier(aNotifier,
+            aNotifManager, aNotifId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbWarningNotifier::~CUsbWarningNotifier()
+    {
+    LOG_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbWarningNotifier::CUsbWarningNotifier(RNotifier& aNotifier,
+        CUsbNotifManager& aNotifManager, TUint aNotifId) :
+    CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgWarning,
+            aNotifId)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Second-phase constructor
+// -----------------------------------------------------------------------------
+//
+void CUsbWarningNotifier::ConstructL()
+    {
+    LOG_FUNC
+
+    CUsbNoteNotifier::ConstructL();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for project UsbRemotePersonality
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/usbremotepersonality.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbremotepersonality.iby)
+
+PRJ_MMPFILES
+usbremotepersonality.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/group/build_component.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,22 @@
+rem
+rem Copyright (c) 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:
+rem
+
+call bldmake clean
+call bldmake bldfiles
+call abld clean
+call abld reallyclean
+call abld build
+call pause
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/group/usbremotepersonality.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* 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:  Plugin for handling remote personality requests
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+target		        usbremotepersonality.dll
+CAPABILITY 	        LocalServices CommDD
+targettype		        plugin
+
+uid			        0x10009d8d 0x10283307
+VENDORID VID_DEFAULT
+
+sourcepath		../src
+
+source                          cremotepersonalityhandlerplugin.cpp
+source			  cremotepersonalityhandler.cpp
+source                          csetpersonality.cpp
+
+userinclude		../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE  /epoc32/include/ecom
+
+start resource 10283307.rss
+target usbremotepersonality.rsc
+end
+
+library			euser.lib usbman.lib usbwatcher.lib ecom.lib platformver.lib
+
+DEBUGLIBRARY  	flogger.lib            // File logging
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/inc/cremotepersonalityhandler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,288 @@
+/*
+* 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:  Handles remote personality - related requests
+*
+*/
+
+
+#ifndef CREMOTEPERSONALITYHANDLER_H
+#define CREMOTEPERSONALITYHANDLER_H
+
+#include <cusbdevicecontrolplugin.h>
+
+class RUsbWatcher;
+class RUsb;
+class RDevUsbcClient;
+class CSetPersonality;
+
+struct TPersonality
+    {
+        
+    TUint8 iId;     // Personality id
+    TUint8 iIndex;  // Index of a string descriptor
+    
+    };
+    
+/**
+ *  Setup packet interpretation
+ *
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ class TSetupPacket
+ {
+ public:
+    
+    /**
+     * Decodes buffer as a SetupPacket
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket incoming buffer to be decoded
+     */
+    void Decode(const RBuf8& aSetupPacket);
+ 
+ public:
+ 
+    TUint8       iType;      // control message type
+    TInt            iRequest;   // request; has type TInt because can be negative: CRemotePersonalityHandler::EUnknown;
+    TUint16     iValue;     // value
+    TUint16     iIndex;     // index
+    TUint16     iLength;    // length
+ } ;
+ 
+/**
+ *  Remote Personality Requests handler
+ *
+ *  @lib usbdevcon.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CRemotePersonalityHandler : public CUsbCMHandler
+    {
+
+public:
+    
+    /**  Last result */
+    enum TLastResult
+    {
+        ESuccess =              0x00,
+        EUndefinedError =       0x01,
+        EInvalidRequest=        0x02,
+        ERequestIsNotSupported= 0x03,
+        EFeatureIsNotSupported= 0x04,
+        ENonExistingPersonality=0x10,
+        EDataTransferInProgress=0x11,
+        EEntityIsLocked=        0x12,
+        ENonExistingEntity=     0x20,
+        EInvalidLockState=      0x21,
+        EInvalidPassword=       0x22,
+        ENoAttemptsLeft=        0x23
+        
+        // 0x80 ..0xFE reserved for vendor usage
+        
+    };
+    
+    /**  Requests */
+    enum TRequest
+    {
+        EUnknown                    = -1,
+        EGetAllPersonalities        = 0x82,
+        EGetLastResult              = 0x84,
+        EGetPersonalityDescriptor   = 0x86,
+        EGetPersonality             = 0x88,
+        ESetPersonality             = 0x89,
+        EGetLockState               = 0x8A,
+        ESetLockState               = 0x8B
+    };
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @return Constructed instance
+     */ 
+    static CRemotePersonalityHandler* NewL();
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CRemotePersonalityHandler();
+    
+    /**
+     * Called back when SetPersonality request is completed
+     * @param aResult Result of the SetPersonality request
+     * @since S60 v.5.0
+     */
+    void SetPersonalityCallBack(TLastResult aResult);
+    
+    // From MUsbCMHandler
+    
+    /**
+     * Handler's Handle
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket request to be handled
+     * @param aData Either data from host to device, or data from device to host
+     * @return Errorcode
+     */
+    TInt Handle(const RBuf8& aSetupPacket, RBuf8& aData);
+    
+    /**
+     * Initializer
+     *
+     * @since S60 v.5.0
+     * @param aLdd Link to LDD services
+     * @param aUsbWatcher Link to USB Watcher services
+     * @param aUsbManager Link to USB Manager services
+     */
+    void Initialize(RDevUsbcClient& aLdd, RUsbWatcher& aUsbWatcher, RUsb& aUsbManager);
+        
+private:
+    
+    /**
+     * Default constructor.
+     *
+     * @since S60 v.5.0
+     */ 
+    CRemotePersonalityHandler();
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */ 
+    void ConstructL();
+   
+   /**
+     * Internal handler - leaves if error
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket request to be handled
+     * @param aData Either data from host to device, or data from device to host
+     */
+    void DoHandleL(const RBuf8& aSetupPacket, RBuf8& aData);
+     
+    /**
+     * Handles GET_ALL_PERSONALITIES request
+     *
+     * @since S60 v.5.0
+     * @param aData Contains result on exit
+     */
+    void GetPersonalitiesL(RBuf8& aData);
+    
+    /**
+     * Handles SET_PERSONALITY request
+     *
+     * @since S60 v.5.0
+     */
+    void SetPersonalityL();
+    
+    /**
+     * Handles GET_LAST_RESULT request
+     * @param aData Last result
+     * @since S60 v.5.0
+     */
+    void GetLastResultL(RBuf8& aData);
+    
+    /**
+     * Read personalities from USB Manager to iPersonalities
+     *
+     * @since S60 v.5.0
+     */
+    void ReadPersonalitiesL();
+    
+    /**
+     * Saves personalities descriptions to USB standard strings descriptors
+     *
+     * @since S60 v.5.0
+     */
+    void SavePersonalitiesStringsL();
+    
+    /**
+     * Check if mapping of ids is needed
+     *
+     * @since S60 v.5.0
+     */
+    TBool IsMappingNeededL();
+    
+    /**
+     * Maps old personality ids (3.2) to new ones (5.0)
+     *
+     * @since S60 v.5.0
+     */
+    TInt MapPersonalityIdFromDeviceToHostL(TInt aPersonalityId);
+    
+    /**
+     * Maps old personality ids (3.2) to new ones (5.0)
+     *
+     * @since S60 v.5.0
+     */
+    TInt MapPersonalityIdFromHostToDeviceL(TInt aPersonalityId);
+        
+private: // data
+    
+    /**
+     * Result of the last operation
+     *   
+     */
+    TLastResult iLastResult;
+    
+    /**
+     * USB watcher
+     * Not owns.  
+     */
+    RUsbWatcher* iUsbWatcher;
+    
+    /**
+     * USB Manager
+     * Not owns.  
+     */
+    RUsb* iUsbManager;
+    
+    /**
+     * USB client
+     * Not owns. 
+     */
+    RDevUsbcClient* iLdd;
+    
+    /**
+     * Request, being processed currently
+     *   
+     */
+    TSetupPacket iSetupPacket;
+    
+    /**
+     * Supported personalities
+     *   
+     */
+    RArray<TPersonality> iPersonalities;
+    
+     /**
+     * SetPersonality request handler
+     *   
+     */
+    CSetPersonality* iSetPersonalityHandler;
+    
+    /**
+     * ETrue if mapping is needed from old ids set to new one and vice versa 
+     *   
+     */
+    TBool iMappingIsNeeded;
+    
+    };
+
+#endif // CREMOTEPERSONALITYHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/inc/csetpersonality.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* 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:  Handles set personality request
+*
+*/
+
+
+#ifndef CSETPERSONALITY_H
+#define CSETPERSONALITY_H
+
+#include <e32base.h>
+
+class RUsbWatcher;
+class CRemotePersonalityHandler; // call back
+ 
+/**
+ * Set Personality Request handler
+ *
+ *  @lib usbremotepersonality.lib
+ *  @since S60 v.5.0 
+ */
+ 
+class CSetPersonality : public CActive
+    {
+
+public:
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     * @return Constructed instance
+     */ 
+    static CSetPersonality* NewL(CRemotePersonalityHandler& aCallBack);
+    
+    /**
+    * Destructor.
+    *
+    * @since S60 v.5.0
+    */
+    virtual ~CSetPersonality();
+    
+    /**
+     * Handles SET_PERSONALITY request
+     *
+     * @since S60 v.5.0
+     */
+    void SetPersonality(TUint aPersonalityId);
+    
+    /**
+     * Sets link to UsbWatcher
+     *
+     * @since S60 v.5.0
+     */
+    void SetUsbWatcher(RUsbWatcher* aUsbWatcher);
+    
+private:
+    
+    /**
+     * Default constructor.
+     *
+     * @since S60 v.5.0
+     */ 
+    CSetPersonality(CRemotePersonalityHandler& aCallBack);
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since S60 v.5.0
+     */ 
+    void ConstructL();
+      
+    // from CActive
+    
+    /**
+     * From CActive.
+     *
+     */
+    void RunL();
+    
+    /**
+     * From CActive.
+     *
+     */
+    void DoCancel();
+    
+    /**
+     * From CActive.
+     *
+     */ 
+     TInt RunError( TInt /*aError*/ );
+        
+private: // data
+    
+    /**
+     * Callback class 
+     * Not owns.  
+     */
+    CRemotePersonalityHandler& iCallBack;
+    
+    /**
+     * USB watcher
+     * Not owns.  
+     */
+    RUsbWatcher* iUsbWatcher;
+    
+     };
+
+#endif // CSETPERSONALITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,118 @@
+/*
+* 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:  Central place for debug-type macros & functions
+*
+*/
+
+
+#ifndef _USBDEVCON_DEBUG_H
+#define _USBDEVCON_DEBUG_H
+
+#ifdef _DEBUG
+
+// Enable this to enable memory tracing
+//#define MEMTRACE
+
+// Following define is to enable OOM
+// situations in SRCS
+// SHOULD NEVER BE IN RELEASES.
+//#define TEST_OOM
+
+#ifdef __WINS__
+
+// File logging for WINS
+#define __FLOGGING__
+
+#else
+
+// Logging with RDebug for target HW
+#define __CLOGGING__
+
+#endif //__WINS__
+
+#endif // Debug
+
+#if defined ( __FLOGGING__ )
+
+_LIT( KLogFile,"UsbWatcher.txt" );
+_LIT( KLogDir,"usb" );
+
+#include <f32file.h>
+#include <flogger.h>
+
+#define FLOG( a ) { FPrint( a ); }
+
+#define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
+
+#define FTRACE( a ) { a; }
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+
+    // If memory tracing is activated.
+#ifdef MEMTRACE
+    TInt size;
+    User::Heap().AllocSize( size );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBDEVCON]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
+#endif
+}
+
+inline void FHex( const TUint8* aPtr, TInt aLen )
+{
+    RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
+}
+
+inline void FHex( const TDesC8& aDes )
+{
+    FHex( aDes.Ptr(), aDes.Length() );
+}
+
+// RDebug logging
+#elif defined(__CLOGGING__)
+
+#include <e32svr.h>
+
+#define FLOG( a ) { RDebug::Print( a ); }
+
+#define FLOGHEX( a )
+
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+{
+    VA_LIST list;
+    VA_START( list,aFmt );
+    TInt tmpInt = VA_ARG( list, TInt );
+    TInt tmpInt2 = VA_ARG( list, TInt );
+    TInt tmpInt3 = VA_ARG( list, TInt );
+    VA_END( list );
+    RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
+}
+
+
+#else   // No loggings --> reduced code size
+
+#define FLOG( a )
+#define FLOGHEX( a )
+#define FTRACE( a )
+
+#endif //_DEBUG
+
+#endif // USBDEVCON_DEBUG_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/rom/usbremotepersonality.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  Image description file for project Usbremotepersonality
+*
+*/
+
+
+#ifndef USBREMOTEPERSONALITY_IBY__
+#define USBREMOTEPERSONALITY_IBY__
+
+#ifdef __USB
+#ifdef __USB_REMOTE_PERSONALITY
+ECOM_PLUGIN(usbremotepersonality.dll, 10283307.rsc)
+#endif
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/src/10283307.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* 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 UsbRemotePersonality
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x10283307;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10283306;
+
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10283308;
+					version_no = 1;
+					display_name = "Remote Personality Change plugin";
+					//default_data = "00000000";
+					//opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/src/cremotepersonalityhandler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,507 @@
+/*
+* 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:  Handles Remote personalities change
+*
+*/
+
+
+#include <e32base.h>
+#include <e32std.h>
+#include <versioninfo.h>
+#include <d32usbc.h>
+#include <usbman.h>
+#include <usbwatcher.h>
+
+#include "cremotepersonalityhandler.h"
+#include "csetpersonality.h" 
+#include "debug.h"
+
+const TUint KValueLoByte = 2;
+const TUint KValueHiByte = 3;
+const TUint KIndexLoByte = 4;
+const TUint KIndexHiByte = 5;
+const TUint KLengthLoByte = 6;
+const TUint KLengthHiByte = 7;
+
+const TUint KOneByte = 8; // for shifting data to one byte
+
+const TUint KGetPersonalitiesHeaderLen = 4;
+const TUint KItemsPerPersonality = 2;
+
+const TUint8 KStringDescriptorsBase = 0xED; // string descriptors will be written starting from this index, descendingly; 0xEE is used for OS string descriptor
+
+const TUint KAllPersonalitiesDescriptorType = 0x12; // All Personalities Descriptor type 
+
+const TUint KSetupPacketLength = 8; // 8 bytes
+
+const TUint KS6032MajorNumber = 3; // 3.2 major number is 3
+
+const TInt K32DevicePCSuite = 113;
+const TInt K32DeviceMS = 114;
+const TInt K32DevicePTP = 115;
+
+const TInt KHostPCSuite = 1;
+const TInt KHostMS = 2;
+const TInt KHostPTP = 3;
+
+// ---------------------------------------------------------------------------
+// Decoding EP0 buffer
+// ---------------------------------------------------------------------------
+//
+void TSetupPacket::Decode(const RBuf8& aSetupPacket)
+    {
+        
+    if (aSetupPacket.Length() < KSetupPacketLength)
+        {
+        iRequest = CRemotePersonalityHandler::EUnknown; 
+        return;
+        }
+    
+    iType           = aSetupPacket[0];
+    iRequest        = static_cast<CRemotePersonalityHandler::TRequest>(aSetupPacket[1]);
+    iValue          = static_cast<TUint16>(aSetupPacket[KValueLoByte] | 
+                                            (aSetupPacket[KValueHiByte] << KOneByte) );
+    iIndex          = static_cast<TUint16>(aSetupPacket[KIndexLoByte] |
+                                            (aSetupPacket[KIndexHiByte] << KOneByte) );
+    iLength         = static_cast<TUint16>(aSetupPacket[KLengthLoByte] |
+                                            (aSetupPacket[KLengthHiByte] << KOneByte) );
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//  
+CRemotePersonalityHandler* CRemotePersonalityHandler::NewL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::NewL" ) );
+    
+    CRemotePersonalityHandler* self = new (ELeave) CRemotePersonalityHandler();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CRemotePersonalityHandler::CRemotePersonalityHandler() : 
+                                        iLastResult(EUndefinedError)
+    {
+    iSetupPacket.iRequest = CRemotePersonalityHandler::EUnknown;
+    }
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::ConstructL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::ConstructL" ) );
+    iSetPersonalityHandler = CSetPersonality::NewL(*this);
+    
+    iMappingIsNeeded = IsMappingNeededL();
+    }
+    
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CRemotePersonalityHandler::~CRemotePersonalityHandler()
+    {
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::~CRemotePersonalityHandler" ) );
+    
+    delete iSetPersonalityHandler;
+                 
+    iPersonalities.Close(); // T-classes' objects in RArray do not require to be "destroyed"
+            
+    }   
+    
+// ---------------------------------------------------------------------------
+// SetPersonality request has been completed
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::SetPersonalityCallBack(TLastResult aResult)
+    {
+    
+    FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::SetPersonalityCallBack aResult = %d" ), aResult));
+    
+    iLastResult = aResult;
+    iSetupPacket.iRequest = CRemotePersonalityHandler::EUnknown;
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Personality-related requests handler
+// ---------------------------------------------------------------------------
+//
+TInt CRemotePersonalityHandler::Handle(const RBuf8& aSetupBuffer, RBuf8& aData)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::Handle" ) );
+    
+    TRAPD(err, DoHandleL(aSetupBuffer, aData));
+    
+    return static_cast<TLastResult>(err);
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Personality-related requests internal handler
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::DoHandleL(const RBuf8& aSetupBuffer, RBuf8& aData)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::DoHandleL" ) );
+    
+    iSetupPacket.Decode(aSetupBuffer);
+    
+    FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::DoHandleL: Request = %d" ), iSetupPacket.iRequest));
+    
+    switch(iSetupPacket.iRequest)
+        {
+        
+        case EGetAllPersonalities       :
+            {
+            iLastResult = EUndefinedError; // will be updated after completing the request
+            
+            GetPersonalitiesL(aData);
+            
+            iLastResult = ESuccess; //static_cast<TLastResult>(err);
+            
+            break;
+            }
+        
+        case EGetLastResult             :
+            {
+            GetLastResultL(aData);
+            break;
+            }
+        
+        case ESetPersonality            :
+            {
+            
+            iLastResult = EUndefinedError; // will be updated after copmleting the request
+
+            SetPersonalityL();
+            
+            iLastResult = EDataTransferInProgress; 
+            
+            break;
+            
+            }
+                
+        case EGetPersonalityDescriptor  :
+        case EGetPersonality            :
+        case EGetLockState              :
+        case ESetLockState              :
+        
+        default:
+            {
+                
+            FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::Handle ***Request Is Not Supported***" ) );
+            
+            User::Leave(KErrNotSupported); 
+            
+            }
+        }
+     
+    }
+    
+// ---------------------------------------------------------------------------
+// Set links to needed services
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::Initialize( RDevUsbcClient& aLdd, 
+                                            RUsbWatcher& aUsbWatcher,
+                                            RUsb& aUsbManager)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::Initialize" ) );
+    
+    iUsbWatcher = &aUsbWatcher;
+    iUsbManager = &aUsbManager;
+    iLdd = &aLdd;
+    
+    iSetPersonalityHandler->SetUsbWatcher(iUsbWatcher);
+    
+    // Read personalities
+    TRAPD(err, ReadPersonalitiesL());
+    
+    FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::Initialize: ReadPersonalities err  = %d" ), err));
+    
+    // Save personalities descriptions, to enable read of them by standard GetDescriptor request 
+    TRAP(err, SavePersonalitiesStringsL());
+    
+    FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::Initialize: SavePersString err  = %d" ), err));
+   
+    }
+
+// ---------------------------------------------------------------------------
+// Process GetAllPersonalities request
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::GetPersonalitiesL(RBuf8& aPersonalities)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::GetPersonalities" ) );
+    
+    // check the request
+    if((iSetupPacket.iValue != 0) || (iSetupPacket.iIndex != 0))
+        {
+
+        FLOG( _L( "[USBREMOTEPERSONALITY]\t**** CRemotePersonalityHandler::GetPersonalities SetupPacket has wrong data *****" ) );
+        User::Leave(EInvalidRequest);
+
+        }
+
+    TInt8 responseLength(KGetPersonalitiesHeaderLen+iPersonalities.Count()*KItemsPerPersonality); // 4 mandatory bytes for header + 2 bytes per personality
+
+    FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::GetPersonalities Response length is %d bytes" ), responseLength));
+    
+    aPersonalities.Close();
+    aPersonalities.Create(responseLength);
+    
+    // Panic on Append never can be rised in this method, due to aPersonalities length exactly equal the appending data length.  
+    aPersonalities.Append(responseLength);
+    aPersonalities.Append(KAllPersonalitiesDescriptorType); // All Personalities Descriptor type 
+    
+    TInt err(ESuccess);
+    TInt currentPersonalityId;
+    
+    err = iUsbManager->GetCurrentPersonalityId(currentPersonalityId);
+    if(ESuccess != err)
+        {
+        User::Leave(EUndefinedError);
+        }
+        
+    FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::GetPersonalities Current personality Id is %d" ), currentPersonalityId));
+    
+    // in S60 3.2 or older, map some personality ids into newer set
+    if(iMappingIsNeeded)
+    	{
+    	currentPersonalityId = MapPersonalityIdFromDeviceToHostL(currentPersonalityId);
+    	}
+    
+    aPersonalities.Append(static_cast<TInt8>(currentPersonalityId));
+    aPersonalities.Append(static_cast<TInt8>(iPersonalities.Count()));
+    
+    TUint counter(KGetPersonalitiesHeaderLen); // counter for aPersonalities descriptor, 4 bytes already written
+    
+    for(TUint i(0); i < iPersonalities.Count(); ++i, counter = counter + KItemsPerPersonality)
+        {
+        
+        TPersonality personality;
+        
+        if(iMappingIsNeeded)
+        	{
+        	personality.iId = MapPersonalityIdFromDeviceToHostL(iPersonalities[i].iId);
+        	}
+        	else
+        	{
+        	personality.iId = iPersonalities[i].iId;	
+        	}
+        	
+        aPersonalities.Append(static_cast<TInt8>(personality.iId));
+        aPersonalities.Append(static_cast<TInt8>(iPersonalities[i].iIndex));        
+    
+        FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::GetPersonalities Added personality id %d Index %d" ), aPersonalities[counter], aPersonalities[counter + 1]));
+
+        }
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Reads personalities 
+// ---------------------------------------------------------------------------
+//
+void CRemotePersonalityHandler::ReadPersonalitiesL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::ReadPersonalitiesL" ) );
+    
+    RArray<TInt> personalityIds;
+    CleanupClosePushL(personalityIds);
+    
+    User::LeaveIfError(iUsbManager->GetPersonalityIds(personalityIds));
+    
+    FTRACE(FPrint(
+           _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::ReadPersonalities There are %d personalities supported" ), personalityIds.Count()));
+    
+    // save ids to iPersonalities           
+    iPersonalities.Reset();
+    TPersonality p;
+    
+    for(TUint i(0); i < personalityIds.Count(); ++i)
+        {
+    
+        p.iId = personalityIds[i];
+        p.iIndex = KStringDescriptorsBase - i;
+        
+        // iPersonalities is a dynamic array, no error handling is needed on Append    
+        iPersonalities.Append(p);
+            
+        FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::ReadPersonalities Personality id = %d Index = %d" ), iPersonalities[i].iId, iPersonalities[i].iIndex));
+
+        }
+        
+    CleanupStack::PopAndDestroy(&personalityIds); // personalityIds
+
+    }
+
+// ---------------------------------------------------------------------------
+// Saves personalities descriptions as standard usb string descriptors
+// ---------------------------------------------------------------------------
+//  
+void CRemotePersonalityHandler::SavePersonalitiesStringsL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::SavePersonalitiesStringsL" ) );
+    
+    HBufC* description; // personality description
+    for(TUint i(0); i<iPersonalities.Count(); ++i)
+        {
+        // gets description; data owenerships hands over to caller
+        User::LeaveIfError(iUsbManager->GetDescription(iPersonalities[i].iId, description));
+        
+        FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::SavePersonalitiesStrings Personality Id = %d Description length =  %d" ), iPersonalities[i].iId, description->Length()));
+        
+        // save string to repository
+        User::LeaveIfError(iLdd->SetStringDescriptor(iPersonalities[i].iIndex, *description));
+        
+        FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::SavePersonalitiesStrings Personality description saved with index %d" ), iPersonalities[i].iIndex));
+
+        delete description;
+        description = 0;
+        }
+        
+    }
+    
+// ---------------------------------------------------------------------------
+// Process SetPersonality request
+// ---------------------------------------------------------------------------
+//  
+void CRemotePersonalityHandler::SetPersonalityL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::SetPersonality" ) );
+    
+    // check the request
+    if((iSetupPacket.iLength != 0) || (iSetupPacket.iIndex != 0))
+        {
+
+        FLOG( _L( "[USBREMOTEPERSONALITY]\t**** CRemotePersonalityHandler::SetPersonality SetupPacket has wrong data *****" ) );
+        User::Leave(EInvalidRequest);
+
+        }
+    
+    if(iMappingIsNeeded)
+    	{
+    	iSetupPacket.iValue = MapPersonalityIdFromHostToDeviceL(iSetupPacket.iValue);
+    	}
+    	
+    // due to watcher process SetPersonality somehow strange, here is check for valid id	
+    for(TUint i(0); i < iPersonalities.Count(); ++i)
+    	{
+    	if(iSetupPacket.iValue == iPersonalities[i].iId)
+    		{
+    		// set personality
+    		iSetPersonalityHandler->SetPersonality(iSetupPacket.iValue);
+    		return;
+    		}
+    	}
+    	
+    // did not find personality id in list of supported personalities
+    iLastResult = ENonExistingPersonality;
+    iSetupPacket.iRequest = CRemotePersonalityHandler::EUnknown;
+    User::Leave(ENonExistingPersonality);    
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Process GetLastResult request
+// ---------------------------------------------------------------------------
+//  
+void CRemotePersonalityHandler::GetLastResultL(RBuf8& aLastResult)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCRemotePersonalityHandler::GetLastResult" ) );
+    
+    // check the request
+    if((iSetupPacket.iValue != 0) || (iSetupPacket.iIndex != 0))
+        {
+
+        FLOG( _L( "[USBREMOTEPERSONALITY]\t**** CRemotePersonalityHandler::GetLastResult SetupPacket has wrong data *****" ) );
+        User::Leave(EInvalidRequest);
+
+        }
+    
+    aLastResult.Close();
+    aLastResult.Create(1); // Length of response to GetLastResult request is 1 byte always.
+    
+    // Panic on Append never can be rised here, due to aPersonalities length exactly equal the appending data length.  
+    aLastResult.Append(static_cast<TInt8>(iLastResult));
+    
+}
+
+TBool CRemotePersonalityHandler::IsMappingNeededL()
+{
+	VersionInfo::TPlatformVersion platformVersion;
+	User::LeaveIfError( VersionInfo::GetVersion( platformVersion ) );
+	
+	if(platformVersion.iMajorVersion > KS6032MajorNumber) return EFalse;
+	
+	return ETrue;	
+}
+
+TInt CRemotePersonalityHandler::MapPersonalityIdFromDeviceToHostL(TInt aPersonality)
+{
+	switch(aPersonality)
+	{
+		case K32DevicePCSuite: return KHostPCSuite;
+		case K32DeviceMS: return KHostMS;
+		case K32DevicePTP: return KHostPTP;
+		
+		default: return aPersonality;	
+	}
+}
+
+TInt CRemotePersonalityHandler::MapPersonalityIdFromHostToDeviceL(TInt aPersonality)
+{
+	switch(aPersonality)
+	{
+		case KHostPCSuite: return K32DevicePCSuite;
+		case KHostMS: return K32DeviceMS;
+		case KHostPTP: return K32DevicePTP;
+		
+		default: return aPersonality;	
+	}
+	
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/src/cremotepersonalityhandlerplugin.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:  Implements ECOM methods for this plug-in
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+
+#include "cremotepersonalityhandler.h"
+
+/**
+ * Define the private interface UIDs
+ */
+const TImplementationProxy UsbRemotePersonalityImplementationTable[] =
+    {
+  IMPLEMENTATION_PROXY_ENTRY(0x10283308, CRemotePersonalityHandler::NewL),
+    };
+
+/**
+ * Return number of implementations
+ */
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(UsbRemotePersonalityImplementationTable) / sizeof(TImplementationProxy);
+
+    return UsbRemotePersonalityImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/src/csetpersonality.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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:  Handles Set personality request
+*
+*/
+
+
+#include <usbwatcher.h>
+
+#include "csetpersonality.h"
+#include "cremotepersonalityhandler.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//  
+CSetPersonality* CSetPersonality::NewL(CRemotePersonalityHandler& aCallBack)
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::NewL" ) );
+    
+    CSetPersonality* self = new (ELeave) CSetPersonality(aCallBack);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// Default construction
+// ---------------------------------------------------------------------------
+//
+CSetPersonality::CSetPersonality(CRemotePersonalityHandler& aCallBack) : 
+                                        CActive(EPriorityStandard),
+                                        iCallBack(aCallBack)
+    {
+    CActiveScheduler::Add(this);
+     }
+        
+// ---------------------------------------------------------------------------
+// Two-phase construction
+// ---------------------------------------------------------------------------
+//
+void CSetPersonality::ConstructL()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::ConstructL" ) );
+    
+    }
+    
+// ---------------------------------------------------------------------------
+// Destruction
+// ---------------------------------------------------------------------------
+//
+CSetPersonality::~CSetPersonality()
+    {
+    
+    FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::~CSetPersonality" ) );
+    Cancel();
+      
+    }   
+  
+// ---------------------------------------------------------------------------
+// Sets Usb Watcher
+// ---------------------------------------------------------------------------
+//
+void CSetPersonality::SetUsbWatcher(RUsbWatcher* aUsbWatcher)
+    {
+    iUsbWatcher = aUsbWatcher;
+    }     
+
+// ---------------------------------------------------------------------------
+// Cancellation
+// ---------------------------------------------------------------------------
+//
+void CSetPersonality::DoCancel()
+    {
+    iUsbWatcher->CancelSetPersonality();
+    }
+    
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CSetPersonality::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// Asynchronous request has been completed
+// ---------------------------------------------------------------------------
+//
+void CSetPersonality::RunL()
+    {
+        
+        FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCSetPersonality::RunL iStatus.Int() = %d" ), iStatus.Int()));
+
+        CRemotePersonalityHandler::TLastResult result(CRemotePersonalityHandler::EUndefinedError); 
+        
+         // set result code according to the problem happened
+        switch(iStatus.Int())
+            {
+            case KErrNone:
+                {
+                result =CRemotePersonalityHandler::ESuccess;
+                break;
+                }
+            case KErrNotFound:
+                {
+                result = CRemotePersonalityHandler::ENonExistingPersonality;
+                break;
+                }
+            case KErrNotSupported:
+                {
+                result = CRemotePersonalityHandler::EFeatureIsNotSupported;
+                break;
+                }
+            case KErrCancel: 
+            default:
+                {
+                result = CRemotePersonalityHandler::EUndefinedError;
+                }
+            }
+       iCallBack.SetPersonalityCallBack(result);
+    }
+
+// ---------------------------------------------------------------------------
+// Process SetPersonality request
+// ---------------------------------------------------------------------------
+//  
+void CSetPersonality::SetPersonality(TUint aPersonalityId)
+    {
+    
+    FTRACE(FPrint(
+          _L("[USBREMOTEPERSONALITY]\tCSetPersonality::SetPersonality Personality Id = %d" ), aPersonalityId));
+    
+    if(IsActive())
+        {
+        Cancel();
+        }
+        
+    // No Ask-on-connection query, no confirmation for unload personality   
+    iUsbWatcher->SetPersonality(iStatus, aPersonalityId, EFalse, ETrue);
+    SetActive();
+    
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/Bmarm/USBRemotePersonalityTestU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/Bwins/USBRemotePersonalityTestU.DEF	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/EABI/USBRemotePersonalityTestU.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/conf/USBRemotePersonalityTest.cfg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* 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: 
+*
+*/
+
+[StifSettings]
+CapsModifier= USBRemotePersonalityTest.exe
+[EndStifSettings]
+
+// USBRemotePersonalityTest Module - total 9 tc
+
+// USBRemotePersonalityTest Api Tests (9 tc)
+
+[Test]
+title Create Plugin (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest CreatePluginImplementationL
+delete tester
+[Endtest]
+
+[Test]
+title Initialize (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest InitializeTestL
+delete tester
+[Endtest]
+
+[Test]
+title Check Last Result (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest CheckLastResultTestL
+delete tester
+[Endtest]
+
+[Test]
+title Get All Personalities (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest GetAllPersonalitiesTestL
+delete tester
+[Endtest]
+
+[Test]
+title Set Personality (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest SetPersonalityTestL
+delete tester
+[Endtest]
+
+[Test]
+title Get Personality (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest GetPersonalityTestL
+delete tester
+[Endtest]
+
+[Test]
+title Get Personality Descriptor (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest GetPersonalityDesTestL
+delete tester
+[Endtest]
+
+[Test]
+title Get Lock State (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest GetLockStateTestL
+delete tester
+[Endtest]
+
+[Test]
+title Set Lock State (USB Remote Personality Plugin Api Test)
+create USBRemotePersonalityTest tester
+tester ExecuteApiTest SetLockStateTestL
+delete tester
+[Endtest]
+
+// Add new api tests here
+// ...
+
+
+// USBRemotePersonalityTest Module Tests (... tc)
+
+/*
+[Test]
+title Example Api Test
+create USBRemotePersonalityTest tester
+tester ExecuteModuleTest ExampleModuleTest
+delete tester
+[Endtest]
+*/
+
+// Add new module tests here
+// ...
+
+
+// USBRemotePersonalityTest Branch Tests (... tc)
+
+/*
+[Test]
+title Example Api Test
+create USBRemotePersonalityTest tester
+tester ExecuteBranchTest ExampleBranchTest
+delete tester
+[Endtest]
+*/
+
+// Add new branch tests here
+// ...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* 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:
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          USBRemotePersonalityTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      LocalServices CommDD
+
+DEFFILE         USBRemotePersonalityTest.def
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE	../inc
+USERINCLUDE	../../../inc
+
+SOURCEPATH      ../src
+SOURCE          USBRemotePersonalityTest.cpp
+SOURCE          USBRemotePersonalityTestBlocks.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY		ecom.lib
+LIBRARY         usbman.lib
+LIBRARY         usbwatcher.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_ats.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,61 @@
+;
+; 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: 
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 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\USBRemotePersonalityTest.dll"-"c:\Sys\Bin\USBRemotePersonalityTest.dll"
+"\epoc32\release\armv5\udeb\USBRemotePersonalityTest.exe"-"c:\Sys\Bin\USBRemotePersonalityTest.exe"
+"..\init\USBRemotePersonalityTest_ats.ini"-"e:\testing\init\USBRemotePersonalityTest.ini"
+"..\conf\USBRemotePersonalityTest.cfg"-"e:\testing\conf\USBRemotePersonalityTest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_exe.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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:
+*
+*/
+
+
+#if defined(__S60_)
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          USBRemotePersonalityTest.exe
+TARGETTYPE      exe
+UID		0 0xEF4892C6
+
+CAPABILITY      LocalServices CommDD
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          USBRemotePersonalityTest_exe.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+
+EPOCSTACKSIZE   40960
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/USBRemotePersonalityTest_phone.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,61 @@
+;
+; 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: 
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x1028315F], 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\USBRemotePersonalityTest.exe"-"c:\Sys\Bin\USBRemotePersonalityTest.exe"
+"\epoc32\release\armv5\udeb\USBRemotePersonalityTest.dll"-"c:\Sys\Bin\USBRemotePersonalityTest.dll"
+"..\init\USBRemotePersonalityTest_phone.ini"-"c:\testframework\testframework.ini"
+"..\conf\USBRemotePersonalityTest.cfg"-"c:\testframework\USBRemotePersonalityTest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+USBRemotePersonalityTest.mmp
+USBRemotePersonalityTest_exe.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/build_sis_ats.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 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: 
+@rem
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis USBRemotePersonalityTest_ats.pkg
+call signsis USBRemotePersonalityTest_ats.sis USBRemotePersonalityTest_ats.sisx rd.cer rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/group/build_sis_phone.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 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: 
+@rem
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis USBRemotePersonalityTest_phone.pkg
+call signsis USBRemotePersonalityTest_phone.sis USBRemotePersonalityTest_phone.sisx rd.cer rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/inc/USBRemotePersonalityTest.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,230 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+#ifndef USBREMOTEPERSONALITYTEST_H
+#define USBREMOTEPERSONALITYTEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include <d32usbc.h>
+#include <usbman.h>
+#include <usbwatcher.h>
+#include <usbpersonalityids.h>
+
+#include "cremotepersonalityhandler.h"
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+const TUint KRemotePersonalityPluginImpUid = 0x10283308;
+const TUint KSetupPacketLength = 8;
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Logging path
+_LIT( KUSBRemotePersonalityTestLogPath, "\\logs\\testframework\\USBRemotePersonalityTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+//_LIT( KUSBRemotePersonalityTestLogPath, "e:\\testing\\stiflogs\\" ); 
+
+// Log file
+_LIT( KUSBRemotePersonalityTestLogFile, "USBRemotePersonalityTest.txt" ); 
+_LIT( KUSBRemotePersonalityTestLogFileWithTitle, "USBRemotePersonalityTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CUSBRemotePersonalityTest;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TUSBRemotePersonalityTestResult
+    {
+    ETestCasePassed,
+    ETestCaseFailed
+    };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+*  CUSBRemotePersonalityTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CUSBRemotePersonalityTest) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CUSBRemotePersonalityTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUSBRemotePersonalityTest();
+
+    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.
+        */
+        CUSBRemotePersonalityTest( 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 ExecuteApiTest( CStifItemParser& aItem );
+        virtual TInt ExecuteModuleTest( CStifItemParser& aItem );
+        virtual TInt ExecuteBranchTest( CStifItemParser& aItem );
+        
+        /**
+         * Method used to log version of test class
+         */
+        void SendTestClassVersion();
+
+        //ADD NEW METHOD DEC HERE
+        //[TestMethods] - Do not remove
+
+	void DoExecuteApiTestL( TPtrC aApiTestName, TUSBRemotePersonalityTestResult& aTestResult );
+	
+	void CreatePluginImplementationTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void InitializeTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void CheckLastResultTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void GetAllPersonalitiesTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void SetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void GetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void GetPersonalityDesTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void GetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult );
+	void SetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult );	
+	
+	void DoExecuteModuleTestL( TPtrC aModuleTestName, TUSBRemotePersonalityTestResult& aTestResult );
+	
+	void ExampleModuleTestL( TUSBRemotePersonalityTestResult& aTestResult );
+
+	void DoExecuteBranchTestL( TPtrC aBranchTestName, TUSBRemotePersonalityTestResult& aTestResult );
+	
+	void ExampleBranchTestL( TUSBRemotePersonalityTestResult& aTestResult );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        
+        RUsb* iUsbMan;
+        RDevUsbcClient* iDevUsbClient;
+        RUsbWatcher* iUsbWatcher;
+        RBuf8 iSetupBuff;
+        RBuf8 iDataBuff;        
+        
+        CRemotePersonalityHandler *iPlugin;
+        
+        TUid iPluginDtorIDKey;
+
+        // 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      // USBREMOTEPERSONALITYTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/init/USBRemotePersonalityTest_ats.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,235 @@
+#
+# 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 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= USBRemotePersonalityTest_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= USBRemotePersonalityTestUSBRemotePersonalityTestUSBRemotePersonalityTest
+# 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\USBRemotePersonalityTest.cfg
+[End_Module]
+
+
+# Load testmoduleUSBRemotePersonalityTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBRemotePersonalityTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBRemotePersonalityTest 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/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/init/USBRemotePersonalityTest_phone.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,234 @@
+#
+# 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 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\USBRemotePersonalityTest\
+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= USBRemotePersonalityTestUSBRemotePersonalityTestUSBRemotePersonalityTest
+# 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\USBRemotePersonalityTest.cfg
+[End_Module]
+
+# Load testmoduleUSBRemotePersonalityTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBRemotePersonalityTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBRemotePersonalityTest 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/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTest.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,218 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "USBRemotePersonalityTest.h"
+#include <SettingServerClient.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::CUSBRemotePersonalityTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUSBRemotePersonalityTest::CUSBRemotePersonalityTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUSBRemotePersonalityTest::ConstructL()
+    {
+    //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(KUSBRemotePersonalityTestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KUSBRemotePersonalityTestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KUSBRemotePersonalityTestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    SendTestClassVersion();
+    
+    iUsbMan = new ( ELeave ) RUsb();
+    User::LeaveIfError( iUsbMan -> Connect() );
+    
+    iUsbWatcher = new ( ELeave ) RUsbWatcher();
+    User::LeaveIfError( iUsbWatcher -> Connect() );
+    
+    iDevUsbClient = new ( ELeave ) RDevUsbcClient();
+    User::LeaveIfError( iDevUsbClient -> Open( 0 ) );
+    
+    iPlugin = ( reinterpret_cast< CRemotePersonalityHandler* >( 
+            REComSession::CreateImplementationL( TUid::Uid( KRemotePersonalityPluginImpUid ), iPluginDtorIDKey ) ) );
+    
+    User::LeaveIfError( iSetupBuff.Create( KSetupPacketLength ) );
+    User::LeaveIfError( iDataBuff.Create( 0 ) );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBRemotePersonalityTest* CUSBRemotePersonalityTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CUSBRemotePersonalityTest* self = new (ELeave) CUSBRemotePersonalityTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CUSBRemotePersonalityTest::~CUSBRemotePersonalityTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+//-----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CUSBRemotePersonalityTest::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("USBRemotePersonalityTest.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* ) CUSBRemotePersonalityTest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTestBlocks.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,665 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "USBRemotePersonalityTest.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CUSBRemotePersonalityTest::Delete() 
+    {    
+    REComSession::DestroyedImplementation( iPluginDtorIDKey );        
+    if ( iPlugin )
+        {
+        delete iPlugin;
+        iPlugin = NULL;
+        }
+    REComSession::FinalClose();
+    
+    iSetupBuff.Close();
+    iDataBuff.Close();
+    
+    if ( iUsbMan )
+        {
+        iUsbMan -> Close();
+        delete iUsbMan;
+        iUsbMan = NULL;
+        }
+    
+    if ( iUsbWatcher )
+        {
+        iUsbWatcher -> Close();
+        delete iUsbWatcher;
+        iUsbWatcher = NULL;
+        }
+    
+    if ( iDevUsbClient )
+        {
+        iDevUsbClient -> Close();
+        delete iDevUsbClient;
+        iDevUsbClient = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CUSBRemotePersonalityTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+		ENTRY( "ExecuteApiTest", CUSBRemotePersonalityTest::ExecuteApiTest ),
+        ENTRY( "ExecuteModuleTest", CUSBRemotePersonalityTest::ExecuteModuleTest ),
+        ENTRY( "ExecuteBranchTest", CUSBRemotePersonalityTest::ExecuteBranchTest ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::ExecuteApiTest
+// -----------------------------------------------------------------------------
+
+TInt CUSBRemotePersonalityTest::ExecuteApiTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteApiTest" );
+	
+	TInt res;
+    TUSBRemotePersonalityTestResult testResult;
+    TPtrC apiTestName( KNullDesC );
+	
+	res = aItem.GetString( _L( "ExecuteApiTest" ), apiTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+		
+	TRAP( res, DoExecuteApiTestL( apiTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteApiTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteApiTest" );
+    return KErrNone;
+    }
+	
+	
+void CUSBRemotePersonalityTest::DoExecuteApiTestL( TPtrC aApiTestName, TUSBRemotePersonalityTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteApiTestL" );
+    if ( !aApiTestName.Compare( _L( "CreatePluginImplementationL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: CreatePluginImplementationL" );
+        CreatePluginImplementationTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "InitializeTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: InitializeTestL" );
+        InitializeTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "CheckLastResultTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: CheckLastResultTestL" );
+        CheckLastResultTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "GetAllPersonalitiesTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: GetAllPersonalitiesTestL" );
+        GetAllPersonalitiesTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "SetPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: SetPersonalityTestL" );
+        SetPersonalityTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "GetPersonalityTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: GetPersonalityTestL" );
+        GetPersonalityTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "GetPersonalityDesTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: GetPersonalityDesTestL" );
+        GetPersonalityDesTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "GetLockStateTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: GetLockStateTestL" );
+        GetLockStateTestL( aTestResult );
+        }
+    else if ( !aApiTestName.Compare( _L( "SetLockStateTestL" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: SetLockStateTestL" );
+        SetLockStateTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Api test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteApiTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::CreatePluginImplementationTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>CreatePluginImplementationTestL" );
+    
+    if ( !iPlugin )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<CreatePluginImplementationTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::InitializeTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>InitializeTestL" );
+    
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    if ( !iPlugin )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+    
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<InitializeTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::CheckLastResultTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>CheckLastResultTestL" );
+    TInt res;
+    TUint8 getLastResult;
+    TInt getLastResultLenght;
+    CRemotePersonalityHandler::TLastResult lastResult;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    getLastResult = CRemotePersonalityHandler::EGetLastResult;
+    getLastResultLenght = sizeof( getLastResult );
+    TPtrC8 const getLastResultString( &getLastResult, getLastResultLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, getLastResultString );
+    
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "Handle failed with value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+    
+    lastResult = static_cast< CRemotePersonalityHandler::TLastResult >( iDataBuff[0] );
+    iLog -> Log( _L( "Last result value: %d, expected %d"), lastResult, CRemotePersonalityHandler::EUndefinedError );   
+    if ( lastResult != CRemotePersonalityHandler::EUndefinedError )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<CheckLastResultTestL" );
+    }
+	
+void CUSBRemotePersonalityTest::GetAllPersonalitiesTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>GetAllPersonalitiesTestL" );
+    TInt res;
+    TUint8 getAll;
+    TInt getAllLenght;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+        
+    getAll = CRemotePersonalityHandler::EGetAllPersonalities;
+    getAllLenght = sizeof( getAll );
+    TPtrC8 const getAllString( &getAll, getAllLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, getAllString );
+  
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "Handle failed with value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+
+    iLog -> Log( _L( "Data length: %d, expected != 0"), iDataBuff.Length() ); 
+    if ( !iDataBuff.Length() )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<GetAllPersonalitiesTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::SetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>SetPersonalityTestL" );
+    TInt res;
+    TUint8 setPersonality;
+    TInt setPersonalityLenght;
+    TUint8 personalityType;
+    TInt personalityTypeLenght;
+    TUint8 getLastResult;
+    TInt getLastResultLenght;
+    CRemotePersonalityHandler::TLastResult lastResult;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    // Request type should be set in second byte
+    // Personality type should be set in third byte
+    setPersonality = CRemotePersonalityHandler::ESetPersonality;
+    setPersonalityLenght = sizeof( setPersonality );
+    TPtrC8 const setPersonalityString( &setPersonality, setPersonalityLenght );
+    personalityType = KUsbPersonalityIdMTP;
+    personalityTypeLenght = sizeof( personalityType );
+    TPtrC8 const personalityTypeString( &personalityType, personalityTypeLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );   
+    iSetupBuff.Replace( 1, 1, setPersonalityString );
+    iSetupBuff.Replace( 2, 1, personalityTypeString );
+
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "Handle failed with value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+
+    getLastResult = CRemotePersonalityHandler::EGetLastResult;
+    getLastResultLenght = sizeof( getLastResult );
+    TPtrC8 const getLastResultString( &getLastResult, getLastResultLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iDataBuff.FillZ();
+    iSetupBuff.Replace( 1, 1, getLastResultString );
+
+    res = iPlugin -> Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "Handle failed with value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+    
+    lastResult = static_cast< CRemotePersonalityHandler::TLastResult >( iDataBuff[0] );
+    iLog -> Log( _L( "Last result value: %d, expected %d"), lastResult, CRemotePersonalityHandler::EDataTransferInProgress );   
+    if ( lastResult != CRemotePersonalityHandler::EDataTransferInProgress )
+        {
+        aTestResult = ETestCaseFailed;
+        return;
+        }
+
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<SetPersonalityTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::GetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>GetPersonalityTestL" );
+    TInt res;
+    TUint8 getPersonality;
+    TInt getPersonalityLenght;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    // Request type should be set in second byte
+    getPersonality = CRemotePersonalityHandler::EGetPersonality;
+    getPersonalityLenght = sizeof( getPersonality );
+    TPtrC8 const getPersonalityString( &getPersonality, getPersonalityLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, getPersonalityString );
+
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNotSupported )
+        {
+        iLog -> Log( _L( "Handle completion value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+    
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<GetPersonalityTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::GetPersonalityDesTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>GetPersonalityDesTestL" );
+    TInt res;
+    TUint8 getPersonalityDes;
+    TInt getPersonalityDesLenght;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    // Request type should be set in second byte
+    getPersonalityDes = CRemotePersonalityHandler::EGetPersonalityDescriptor;
+    getPersonalityDesLenght = sizeof( getPersonalityDes );
+    TPtrC8 const getPersonalityDesString( &getPersonalityDes, getPersonalityDesLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, getPersonalityDesString );
+
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNotSupported )
+        {
+        iLog -> Log( _L( "Handle completion value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+    
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<GetPersonalityDesTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::GetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>GetLockStateTestL" );
+    TInt res;
+    TUint8 getLockState;
+    TInt getLockStateLenght;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    // Request type should be set in second byte
+    getLockState = CRemotePersonalityHandler::EGetLockState;
+    getLockStateLenght = sizeof( getLockState );
+    TPtrC8 const getLockStateString( &getLockState, getLockStateLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, getLockStateString );
+
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNotSupported )
+        {
+        iLog -> Log( _L( "Handle completion value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+    
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<GetLockStateTestL" );
+    }
+
+
+void CUSBRemotePersonalityTest::SetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+    STIF_LOG( "[STIF_LOG] >>>SetLockStateTestL" );
+    TInt res;
+    TUint8 setLockState;
+    TInt setLockStateLenght;
+    
+    User::LeaveIfNull( iPlugin );
+    iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
+    STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
+    
+    // Request type should be set in second byte
+    setLockState = CRemotePersonalityHandler::ESetLockState;
+    setLockStateLenght = sizeof( setLockState );
+    TPtrC8 const setLockStateString( &setLockState, setLockStateLenght );
+    
+    iSetupBuff.FillZ( KSetupPacketLength );
+    iSetupBuff.Replace( 1, 1, setLockStateString );
+
+    res = iPlugin->Handle( iSetupBuff, iDataBuff );
+    if ( res != KErrNotSupported )
+        {
+        iLog -> Log( _L( "Handle completion value: %d"), res );
+        aTestResult = ETestCaseFailed;
+        return;
+        }    
+    STIF_LOG( "[STIF_LOG] Handle request completed" );
+ 
+    aTestResult = ETestCasePassed;
+    STIF_LOG( "[STIF_LOG] <<<SetLockStateTestL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::ExecuteModuleTest
+// -----------------------------------------------------------------------------	
+
+TInt CUSBRemotePersonalityTest::ExecuteModuleTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteModuleTest" );
+	
+    TInt res;
+    TUSBRemotePersonalityTestResult testResult;
+    TPtrC moduleTestName( KNullDesC );
+
+    res = aItem.GetString( _L( "ExecuteModuleTest" ), moduleTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+
+    TRAP( res, DoExecuteModuleTestL( moduleTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteModuleTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteModuleTest" );
+    return KErrNone;
+    }	
+	
+	
+void CUSBRemotePersonalityTest::DoExecuteModuleTestL( TPtrC aModuleTestName, TUSBRemotePersonalityTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteModuleTestL" );
+    if ( !aModuleTestName.Compare( _L( "ExampleModuleTest" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: ExampleModuleTest" );
+        ExampleModuleTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Module test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteModuleTestL" );
+    }
+	
+	
+void CUSBRemotePersonalityTest::ExampleModuleTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExampleModuleTestL" );
+	
+    aTestResult = ETestCasePassed;
+	
+	STIF_LOG( "[STIF_LOG] <<<ExampleModuleTestL" );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUSBRemotePersonalityTest::ExecuteBranchTest
+// -----------------------------------------------------------------------------
+	
+TInt CUSBRemotePersonalityTest::ExecuteBranchTest( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteBranchTest" );
+	
+    TInt res;
+    TUSBRemotePersonalityTestResult testResult;
+    TPtrC branchTestName( KNullDesC );
+
+    res = aItem.GetString( _L( "ExecuteBranchTest" ), branchTestName );   
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "GetString failed with value: %d" ), res );
+        return res;
+        }
+
+    TRAP( res, DoExecuteBranchTestL( branchTestName, testResult ) );
+    if ( res != KErrNone )
+        {
+        iLog -> Log( _L( "DoExecuteBranchTestL error: %d"), res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteBranchTest" );
+    return KErrNone;
+    }
+
+	
+void CUSBRemotePersonalityTest::DoExecuteBranchTestL( TPtrC aBranchTestName, TUSBRemotePersonalityTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteBranchTestL" );
+    if ( !aBranchTestName.Compare( _L( "ExampleBranchTest" ) ) )
+        {
+        STIF_LOG( "[STIF_LOG] Branch test type: ExampleBranchTest" );
+        ExampleBranchTestL( aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "[STIF_LOG] Branch test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteBranchTestL" );
+    }
+	
+	
+void CUSBRemotePersonalityTest::ExampleBranchTestL( TUSBRemotePersonalityTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExampleBranchTestL" );
+	
+    aTestResult = ETestCasePassed;
+    
+	STIF_LOG( "[STIF_LOG] <<<ExampleBranchTestL" );
+	}
+	
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTest_exe.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* 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:   ?Description
+*
+*/
+
+
+
+// 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 
+    // USBRemotePersonalityTest_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/usbengines/usbwatcher/EABI/usbpersonalityu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,34 @@
+EXPORTS
+	_ZN15CUsbPersonality21ShowUsbConnectionNoteEv @ 1 NONAME
+	_ZN15CUsbPersonalityC2ER21TUsbPersonalityParams @ 2 NONAME
+	_ZN21CUsbPersonalityPlugin4NewLER21TUsbPersonalityParams4TUid @ 3 NONAME
+	_ZN21CUsbPersonalityPluginC2ER21TUsbPersonalityParams @ 4 NONAME
+	_ZN21CUsbPersonalityPluginD0Ev @ 5 NONAME
+	_ZN21CUsbPersonalityPluginD1Ev @ 6 NONAME
+	_ZN21CUsbPersonalityPluginD2Ev @ 7 NONAME
+	_ZN21TUsbPersonalityParams16SetPersonalityIdEi @ 8 NONAME
+	_ZN21TUsbPersonalityParamsC1ER4RUsbR23CUsbPersonalityNotifier @ 9 NONAME
+	_ZN21TUsbPersonalityParamsC2ER4RUsbR23CUsbPersonalityNotifier @ 10 NONAME
+	_ZN21TUsbPersonalityParamsD1Ev @ 11 NONAME
+	_ZN21TUsbPersonalityParamsD2Ev @ 12 NONAME
+	_ZN23CUsbPersonalityNotifier10DoShowNoteE4TUidRK6TDesC8R5TDes8 @ 13 NONAME ABSENT
+	_ZN23CUsbPersonalityNotifier11CancelQueryE4TUid @ 14 NONAME
+	_ZN23CUsbPersonalityNotifier4NewLEv @ 15 NONAME
+	_ZN23CUsbPersonalityNotifier8ShowNoteE4TUidRK6TDesC8R5TDes8 @ 16 NONAME
+	_ZN23CUsbPersonalityNotifier9CancelAllEv @ 17 NONAME
+	_ZN23CUsbPersonalityNotifier9ShowQueryE4TUidRK6TDesC8R5TDes8P20MUsbNotifierCallBackP14TRequestStatus @ 18 NONAME
+	_ZN23CUsbPersonalityNotifierC1Ev @ 19 NONAME ABSENT
+	_ZN23CUsbPersonalityNotifierC2Ev @ 20 NONAME ABSENT
+	_ZN23CUsbPersonalityNotifierD0Ev @ 21 NONAME
+	_ZN23CUsbPersonalityNotifierD1Ev @ 22 NONAME
+	_ZN23CUsbPersonalityNotifierD2Ev @ 23 NONAME
+	_ZNK21TUsbPersonalityParams13PersonalityIdEv @ 24 NONAME
+	_ZNK21TUsbPersonalityParams19PersonalityNotifierEv @ 25 NONAME
+	_ZNK21TUsbPersonalityParams6UsbManEv @ 26 NONAME
+	_ZTI15CUsbPersonality @ 27 NONAME ; #<TI>#
+	_ZTI21CUsbPersonalityPlugin @ 28 NONAME ; #<TI>#
+	_ZTV15CUsbPersonality @ 29 NONAME ; #<VT>#
+	_ZTV21CUsbPersonalityPlugin @ 30 NONAME ; #<VT>#
+	_ZN23CUsbPersonalityNotifier19CancelAllButCurrentEv @ 31 NONAME
+	_ZN23CUsbPersonalityNotifier9IsShowingE4TUid @ 32 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/EABI/usbwatcheru.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN11RUsbWatcher14SetPersonalityER14TRequestStatusiii @ 1 NONAME
+	_ZN11RUsbWatcher20CancelSetPersonalityEv @ 2 NONAME
+	_ZN11RUsbWatcher22SetPreviousPersonalityER14TRequestStatus @ 3 NONAME
+	_ZN11RUsbWatcher22SetPreviousPersonalityEv @ 4 NONAME
+	_ZN11RUsbWatcher28CancelSetPreviousPersonalityEv @ 5 NONAME
+	_ZN11RUsbWatcher34SetPreviousPersonalityOnDisconnectEv @ 6 NONAME
+	_ZN11RUsbWatcher7ConnectEv @ 7 NONAME
+	_ZN11RUsbWatcherC1Ev @ 8 NONAME
+	_ZN11RUsbWatcherC2Ev @ 9 NONAME
+	_ZN11RUsbWatcherD1Ev @ 10 NONAME
+	_ZN11RUsbWatcherD2Ev @ 11 NONAME
+	_ZNK11RUsbWatcher7VersionEv @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/bwins/usbpersonalityu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,23 @@
+EXPORTS
+	??0CUsbPersonality@@IAE@AAVTUsbPersonalityParams@@@Z @ 1 NONAME ; CUsbPersonality::CUsbPersonality(class TUsbPersonalityParams &)
+	??0CUsbPersonalityNotifier@@AAE@XZ @ 2 NONAME ABSENT ; CUsbPersonalityNotifier::CUsbPersonalityNotifier(void)
+	??0CUsbPersonalityPlugin@@IAE@AAVTUsbPersonalityParams@@@Z @ 3 NONAME ; CUsbPersonalityPlugin::CUsbPersonalityPlugin(class TUsbPersonalityParams &)
+	??0TUsbPersonalityParams@@QAE@AAVRUsb@@AAVCUsbPersonalityNotifier@@@Z @ 4 NONAME ; TUsbPersonalityParams::TUsbPersonalityParams(class RUsb &, class CUsbPersonalityNotifier &)
+	??1CUsbPersonalityNotifier@@UAE@XZ @ 5 NONAME ; CUsbPersonalityNotifier::~CUsbPersonalityNotifier(void)
+	??1CUsbPersonalityPlugin@@UAE@XZ @ 6 NONAME ; CUsbPersonalityPlugin::~CUsbPersonalityPlugin(void)
+	?CancelAll@CUsbPersonalityNotifier@@QAEXXZ @ 7 NONAME ; void CUsbPersonalityNotifier::CancelAll(void)
+	?CancelQuery@CUsbPersonalityNotifier@@QAEXVTUid@@@Z @ 8 NONAME ; void CUsbPersonalityNotifier::CancelQuery(class TUid)
+	?DoShowNote@CUsbPersonalityNotifier@@AAEHVTUid@@ABVTDesC8@@AAVTDes8@@@Z @ 9 NONAME ABSENT ; int CUsbPersonalityNotifier::DoShowNote(class TUid, class TDesC8 const &, class TDes8 &)
+	?NewL@CUsbPersonalityNotifier@@SAPAV1@XZ @ 10 NONAME ; class CUsbPersonalityNotifier * CUsbPersonalityNotifier::NewL(void)
+	?NewL@CUsbPersonalityPlugin@@SAPAV1@AAVTUsbPersonalityParams@@VTUid@@@Z @ 11 NONAME ; class CUsbPersonalityPlugin * CUsbPersonalityPlugin::NewL(class TUsbPersonalityParams &, class TUid)
+	?PersonalityId@TUsbPersonalityParams@@QBEHXZ @ 12 NONAME ; int TUsbPersonalityParams::PersonalityId(void) const
+	?PersonalityNotifier@TUsbPersonalityParams@@QBEAAVCUsbPersonalityNotifier@@XZ @ 13 NONAME ; class CUsbPersonalityNotifier & TUsbPersonalityParams::PersonalityNotifier(void) const
+	?SetPersonalityId@TUsbPersonalityParams@@QAEXH@Z @ 14 NONAME ; void TUsbPersonalityParams::SetPersonalityId(int)
+	?ShowNote@CUsbPersonalityNotifier@@QAEHVTUid@@ABVTDesC8@@AAVTDes8@@@Z @ 15 NONAME ; int CUsbPersonalityNotifier::ShowNote(class TUid, class TDesC8 const &, class TDes8 &)
+	?ShowQuery@CUsbPersonalityNotifier@@QAEHVTUid@@ABVTDesC8@@AAVTDes8@@PAVMUsbNotifierCallBack@@PAVTRequestStatus@@@Z @ 16 NONAME ; int CUsbPersonalityNotifier::ShowQuery(class TUid, class TDesC8 const &, class TDes8 &, class MUsbNotifierCallBack *, class TRequestStatus *)
+	?ShowUsbConnectionNote@CUsbPersonality@@UAEXXZ @ 17 NONAME ; void CUsbPersonality::ShowUsbConnectionNote(void)
+	?UsbMan@TUsbPersonalityParams@@QBEAAVRUsb@@XZ @ 18 NONAME ; class RUsb & TUsbPersonalityParams::UsbMan(void) const
+	??1TUsbPersonalityParams@@QAE@XZ @ 19 NONAME ; TUsbPersonalityParams::~TUsbPersonalityParams(void)
+	?CancelAllButCurrent@CUsbPersonalityNotifier@@QAEXXZ @ 20 NONAME ; void CUsbPersonalityNotifier::CancelAllButCurrent(void)
+	?IsShowing@CUsbPersonalityNotifier@@QAEHVTUid@@@Z @ 21 NONAME ; int CUsbPersonalityNotifier::IsShowing(class TUid)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/bwins/usbwatcheru.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,12 @@
+EXPORTS
+	??0RUsbWatcher@@QAE@XZ @ 1 NONAME ; RUsbWatcher::RUsbWatcher(void)
+	??1RUsbWatcher@@QAE@XZ @ 2 NONAME ; RUsbWatcher::~RUsbWatcher(void)
+	?CancelSetPersonality@RUsbWatcher@@QAEXXZ @ 3 NONAME ; void RUsbWatcher::CancelSetPersonality(void)
+	?CancelSetPreviousPersonality@RUsbWatcher@@QAEXXZ @ 4 NONAME ; void RUsbWatcher::CancelSetPreviousPersonality(void)
+	?Connect@RUsbWatcher@@QAEHXZ @ 5 NONAME ; int RUsbWatcher::Connect(void)
+	?SetPersonality@RUsbWatcher@@QAEXAAVTRequestStatus@@HHH@Z @ 6 NONAME ; void RUsbWatcher::SetPersonality(class TRequestStatus &, int, int, int)
+	?SetPreviousPersonality@RUsbWatcher@@QAEXAAVTRequestStatus@@@Z @ 7 NONAME ; void RUsbWatcher::SetPreviousPersonality(class TRequestStatus &)
+	?SetPreviousPersonality@RUsbWatcher@@QAEXXZ @ 8 NONAME ; void RUsbWatcher::SetPreviousPersonality(void)
+	?SetPreviousPersonalityOnDisconnect@RUsbWatcher@@QAEXXZ @ 9 NONAME ; void RUsbWatcher::SetPreviousPersonalityOnDisconnect(void)
+	?Version@RUsbWatcher@@QBE?AVTVersion@@XZ @ 10 NONAME ; class TVersion RUsbWatcher::Version(void) const
+
Binary file usbengines/usbwatcher/conf/usbwatcher.confml has changed
Binary file usbengines/usbwatcher/conf/usbwatcher_101F8801.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/backup_registration.xml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0" standalone="yes"?>
+
+<!--
+      USB Watcher backup registration file
+-->
+
+<backup_registration version="1.0">
+   <proxy_data_manager SID="0x10202BE9"/>
+   <restore requires_reboot="no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:  Build information file for project UsbWatcher
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+../group/usbpersonality.mmp
+../group/usbwatcher.mmp
+../group/usbwatcherserver.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+backup_registration.xml  /epoc32/data/z/private/101F9696/backup_registration.xml
+backup_registration.xml  /epoc32/release/winscw/udeb/z/private/101F9696/backup_registration.xml
+backup_registration.xml  /epoc32/release/winscw/urel/z/private/101F9696/backup_registration.xml
+
+../loc/usbman.loc MW_LAYER_LOC_EXPORT_PATH(usbman.loc)
+../rom/usbwatcher.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbwatcher.iby)
+// This file contains actual personality rss data
+../rom/usbwatcher_resources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(usbwatcher_resources.iby)
+
+//Usbmanrsc.iby is included by Symbian usbman.iby.
+// For l10n reaon it is not used but just to overwrite possible existing one
+../rom/usbmanrsc.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbmanrsc.iby)
+
+../conf/usbwatcher.confml MW_LAYER_CONFML(usbwatcher.confml)
+../conf/usbwatcher_101F8801.crml MW_LAYER_CRML(usbwatcher_101F8801.crml)
+
+../rom/mtp_symbian_temp.iby CORE_MW_LAYER_IBY_EXPORT_PATH(mtp_symbian_temp.iby)
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/usbpersonality.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* 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 definition file for project UsbPersonality
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          usbpersonality.dll
+CAPABILITY      LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ
+TARGETTYPE      dll
+UID             0x1000008d 0x102823F3
+VENDORID        VID_DEFAULT
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../inc
+
+SOURCEPATH      ../src
+SOURCE          cusbpersonality.cpp
+SOURCE          cusbpersonalityplugin.cpp
+SOURCE          cusbpersonalitynotifier.cpp
+SOURCE          tusbpersonalityparams.cpp
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+DEBUGLIBRARY    flogger.lib            // File logging
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/usbwatcher.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2002-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 definition file for project UsbWatcher
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          usbwatcher.dll
+CAPABILITY      ALL -TCB
+TARGETTYPE      DLL
+
+UID         0x1000008d 0x102823F4
+VENDORID    VID_DEFAULT
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../inc
+
+SOURCEPATH      ../src
+SOURCE          rusbwatcher.cpp
+
+LIBRARY         euser.lib
+DEBUGLIBRARY    flogger.lib            // File logging
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/usbwatcherserver.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* 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:  Project definition file for project UsbWatcher
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET        UsbWatcher.exe
+TARGETTYPE    exe
+
+TARGETPATH    /system/programs
+
+UID           0x1000008d 0x101F9696
+
+VENDORID      VID_DEFAULT
+
+CAPABILITY    LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ
+
+SOURCEPATH  ../src
+SOURCE      usbwatcher.cpp cusbwatcher.cpp cusbactivestate.cpp
+SOURCE      cusbwatchersession.cpp cusbwatcherserver.cpp
+SOURCE      cusbactivepersonalityhandler.cpp
+SOURCE      cusbwatcherscheduler.cpp
+SOURCE      cusbdevicelock.cpp
+SOURCE      cusbdevconstarter.cpp
+SOURCE      cusbglobalsystemstateobserver.cpp
+SOURCE      tusbindicatorhandler.cpp
+
+
+USERINCLUDE   ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE ../../usbotgwatcher/inc
+SYSTEMINCLUDE   /epoc32/include/usb
+
+
+START RESOURCE usbman_pcsmtp.rss
+TARGET	usbman_pcsmtp
+TARGETPATH /private/101fe1db
+HEADER
+LANGUAGE_IDS
+END
+
+START RESOURCE usbman_pcs.rss
+TARGET	usbman_pcs
+TARGETPATH /private/101fe1db
+HEADER
+LANGUAGE_IDS
+END
+
+START RESOURCE usbman_pcspam.rss
+TARGET	usbman_pcspam
+TARGETPATH /private/101fe1db
+HEADER
+LANGUAGE_IDS
+END
+
+START RESOURCE usbman_pcsmtppam.rss
+TARGET	usbman_pcsmtppam
+TARGETPATH /private/101fe1db
+HEADER
+LANGUAGE_IDS
+END
+
+
+LIBRARY       euser.lib             // Kernel API
+LIBRARY       usbman.lib            // RUsb API (i.e. USB Manager's client API)
+LIBRARY       etel.lib etelmm.lib   // Multimode Etel API
+LIBRARY       ecom.lib
+LIBRARY       usbpersonality.lib
+LIBRARY       centralrepository.lib // Central Repository (USB Personality API)
+LIBRARY       featmgr.lib
+LIBRARY       usbotgwatcher.lib  //OTG
+
+DEBUGLIBRARY  flogger.lib            // File logging
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbactivepersonalityhandler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,293 @@
+/*
+* Copyright (c) 2002-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:  Header file for class CUsbActivePersonalityHandler
+*
+*/
+
+
+#ifndef CUSBACTIVEPERSONALITYHANDLER_H
+#define CUSBACTIVEPERSONALITYHANDLER_H
+
+// INCLUDE FILES
+#include <etelmm.h>             // for fetching the IMEI code for serial number
+#include <mmtsy_names.h>        // for RTelServer names
+#include "cusbwatcher.h"
+
+const TUid KUidPersonalityPlugIns = {0x10274793};
+
+// FORWARD CLASS DECLARATIONS
+class CUsbPersonality;
+class TUsbPersonalityParams;
+class CUsbPersonalityNotifier;
+
+// CLASS DECLARATION
+
+/**
+*  Class to handle USB personality issues.
+*
+*  @lib euser.lib usbman.lib c32.lib centralrepository.lib
+*  @since Series 60 3.0
+*/
+NONSHARABLE_CLASS( CUsbActivePersonalityHandler ) : public CActive
+     
+    {
+public:  // Constructors and destructor
+        
+    /**
+     * Two-phased constructor.
+     *
+     * @param aUsbMan Reference to RUsb.
+     * @param aOwner Reference to CUsbWatcher.
+     * @return pointer to created object
+     */
+    static CUsbActivePersonalityHandler* NewL( RUsb& aUsbMan,
+            CUsbWatcher& aOwner );
+        
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbActivePersonalityHandler();
+
+public: // New functions
+        
+    /**
+     * Confirm personality load. If current personality can be unloaded
+     * and new personality can be loaded then this method will complete
+     * aStatus with KErrNone.
+     *
+     * @since Series 60 3.2
+     * @param aStatus Used to complete outstanding request.
+     */
+    void ConfirmPersonalityUnload( TRequestStatus& aStatus );
+        
+    /**
+     * Start personality.
+     *
+     * @since Series 60 3.2
+     * @param aPersonalityId Identification of the personality to be loaded.
+     * @param aAskOnConnectionSetting When this parameter is ETrue, "ask on connection" query is shown.
+     * @param aStatus Used to complete outstanding request.
+     */
+    void StartPersonality( TInt& aPersonalityId, 
+            TInt aAskOnConnectionSetting, TRequestStatus& aStatus );
+
+    /**
+     * Stop current personality.
+     *
+     * @since Series 60 3.2
+     * @param aStatus Used to complete outstanding request.
+     */
+    void StopPersonality( TRequestStatus& aStatus );
+
+    /**
+     * Called by the owner class when device state is changed.
+     *
+     * @since Series 60 3.0
+     * @param aState state of the device
+     */
+    void StateChangeNotify( TUsbDeviceState aStateOld,
+            TUsbDeviceState aStateNew );
+        
+    /**
+     * Called by the owner class when device state is changed.
+     *
+     * @since Series 60 3.2
+     */
+    void PersonalitySelected();
+     
+    /**
+     * Cancel Cable connected notifier
+     *
+     * @since Series 60 5.0
+     */
+    void CancelCableConnectedNotifier();
+    
+public: // from base class CActive
+
+    /**
+     * From CActive.
+     * This method is called when outstanding request is completed.
+     *
+     * @since Series 60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * This method is called when RunL() leaves.
+     *
+     * @since Series 60 3.0
+     * @param aError the error returned
+     * @return error
+     */
+    TInt RunError( TInt /*aError*/ );
+
+    /**
+      * From CActive
+      * This method is called when Cancel() is called and there is outstanding
+      * request pending.
+      *
+      * @since Series 60 3.0
+      */
+    void DoCancel();
+
+private:
+    
+    /** Personality handler states */
+    enum TUsbActivePersonalityState 
+        {
+        EUsbPersonalityIdle = 0,
+        EUsbPersonalityPrepareStart,
+        EUsbPersonalityStartUsb,
+        EUsbPersonalityFinishStart,
+        EUsbPersonalityStarted,
+        EUsbPersonalityPrepareStop,
+        EUsbPersonalityStopUsb,
+        EUsbPersonalityFinishStop
+        };
+
+    /**
+     * Construct USB serial number.
+     * @since Series 60 3.0
+     */    
+    void ConstructUsbSerialNumberL();
+    
+    /**
+     * Publish serial number to P&S for USB Manager.
+     * @since Series 60 3.0     
+     * @return In case of success KErrNone is returned.
+     */    
+    TInt PublishSerialNumber();
+        
+    /**
+     * Creates and returns a class handler object for the given personality.
+     * @since Series 60 3.0
+     * @param aPersonality Personality ID where return value is written.
+     * @return Pointer to created object
+     */
+    CUsbPersonality* NewPersonalityHandlerL( TInt aPersonality );
+
+    /**
+     * Constructor is prohibited.
+     * @param aUsbMan Reference to usb manager.
+     * @param aParent Reference to UsbWatcher.
+     */
+    CUsbActivePersonalityHandler( RUsb& aUsbMan, CUsbWatcher& aOwner );
+
+    /**
+     * C++ default constructor (no implementation provided).
+     */
+    CUsbActivePersonalityHandler();
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+        
+private:    // Data
+    /**
+     * Handle to Usb Manager
+     */
+    RUsb iUsbMan;
+    
+    /**
+     * Currently loaded personality
+     */
+    CUsbPersonality* iCurrentPersonalityHandler;
+
+    /**
+     * Dummy descriptor used by ask on connection.
+     */
+    TPtrC8 iDummy;
+    
+    /**
+     * Dummy descriptor buf
+     */
+    TBuf8<1> iDummyBuf;
+    
+    /**
+     * Buffer where selected personality is stored by the ask
+     * on connection.
+     */    
+    TPckgBuf<TInt> iPersonalityPckgBuf;
+
+    /**
+     * Owner of this class.
+     */
+    CUsbWatcher& iOwner;
+
+    /**
+     * Personality id of currently loaded personality.
+     */        
+    TInt *iPersonalityId;
+    
+    /**
+     * Ask on connection is either on (1) or off (0).
+     */    
+    TInt iAskOnConnectionSetting;
+
+    /**
+     * When value is ETrue then serial number is written to P&S.
+     */            
+    TBool iSerialNumberWritten;
+    
+    /**
+     * When value is ETrue then personality uses serial number.
+     */            
+    TBool iUseSerialNumber;
+    
+    /**
+     * Access to mobile phone functionality.
+     */                
+    RMobilePhone::TMobilePhoneIdentityV1 iPhoneInfo;
+    
+    /**
+     * State of the class.
+     */                
+    TUsbActivePersonalityState iState;
+    
+	/**
+	 * Cleanup process or normal process in various states
+	 */        
+    TBool isFailureCleanup;
+    
+    /**
+     * Request to be completed.
+     */                
+    TRequestStatus *iRequestStatus;
+    
+    /**
+     * Container class for personalities.
+     */                
+    TUsbPersonalityParams* iPersonalityParams;
+    
+    /**
+     * Handle to notifier class, which is used to show notes/queries.
+     */                    
+    CUsbPersonalityNotifier* iPersonalityNotifier;
+    
+    /**
+     * The device state.
+     */                    
+    TUsbDeviceState iDeviceState;
+    
+    /**
+     * Packages for queries
+     */
+    TUSBQueriesNotifierParamsPckg iQueryParams;
+    };
+
+#endif   // CUSBACTIVEPERSONALITYHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbactivestate.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2002-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:  Header file for class CUsbActiveState
+*
+*/
+
+
+#ifndef CUSBACTIVESTATE_H
+#define CUSBACTIVESTATE_H
+
+// INCLUDE FILES
+#include <e32base.h>
+
+// FORWARD DECLARATION
+class CUsbWatcher;
+
+// CLASS DECLARATION
+
+/**
+*  Class to handle USB state changes.
+*
+*  @lib euser.lib usbman.lib
+*  @since Series 60 2.?
+*/
+NONSHARABLE_CLASS( CUsbActiveState ) : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aUsbMan Reference to usb manager.
+        * @param aParent Reference to UsbMediaWatcher.
+        * @return Pointer to created object.
+        */
+        static CUsbActiveState* NewL( RUsb& aUsbMan, CUsbWatcher& aOwner );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CUsbActiveState();
+
+    public: // from base class CActive
+
+        /**
+        * From CActive.
+        * This method is called when device state has changed.
+        * New request is issued and device state is given to owner class.
+        *
+        * @since Series 60 2.?
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * If there is outstanding request pending when Cancel() is called then
+        * this method must cancel request.
+        *
+        * @since Series 60 2.?
+        */
+        void DoCancel();
+
+    public: // new methods
+
+        /**
+        * Get the current device state
+        * @return the current device state
+        *
+        * @since Series 60 3.2
+        */
+        TUsbDeviceState CurrentState();
+
+        /**
+        * Get previous device state
+        * @return previous device state
+        *
+        * @since Series 60 5.1
+        */
+        TUsbDeviceState PreviousState();
+
+    
+    private:
+
+        /**
+        * Constructor is prohibited.
+        * @param aUsbMan Reference to Usb manager.
+        * @param aParent Reference to CUsbMediaWatcher.
+        */
+        CUsbActiveState( RUsb& aUsbMan, CUsbWatcher& aOwner );
+
+        /**
+        * C++ default constructor (no implementation provided).
+        */
+        CUsbActiveState();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor when not deriving from CBase.
+        CUsbActiveState( const CUsbActiveState& );
+        // Prohibit assigment operator when not deriving from CBase.
+        CUsbActiveState& operator=( const CUsbActiveState& );
+
+    private: // Data
+        /**
+         * Handle to Usb Manager
+         */
+        RUsb iUsbMan;
+        
+        /**
+         * Refernce to owner class
+         */
+        CUsbWatcher& iOwner;
+
+        /**
+         * Current device state
+         */
+        TUsbDeviceState iCurrentState;
+
+        /**
+         * Previous device state
+         */
+        TUsbDeviceState iPreviousState;        
+
+    };
+
+#endif   // CUSBACTIVESTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbdevconstarter.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,130 @@
+/*
+* 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:  Header file for class CUsbDevConStarter
+*
+*/
+
+
+#ifndef CUSBDEVCONSTARTER_H
+#define CUSBDEVCONSTARTER_H
+
+#include <e32base.h>
+
+/**
+ * class for starting usbdevcon process
+ * This class will start usbdevcon process. It also supervises its
+ * termination. 
+ * @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CUsbDevConStarter ) : public CActive
+    {
+
+public:
+
+    //states for starting usbdevcon
+    enum TUsbDevConStarterState
+        {
+        EIdle,
+        EWaitingRendezvous,
+        ERunning
+        };
+
+    static CUsbDevConStarter* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbDevConStarter();
+
+    /**
+     * Start usbdevcon process
+     * The usbdevcon process is started, unless it is already running.
+     *
+     * @since S60 5.0
+     */
+    void Start();
+
+    /**
+     * Logon for usbdevcon process termination
+     *
+     * @since S60 5.0
+     */
+    void Logon();
+
+    /**
+     * StopRestarting prevents usbdevcon restart
+     * If usbdevcon terminates, it is not restarted, if StopRestarting has
+     * been called. 
+     *
+     * @since S60 5.0
+     */
+    void StopRestarting();
+
+private: // From base class
+
+    /**
+     * From CActive.
+     * Handles the process termination
+     *
+     * @since Series 60 5.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Never called in this implementation
+     *
+     * @since Series 60 5.0
+     * @param aError The error returned
+     * @return error
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * From CActive
+     * Cancels outstanding request.
+     * Note that process may be running after Cancel. If Start is called
+     * after Cancel, another process will be started. 
+     *
+     * @since Series 60 5.0
+     */
+    void DoCancel();
+
+private:
+
+    CUsbDevConStarter();
+
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Handle to UsbDevCon process
+     */
+    RProcess iProcess;
+    
+    /**
+     * Is set to run. 
+     */
+    TBool iStarted;
+
+    /**
+     * State of starting usbdevcon
+     */
+    TUsbDevConStarterState iState;
+    };
+
+#endif // CUSBDEVCONSTARTER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbdevicelock.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* 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:  Header file for class CUsbDeviceLock.
+*
+*/
+
+
+#ifndef CUSBDEVICELOCK_H
+#define CUSBDEVICELOCK_H
+
+class CUsbWatcher;
+
+/**
+ *  Class for device lock notification
+ *
+ *  @lib euser.lib usbman.lib SysUtil.lib
+ *  @since Series 60 2.?
+ */
+NONSHARABLE_CLASS( CUsbDeviceLock ) : public CActive
+    {
+
+public:
+
+    static CUsbDeviceLock* NewL( CUsbWatcher& aOwner );
+
+    virtual ~CUsbDeviceLock();
+
+public:
+    /**
+     * Subscribes device lock change event.
+     *
+     * @since Series 60 3.0
+     */    
+    void Subscribe();
+    
+    /**
+     * Current state of device lock.
+     *
+     * @since Series 60 3.0
+     * @return When set (ETrue) device is locked. When unset (EFalse) device is unlocked.
+     */
+    TBool Locked();
+    
+public: // from base class CActive
+    
+    /**
+     * From CActive.
+     * This method is never called in this implementation.
+     *
+     * @since Series 60 3.0
+     */
+    TInt RunError( TInt /*aError*/ );
+
+    /**
+     * From CActive.
+     * This method is called when device lock state has changed. 
+     * New state is given to owner class.
+     *
+     * @since Series 60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Will cancel outstanding request if called.
+     *
+     * @since Series 60 3.0
+     */
+    void DoCancel();
+      
+private:
+
+    /**
+     * C++ constructor.
+     */
+    CUsbDeviceLock( CUsbWatcher& aOwner );
+
+    CUsbDeviceLock();
+
+    void ConstructL();
+      
+
+private:
+    /**
+     * Handle to P&S key
+     */
+    RProperty  iProperty;
+    
+    /**
+     * Owner of this class
+     */
+    CUsbWatcher& iOwner;
+};
+
+#endif // CUSBDEVICELOCK_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbglobalsystemstateobserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* 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:  Header of CUsbGlobalSystemStateObserver
+*
+*/
+
+
+#ifndef CUSBGLOBALSYSTEMSTATEOBSERVER_H
+#define CUSBGLOBALSYSTEMSTATEOBSERVER_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32property.h>
+
+class CUsbWatcher;
+
+NONSHARABLE_CLASS( CUsbGlobalSystemStateObserver ) : public CActive
+{
+public:
+    static CUsbGlobalSystemStateObserver* NewL( CUsbWatcher& aUsbWatcher );
+    static CUsbGlobalSystemStateObserver* NewLC( CUsbWatcher& aUsbWatcher );
+    void Subscribe();
+    virtual ~CUsbGlobalSystemStateObserver();
+
+    /**
+     * Read and return global system state
+     * 
+     * @since Series 60 3.2
+     * @return systemstate
+     */
+    static TInt GlobalSystemState();
+
+private: // From base class
+    void RunL();
+    TInt RunError( TInt aError );
+    void DoCancel();
+        
+private:
+    CUsbGlobalSystemStateObserver( CUsbWatcher& aUsbWatcher );
+    void ConstructL();
+
+private: // data
+    RProperty iProperty;
+    CUsbWatcher& iUsbWatcher;
+};
+
+#endif // CUSBGLOBALSYSTEMSTATEOBSERVER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,457 @@
+/*
+* Copyright (c) 2002-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:  Header file for class CUsbWatcher
+*
+*/
+
+
+#ifndef CUSBWATCHER_H
+#define CUSBWATCHER_H
+
+#include <bldvariant.hrh>
+#include <e32base.h>
+#include <usbman.h>
+#include <e32property.h>
+#include <PSVariables.h>
+#include <centralrepository.h>
+#include <usbuinotif.h>
+#include <usbwatcher.h>
+#include "debug.h"
+#include "musbwatchernotify.h"
+#include "cusbwatchersession.h"
+#include "tusbindicatorhandler.h"
+
+
+class CUsbActiveState;
+class CUsbActivePersonalityHandler;
+class CUsbDeviceLock;
+class CUsbDevConStarter;
+class CUsbGlobalSystemStateObserver;
+class CUsbOtgWatcher; //OTG
+
+/**
+*  Struct for supported personalities.
+*
+*  This struct is used to store supported personalities.
+*
+*  @since Series 60 3.2
+*/
+struct TUsbSupportedPersonalityInf
+    {
+    
+    /**
+     * implementation Uid of the personality
+     */
+    TUid  iPersonalityUid;
+    
+    /**
+     * personality id
+     */
+    TInt  iPersonalityId;
+    
+    /**
+     * if set then serial number is used by the personality
+     */
+    TBool iUseSerialNumber;
+    };
+
+/**
+*  UsbWatcher core class.
+*
+*  This class starts, stops and changes personalities depending on the cable
+*  state or client changing the personality. There is always only one instance
+*  of this class.
+*
+*  @since Series 60 2.?
+*/
+NONSHARABLE_CLASS( CUsbWatcher ): public CActive
+    {
+
+public:
+
+    static CUsbWatcher* NewL();
+        
+    virtual ~CUsbWatcher();
+   
+    /**
+     * Used to register observer. Each created session will register observer.
+     *
+     * @since S60 3.2
+     * @param aObserver Pointer to observer class to be added.
+     */
+    void RegisterObserverL( MUsbWatcherNotify* aObserver );
+
+    /**
+     * Used to deregister observer. When session is terminated, 
+     * it must deregister the observer.
+     *
+     * @since S60 3.2
+     * @param aObserver Pointer to observer class to be removed.
+     */
+    void DeRegisterObserver( MUsbWatcherNotify* aObserver );
+
+    /**
+     * This method is called when operation is finished.
+     *
+     * @since S60 3.2
+     * @param aStatus Status of the ended operation.
+     */
+	void Notify( TInt aStatus );
+
+    /**
+     * This method returns personalities supported by the system.
+     *
+     * @since S60 3.2
+     * @return Refernce to the supported personalities array.
+     */
+    inline const RArray<TUsbSupportedPersonalityInf>& Personalities() const;
+
+    /**
+     * This method updates central repository key and if USB is connected
+     * it will also change the personality to new one.
+     * 
+     * Note that if KErrDiskFull is returned while the cable is connected,
+     * the personality was loaded, but it was not stored to Central Repository.
+     *
+     * @since S60 3.2
+     * @param aPersonalityId Personality id
+     * @param aNonBlocking If true, no personality switch  queries are shown
+     * @return KErrNone if success, otherwise system-wide error code.
+     */
+    void SetPersonality( TInt aPersonalityId, TBool aNonBlocking );
+    
+    /**
+     * Cancel outstanding SetPersonality() request. Everything is returned
+     * to the state before request was done.
+     *
+     * @since S60 3.2
+     */    
+    void CancelSetPersonality();
+
+    /**
+     * Set previous personality.
+     *
+     * @since S60 3.2
+     */
+    void SetPreviousPersonality();
+
+    /**
+     * Cancel outstanding SetPreviousPersonality() request. After this request
+     * everything is returned to the state like it was before the request.
+     *
+     * @since S60 3.2
+     */
+    void CancelSetPreviousPersonality();
+
+    /**
+     * Set previous personality when USB cable is disconnected. Note that
+     * if cable is already disconnected when this request is issued, service
+     * does nothing.
+     *
+     * @since S60 3.2
+     */
+    void SetPreviousPersonalityOnDisconnect();
+            
+    /**
+     * Write personality id to the central repository
+     *
+     * @since Series 60 3.2
+     * @param aPersonalityId Current personality id setting
+     * @return KErrNone in case of success
+     */
+    TInt WritePersonalityId( TInt aPersonalityId );
+
+    /**
+     * This method is called by the CUsbActiveState class when there is
+     * a change in USB state.
+     *
+     * @since Series 60 2.?
+     * @param aStateOld old device state
+     * @param aStateNew new device state
+     */
+    void StateChangeNotify( TUsbDeviceState aStateOld, 
+            TUsbDeviceState aStateNew );
+    
+   
+    /**
+     * This callback function is called when device is locked.
+     * 
+     * @since Series 60 2.?
+     * @return error
+     */
+    void Lock();
+    
+    /**
+     * This callback function is called when device is unlocked.
+     * 
+     * @since Series 60 2.?
+     * @return error
+     */
+    void Unlock();
+        
+    /**
+     * Stop loaded personality
+     * 
+     * @since Series 60 3.2
+     */
+    void StopPersonality();
+    
+    /**
+     * Start personality
+     * 
+     * @since Series 60 3.2    
+     */
+    void StartPersonality();
+
+     /**
+      * Check if self is A-device (A-end connected).
+      * @return ETrue if self is in A-device state.
+      */
+      TBool IsDeviceA();
+    
+public: // from base class CActive
+
+    /**
+     * From CActive.
+     * Implements state machine for this class.
+     *
+     * @since Series 60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Never called in this implementation.
+     *
+     * @since Series 60 3.0
+     * @param aError The error returned
+     * @return error
+     */
+    TInt RunError( TInt /*aError*/ );
+
+    /**
+     * From CActive
+     * Cancels outstanding request.
+     *
+     * @since Series 60 3.0
+     */
+    void DoCancel();
+
+	/**
+     * Check if there is an observer with ask on connection suppression.
+     * Check if one or more sessions have suppressed the ask on 
+     * connection mode query.
+     *
+     * @since S60 5.0
+     * @return ETrue if suppression found
+     */	
+    TBool IsAskOnConnectionSuppression();
+	
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CUsbWatcher();
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+
+    /**
+     * Get personality plugins.
+     *
+     * @since Series 60 3.2
+     */
+    void GetPersonalityPluginsL();
+        
+    /**
+     * Switch personality according to USB state.
+     * @param aConfirmUnload If true, no personality switch blocking queries are shown.
+     * @since Series 60 3.2
+     */
+    void SwitchPersonality( TBool aNonBlocking = EFalse );
+
+    /**
+     * Starts personality/USB.
+     *
+     * @since Series 60 2.?
+     */
+    void Start();
+
+    /**
+     * Stops personality/USB.
+     *
+     * @since Series 60 2.?
+     */    
+    void Stop();
+        
+    /**
+     * Stops and starts personality.
+     * @param aConfirmUnload If true, no personality switch blocking queries are shown.
+     * @since Series 60 3.0
+     */    
+    void StopStart( TBool aNonBlocking );
+
+	/**
+     * Get personality id. Used in charging mode.
+     *
+     * @since Series 60 3.2
+     * @return error
+     */
+    TInt GetChargingPersonalityId( TInt& aPersonalityId ); 
+	
+private: // Data
+    /** 
+     * states for USB starting and stopping 
+     */
+    enum TUsbState
+        {
+        EUsbIdle,
+        EUsbStarting,
+        EUsbStarted,
+        EUsbStopping,
+        EUsbConfirmStop
+        };
+
+    /**
+     * Personalities supported by this system
+     */
+    RArray<TUsbSupportedPersonalityInf> iSupportedPersonalities;
+
+    /**
+     * Object to follow device state
+     */
+    CUsbActiveState* iActiveState;
+
+    /**
+     * Handle to Usb Manager
+     */
+    RUsb iUsbMan;
+
+    /**
+     * Object to start or stop current personality
+     */
+    CUsbActivePersonalityHandler* iPersonalityHandler;
+
+    /**
+     * Current personality id
+     */
+    TInt iPersonalityId;
+    
+    /**
+     * Previous personality id
+     */
+    TInt iPrevPersonalityId;
+    
+    /**
+     * Earlier previous personality id
+     */
+    TInt iOldPrevPersonalityId;
+    
+    /**
+     * Current ask on connection setting
+     */
+    TInt iAskOnConnectionSetting;
+    
+    /**
+     * State for USB starting/stoping
+     */
+    TUsbState iState;
+
+    /**
+     * Flag to detect when stop+start scenario ongoing
+     */
+    TBool iStopStartScenario;
+
+    /**
+     * Registered by CUsbWatcherSession when connection established
+     */
+	RPointerArray<MUsbWatcherNotify> iObservers;
+    
+    /**
+     * Access to central repository
+     */
+    CRepository* iPersonalityRepository;
+
+    /**
+     * Flag to detect when personality change is ongoing
+     */
+    TBool iPersonalityChangeOngoing;
+
+    /**
+     * Flag to detect when set personality request is ongoing
+     */
+    TBool iSetPersonalityOngoing;
+
+    /**
+     * Flag to detect when set previous personality request is ongoing
+     */
+    TBool iSetPreviousPersonalityOngoing;
+
+    /**
+     * Flag to detect when client has requested personality change on disconnect
+     */
+    TBool iSetPreviousPersonalityOnDisconnect;
+    
+    /**
+     * Flag to detect when personality is changed from the ask on connection
+     */
+    TBool iChangePersonalityOngoing;    
+    
+    /**
+     * Device lock feature
+     */
+    CUsbDeviceLock* iUsbDeviceLock;
+    
+    /**
+     * Usbdevcon process starter
+     * Own.
+     */
+    CUsbDevConStarter* iUsbDevConStarter;
+
+    /**
+     * Global system state listener
+     * Start/stop personality depending on global state changes.
+     * Own.
+     */
+    CUsbGlobalSystemStateObserver* iGlobalStateObserver;
+    
+    /**
+     * Personality loading ongoing
+     */
+    TBool iStarted;
+    
+    /**
+     * OTG Watcher
+     */
+    CUsbOtgWatcher* iOtgWatcher; //OTG
+    
+    /*
+     * USB indicator handler to handle device side indicator
+     */
+    TUsbIndicatorHandler iUsbIndicatorHandler;
+    
+    /*
+     * Starting mode is normal?
+     */
+    TBool iNormalStart;
+    };
+    
+#include "cusbwatcher.inl"
+
+#endif   // CUSBWATCHER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcher.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:  Inline methods for CUsbWatcher class
+*
+*/
+
+
+#include <UsbWatcherInternalCRKeys.h>
+
+// ----------------------------------------------------------------------------
+// Return personality array.
+// ----------------------------------------------------------------------------
+//
+inline const RArray<TUsbSupportedPersonalityInf>& CUsbWatcher::Personalities() 
+        const
+    {
+    return iSupportedPersonalities;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcherscheduler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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:  Active scheduler for server
+*
+*/
+
+
+#ifndef CUSBWATCHERSCHEDULER_H
+#define CUSBWATCHERSCHEDULER_H
+
+#include <e32base.h>
+
+class CUsbWatcherServer;
+
+/**
+ * The CUsbWatcherScheduler class
+ *
+ * Implements an Active Scheduler for the server to use. This is necessary
+ * in order to provide an Error() function which does something useful instead
+ * of panicking.
+ */
+NONSHARABLE_CLASS( CUsbWatcherScheduler ) : public CActiveScheduler
+    {
+public:
+    static CUsbWatcherScheduler* NewL();
+    ~CUsbWatcherScheduler();
+
+    void SetServer(CUsbWatcherServer& aServer);
+
+private:
+    inline CUsbWatcherScheduler() {};
+    // from CActiveScheduler
+    void Error( TInt aError ) const;
+
+public:
+    CUsbWatcherServer* iServer;
+    };
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcherserver.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* 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:  Header file for CUsbWatcherServer class
+*
+*/
+
+
+#ifndef CUSBWATCHERSERVER_H
+#define CUSBWATCHERSERVER_H
+
+//
+// Forward declarations
+//
+class CUsbWatcher;
+
+/**
+ * The CUsbWatcherServer class
+ *
+ * Implements a Symbian OS server that exposes the RUsbWatcher API
+ */
+NONSHARABLE_CLASS( CUsbWatcherServer ) : public CPolicyServer
+    {
+public:
+    static CUsbWatcherServer* NewLC();
+    virtual ~CUsbWatcherServer();
+
+    virtual CSession2* NewSessionL( const TVersion &aVersion,
+            const RMessage2& aMessage ) const;
+    void Error( TInt aError );
+
+    CUsbWatcher& Watcher() const;
+        
+protected:
+    CUsbWatcherServer();
+    void ConstructL();
+        
+private:
+    CUsbWatcher* iUsbWatcher;
+    };
+
+#include "cusbwatcherserver.inl"
+
+#endif
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcherserver.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2002-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:  Inline methods for CUsbWatcherServer class
+*
+*/
+
+
+inline CUsbWatcher& CUsbWatcherServer::Watcher() const
+    {
+    return *iUsbWatcher;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatchersession.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002-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:  Session class for USB Watcher
+*
+*/
+
+
+#ifndef CUSBWATCHERSESSION_H
+#define CUSBWATCHERSESSION_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include "musbwatchernotify.h"
+//
+// Forward declarations
+//
+class CUsbWatcherServer;
+class CUsbWatcher;
+
+NONSHARABLE_CLASS( CUsbWatcherSession ) : public CSession2,
+    public MUsbWatcherNotify
+    {
+public:
+    static CUsbWatcherSession* NewL(CUsbWatcherServer* aServer);
+    virtual ~CUsbWatcherSession();
+
+    // CSession
+    virtual void ServiceL(const RMessage2& aMessage);
+        
+    virtual void Notify(TInt iPersonalityId, TInt aStatus); 
+
+    /**
+     * Check if ask on connection mode query is suppressed in this session.
+     * From MUsbWatcherNotify
+     */
+    virtual TBool IsAskOnConnectionSuppressed();
+    
+protected:
+    CUsbWatcherSession(CUsbWatcherServer* aServer);
+    void ConstructL();
+
+    void DispatchMessageL(const RMessage2& aMessage);
+
+private:
+
+    TInt SetPersonality(const RMessage2& aMessage, TBool& aComplete);
+    TInt CancelSetPersonality(const RMessage2& aMessage, 
+            TBool& aComplete);
+    TInt SetPreviousPersonality(const RMessage2& aMessage,
+            TBool& aComplete);
+    TInt SetPreviousPersonalitySync(const RMessage2& aMessage, 
+            TBool& aComplete);    
+    TInt CancelSetPreviousPersonality(const RMessage2& aMessage, 
+            TBool& aComplete);
+    TInt SetPreviousPersonalityOnDisconnect(const RMessage2& aMessage, 
+            TBool& aComplete);
+
+    /**
+     * Prevent showing ask on connection mode query in this session.
+     * This affects to the next cable connections. The currently shown
+     * mode query is not closed.
+     * aSuppress ETrue prevents showing the mode query.
+     */
+    void SetAskOnConnectionSuppression(TBool aSuppress);
+
+    CUsbWatcherServer* iUsbWatcherServer;
+    RMessage2 iSetPersonalityMessage;
+    RMessage2 iCancelSetPersonalityMessage;
+    RMessage2 iSetPreviousPersonalityMessage;
+    RMessage2 iCancelSetPreviousPersonalityMessage;
+    TBool iSetPersonalityOutstanding;
+    TBool iCancelSetPersonalityOutstanding;
+
+    TBool iSetPreviousPersonalityOutstanding;
+    TBool iCancelSetPreviousPersonalityOutstanding;
+    TBool iSuppressAskOnConnection; // Prevent ask on connection mode query 
+    };
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/debug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,172 @@
+/*
+* 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:  Debug macros
+*
+*/
+
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+//////////////////////////////////////////////////////////////////////////////
+// Here are parameters need to be modified. 
+// Component name 
+#define MODULE_NAME "USBWATCHER"
+//////////////////////////////////////////////////////////////////////////////
+
+
+// For handling unicode strings as L##MACRO is interpreted as LMACRO
+#define WIDEN2( x ) L##x
+#define WIDEN( x ) WIDEN2( x )
+
+_LIT( KUsbPanicModule, ""WIDEN( MODULE_NAME ) );
+
+#ifdef _DEBUG
+
+// Comment this line out if using real-time debugging
+//#define LOG_TO_FILE 
+// ===========================================================================
+#if defined ( LOG_TO_FILE )
+// ===========================================================================
+// Add corresponding libabry in mmp file
+// LIBRARY    flogger.lib    
+// The log file is located at  
+// c:\logs\usb\MODULE_NAME.txt
+
+#include <flogger.h>
+
+#define DESC( x ) TPtrC( ( const TText* ) ( x ) )
+#define DESC8( x ) TPtrC8( ( const TUint8* ) ( x ) )
+_LIT( KUsbLogDir, "USB" );
+_LIT( KUsbLogFile, ""WIDEN(MODULE_NAME)L".txt" );
+
+// s: c string. 
+#define LOG(s) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "[%08x] ["MODULE_NAME"] "##s ), TUint(RThread().Id()) )
+
+// s: c string contains "%x"
+// v: varaible corresponding to %x
+#define LOG1(s, v) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "[%08x] ["MODULE_NAME"] "##s ), v, \
+                TUint(RThread().Id()) )
+// s: c string contains "%x%y"
+// v1: varaible corresponding to %x
+// v2: varaible corresponding to %y
+#define LOG2(s, v1, v2) RFileLogger::WriteFormat( KUsbLogDir, \
+                KUsbLogFile, EFileLoggingModeAppend, \
+                DESC8( "[%08x] ["MODULE_NAME"] "##s ), TUint(RThread().Id()), \
+                v1, v2 )
+
+// s: c string contains "%x%y%z"
+// v1: varaible corresponding to %x
+// v2: varaible corresponding to %y
+// v3: varaible corresponding to %z
+#define LOG3(s, v1, v2, v3) RFileLogger::WriteFormat( KUsbLogDir, \
+            KUsbLogFile, EFileLoggingModeAppend, \
+            DESC8( "[%08x] ["MODULE_NAME"] "##s ), \
+            TUint(RThread().Id()), v1, v2, v3 )
+
+class TFuncLogger
+    {
+public:
+    TFuncLogger(const TDesC8& aFuncName)
+        {
+        iFuncName.Set( aFuncName );
+        RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile, 
+            EFileLoggingModeAppend, 
+            DESC8( "[%08x] ["MODULE_NAME"] >>%s" ), TUint(RThread().Id()),
+            iFuncName.Ptr() );
+        }
+    ~TFuncLogger()
+        {
+        RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile,
+             EFileLoggingModeAppend, 
+             DESC8( "[%08x] ["MODULE_NAME"] <<%s" ), TUint(RThread().Id()),
+             iFuncName.Ptr() );
+        }
+private:
+    TPtrC8 iFuncName;
+    };
+// ===========================================================================
+#else //Real-time logging
+// ===========================================================================
+#include <e32debug.h>
+
+// Paramters same as above.
+#define LOG( str ) { RDebug::Printf( "[%08x] ["MODULE_NAME"] %s",\
+        TUint(RThread().Id()), str  ); }
+
+#define LOG1( s, v ) { RDebug::Printf( "[%08x] ["MODULE_NAME"] "##s ,\
+        TUint(RThread().Id()), v ); }
+
+#define LOG2( s, v1,v2 ) { RDebug::Printf( "[%08x] ["MODULE_NAME"] "##s , \
+        TUint(RThread().Id()), v1, v2 ); }
+
+#define LOG3( s, v1, v2, v3 ) { RDebug::Printf( "[%08x] ["MODULE_NAME"] "##s, \
+        TUint(RThread().Id()), v1, v2, v3); }
+
+class TFuncLogger
+    {
+public:
+    TFuncLogger(const TDesC8& aFuncName)
+        {
+        iFuncName.Set( aFuncName );
+        RDebug::Printf( "[%08x] ["MODULE_NAME"] >>%s", TUint(RThread().Id()), 
+             iFuncName.Ptr());
+        }
+    ~TFuncLogger()
+        {
+        RDebug::Printf( "[%08x] ["MODULE_NAME"] <<%s", TUint(RThread().Id()), 
+             iFuncName.Ptr());
+        }
+private:
+    TPtrC8 iFuncName;
+    };
+#endif // LOG_TO_FILE
+
+#define LEAVE( exp )  {volatile TInt err_ = exp; \
+        LOG3( "LEAVE(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\
+        User::Leave( err_ );}
+
+#define LEAVEIFERROR( exp ) {volatile TInt err__ = exp; \
+		if(err__ < 0) LEAVE(err__);}
+
+#define PANIC( exp ) {volatile TInt err_ = exp; \
+        LOG3( "PANIC(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\
+        User::Panic( KUsbPanicModule, err_ );}
+
+
+#define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__));
+
+#else // _DEBUG   
+// ===========================================================================
+
+#define LOG( s )
+#define LOG1( s, v ) 
+#define LOG2( s, v1, v2 )
+#define LOG3( s, v1, v2, v3 )
+#define LOG_FUNC_ENTRY 
+#define LOG_FUNC_EXIT 
+#define LEAVE( exp ) User::Leave( exp );
+#define LEAVEIFERROR( exp ) User::LeaveIfError( exp );
+#define PANIC( err ) User::Panic( KUsbPanicModule, err );
+#define LOG_FUNC
+// ===========================================================================
+#endif // _DEBUG
+// ===========================================================================
+#endif // DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/musbwatchernotify.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2002-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:  Used by CUsbWatcher class to notify about completed request.
+*
+*/
+
+
+#ifndef MUSBWATCHERNOTIFY_H
+#define MUSBWATCHERNOTIFY_H
+
+class MUsbWatcherNotify
+    {
+public:
+    virtual void Notify( TInt aPersonalityId, TInt aStatus ) = 0;  
+
+    /**
+     * Check if ask on connection mode query is suppressed in this session.
+     */
+    virtual TBool IsAskOnConnectionSuppressed() = 0;
+    };
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/rusbwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:  Common header file for USB Watcher.
+*
+*/
+
+
+#ifndef R_RUSBWATCHER_H
+#define R_RUSBWATCHER_H
+
+#include <e32std.h>
+#include "usbwatchershared.h"
+
+const TUid KUsbWatcherSvrUid = {0x101F9696};
+
+_LIT(KUsbWatcherImg, "z:\\system\\programs\\usbwatcher.exe");
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/tusbindicatorhandler.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* 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:  Header file for class TUsbIndicatorHandler
+*
+*/
+
+
+#ifndef TUSBINDICATORHANDLER_H
+#define TUSBINDICATORHANDLER_H
+
+#include <bldvariant.hrh>
+#include <usbstates.h>
+
+
+/**
+*  USB indicator handler class for device side.
+*
+*  This class shows USB indicator when device state changes to Configured, 
+*  and hides USB indicator when device leaves Configured state. Suspended 
+ * state does not change the indicator.
+*
+*  @since TB9.2
+*/
+NONSHARABLE_CLASS( TUsbIndicatorHandler )
+    {
+
+public:
+    /**
+     * Constructor
+     */
+    TUsbIndicatorHandler();
+    
+	/**
+     * Set USB indicator (On/Off, maybe more in future) according to 
+     * the change of USB device state
+     *
+     * @param aStateOld previous USB device state
+     * @param aStateNew current USB device state
+     */
+    void HandleDeviceStateChange( TUsbDeviceState aStateOld, 
+            TUsbDeviceState aStateNew );
+            
+private:
+	/**
+     * Show USB indicator (On/Off, maybe more in future)
+     *
+     * @since TB9.2
+     * @param aUsbIndicatorState the state of the indicator, 0: OFF, 1: ON
+     */
+    void ShowUsbIndicator( TInt aUsbIndicatorState );
+	
+private:
+    /**
+     * The device state before suspend.
+     * Used to filter out suspend from others;
+     */
+    TUsbDeviceState iDevStateB4Suspend;
+    
+    /////////////////////////////////////////////////////////////////////////
+    // Test code
+    friend class CtTUsbIndicatorHandler;
+    TBool iUsbIndicator; 
+    // 
+    /////////////////////////////////////////////////////////////////////////
+     
+    };
+    
+
+#endif   // TUSBINDICATORHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/usbvariation.rh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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 USBVARIATION_RH
+#define USBVARIATION_RH
+
+#define per_manufacturer "Nokia"
+#define per_product "S60 Device"
+
+#define per_vendorId 0x0421
+
+#define per_productId_PCSuite 0x0500
+#define per_productId_MassStorage 0x0501
+#define per_productId_PTP 0x001c
+#define per_productId_MediaTransfer 0x4A4
+#define per_productId_PCSuiteMTP per_productId_PCSuite
+#define per_productId_ModemInstall      0x0396
+#define per_productId_RNDIS 0x03A3
+
+#define per_bcdDevice 0x0100
+
+
+
+#endif // USBVARIATION_RH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/usbwatcherserversecuritypolicy.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* 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:  Server security policy definitions
+*
+*/
+
+ 
+#ifndef USBWATCHERSERVERSECURITYPOLICY_H
+#define USBWATCHERSERVERSECURITYPOLICY_H
+
+/**
+ * USB Wathcer server security policy definitions
+ */
+const TUint KUsbWatcherServerRangeCount = 2;
+
+const TInt KUsbWatcherServerRanges[ KUsbWatcherServerRangeCount ] = 
+	{
+	EUsbWatcherSetPersonality,        // NetworkControl 
+	EUsbWatcherSetPreviousPersonalityOnDisconnect + 1  
+	};
+
+/** 
+ * Index numbers into KUsbWatcherServerElements[] 
+ */
+const TInt KPolicyLocalServices = 0;
+const TInt KPolicyPass = 1;
+
+/**
+ * Mapping IPCs to poicy element 
+ */
+const TUint8 KUsbWatcherServerElementsIndex[ KUsbWatcherServerRangeCount ] = 
+    {
+    KPolicyLocalServices,
+    CPolicyServer::ENotSupported, 
+    };
+
+/** 
+ * Individual policy elements 
+ */
+const CPolicyServer::TPolicyElement KUsbWatcherServerElements[] = 
+    {
+    // the EFailClient means that the if the check fails the CheckFailed method
+    //with return KErrPermissionDenied 
+    { _INIT_SECURITY_POLICY_C1( ECapabilityLocalServices ), 
+            CPolicyServer::EFailClient },
+    { _INIT_SECURITY_POLICY_PASS },
+	};
+
+/** 
+ * Main policy definition
+ */
+const CPolicyServer::TPolicy KUsbWatcherServerPolicy = 
+    {
+    CPolicyServer::EAlwaysPass, //Specifies all connect attempts should pass 
+    KUsbWatcherServerRangeCount,
+    KUsbWatcherServerRanges,
+    KUsbWatcherServerElementsIndex,
+    KUsbWatcherServerElements,
+    };
+
+#endif //USBWATCHERSERVERSECURITYPOLICY_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/usbwatchershared.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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:  Shared definitions between client and server
+*
+*/
+
+
+#ifndef USBWATCHERSHARED_H
+#define USBWATCHERSHARED_H
+
+#include <e32std.h>
+
+const TInt KUsbWatcherSrvMajorVersionNumber = 1;
+const TInt KUsbWatcherSrvMinorVersionNumber = 0;
+const TInt KUsbWatcherSrvBuildVersionNumber = 0;
+
+_LIT(KUsbWatcherServerName, "!usbwatcher");
+
+const TInt KUsbWatcherMaxSupportedPersonalities = 64;
+
+enum TUsbWatcherMessages
+    {
+    EUsbWatcherSetPersonality,
+    EUsbWatcherCancelSetPersonality,
+    EUsbWatcherSetPreviousPersonality,
+    EUsbWatcherSetPreviousPersonalitySync,
+    EUsbWatcherCancelSetPreviousPersonality,
+    EUsbWatcherSetPreviousPersonalityOnDisconnect
+    };
+
+_LIT(KUsbWatcherCliPncCat, "UsbWatcher-Client");
+
+enum TUsbWatcherPanicClient
+    {
+    EUsbWatcherCreateFailure,
+    EUsbWatcherPanicIllegalIPC,
+    EUsbWatcherPanicRemovedExport
+    };
+
+#endif //USBWATCHERSHARED_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/loc/usbman.loc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* 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:  Localization strings for project usbwatcher
+*
+*/
+
+
+//d: List item text of USBUI Setting view
+//d: for "Ovi suite". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_ovisuite "Ovi Suite"
+
+//d: List item text of USBUI Setting view
+//d: for "Mass storage". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_mass_storage "Mass storage"
+
+//d: List item text of USBUI Setting view
+//d: for "Image print". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_ptp "Image print"
+
+//d: List item text of USBUI Setting view
+//d: for "Media transfer". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_mtp "Media transfer"
+
+//d: List item text of USBUI Setting view
+//d: for "Ovi Suite". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_ovisuite_mtp "Ovi Suite"
+
+//d: List item text of USBUI Setting view
+//d: for "Connect to internet". 
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_quickconnect "Connect PC to Web"
+
+//d: List item text of USBUI Setting view, not to be localized
+//d: for "RNDIS"
+//d: This text is also used in USB connected popup
+//l: list_double_large_graphic_pane_t1_cp2
+//w:
+//r: 5.2
+//
+#define qtn_usb_mode_rndis "Connect PC with RNDIS"
+
+//d: text describing the mass storage mode, shown in preview pop up in USB UI Setting 
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_mass_storage "Access your phone’s memory card from the device you are connected to."
+
+//d: text describing the ovi suite mode, shown in preview pop up in USB UI setting
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_ovi_suite "Manage your phone with Ovi Suite and sync your media content."
+
+//d: text describing the media transfer mode, shown in preview pop up in USB UI setting
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_mtp "Sync your media content with Windows Media Player or Nokia Ovi Player, or connect to compatible stereos."
+
+//d: text describing the picture transfer mode, shown in preview pop up in USB UI setting
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_ptp "Print pictures with a compatible printer."
+
+//d: text describing the Phone as modem mode, shown in preview pop up in USB UI setting
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_pam "Use your mobile phone as a modem"
+
+//d: text describing the Phone as RNDIS mode, shown in preview pop up in USB UI setting, not to be localized
+//l: popup_preview_text_window/opt6
+//r: 5.2
+#define qtn_usb_mode_msg_rndis "Use your mobile phone as RNDIS"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/mtp_symbian_temp.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,200 @@
+/*
+* 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: Temporary include MTP components released by ex-Symbian
+*
+*/
+
+
+#ifndef MTPSYMBIANTEMP_IBY__
+#define MTPSYMBIANTEMP_IBY__
+
+// mtp_framework.iby
+#ifndef MTP_FRAMEWORK_IBY
+#define MTP_FRAMEWORK_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Framework cenrep file (temporary until this can be described in ConfML)
+//data=ZPRIVATE\10202be9\10282fcc.cre					private\10202be9\10282fcc.cre
+// MTP Data Types Library
+file=ABI_DIR\BUILD_DIR\mtpdatatypes.dll    system\libs\mtpdatatypes.dll
+// MTP Framework Library
+file=ABI_DIR\BUILD_DIR\mtpframework.dll    			system\libs\mtpframework.dll
+// MTP SERVER
+file=ABI_DIR\BUILD_DIR\mtpserver.exe    system\libs\mtpserver.exe
+// MTP Client
+file=ABI_DIR\BUILD_DIR\mtpclient.dll    system\libs\mtpclient.dll
+// MTP Generic Transport API
+file=ABI_DIR\DEBUG_DIR\mtptransportapi.dll  system\libs\mtptransportapi.dll
+// MTP Data Provider API
+file=ABI_DIR\BUILD_DIR\mtpdataproviderapi.dll    system\libs\mtpdataproviderapi.dll
+// MTP Device Data Provider Extension API
+file=ABI_DIR\BUILD_DIR\mtpdevdpextnapi.dll    system\libs\mtpdevdpextnapi.dll
+// MTP Data Provider Utility
+file=ABI_DIR\BUILD_DIR\mtpdataproviderutility.dll    system\libs\mtpdataproviderutility.dll
+// MTP Proxy Data Provider
+ECOM_PLUGIN(mtpproxydp.dll, mtpproxydp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827B1.rsc  resource\mtp\102827B1.rsc 
+// MTP dummydp resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\dummydp.rsc  resource\mtp\dummydp.rsc 
+// MTP Service Config resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\services.rsc  resource\mtp\services.rsc 
+// MTP Backup registration file
+data=EPOCROOT##epoc32\data\Z\private\102827a2\backup_registration.xml  private\102827a2\backup_registration.xml
+//MTP device icon property file 
+data=EPOCROOT##epoc32\data\Z\private\102827a2\mtpdevice.ico  private\102827a2\mtpdevice.ico
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_FRAMEWORK_IBY
+
+// mtp_filedp.iby
+#ifndef MTP_FILEDP_IBY
+#define MTP_FILEDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpfiledp.dll, mtpfiledp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827B0.rsc  resource\mtp\102827B0.rsc 
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_FILEDP_IBY
+
+// mtp_usbsic.iby
+#ifndef MTP_USBSIC_IBY
+#define MTP_USBSIC_IBY
+#if !defined (SYMBIAN_EXCLUDE_MTP) && !defined(SYMBIAN_EXCLUDE_USB)
+//MTP USB Data Types Library
+file=ABI_DIR\BUILD_DIR\mtpusbdatatypes.dll				system\libs\mtpusbdatatypes.dll
+//MTP USB Still Image Class Controller
+ECOM_PLUGIN(mtpusbsiccc.dll, mtpusbsiccc.rsc)
+//MTP USB SIC transport plugin
+ECOM_PLUGIN(mtpusbsicimp.dll, mtpusbsicimp.rsc)
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_USBSIC_IBY
+
+// mtppictbridgedp.iby
+#ifndef MTPPICTBRIDGEDP_IBY
+#define MTPPICTBRIDGEDP_IBY
+#ifdef __USB_PICTBRIDGE 
+// MTP data provider
+ECOM_PLUGIN(mtppictbridgedp.dll, mtppictbridgedp.rsc)
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001FE3C.rsc  resource\mtp\2001FE3C.rsc   
+#endif
+#endif //MTPPICTBRIDGEDP_IBY
+
+// rptp.iby
+#ifndef RPTP_IBY
+#define RPTP_IBY
+file=ABI_DIR\BUILD_DIR\rptp.dll        system\libs\rptp.dll
+#endif //RPTP_IBY
+
+// mtp_imagedp.iby
+#ifndef MTPIMAGEDP_IBY
+#define MTPIMAGEDP_IBY
+ECOM_PLUGIN(mtpimagedp.dll,mtpimagedp.rsc)
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001FCAE.rsc  resource\mtp\2001FCAE.rsc 
+#endif MTPIMAGEDP_IBY
+
+// mtp_statusservice.iby
+#ifndef MTP_STATUSSERVICE_IBY
+#define MTP_STATUSSERVICE_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpstatusservice.dll, mtpstatusservice.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001a97f.rsc  resource\mtp\2001a97f.rsc 
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_STATUSSERVICE_IBY
+
+// mtp_metadataservice.iby
+#ifndef MTP_METADATAERVICE_IBY
+#define MTP_METADATASERVICE_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpmetadataservice.dll, mtpmetadataservice.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001A9A3.rsc  resource\mtp\2001A9A3.rsc
+data=EPOCROOT##epoc32\data\Z\deviceexperiences\default\en-us\A42998DC-D9BD-4287-A2EA-46116889443C.devicemetadata-ms deviceexperiences\default\en-us\A42998DC-D9BD-4287-A2EA-46116889443C.devicemetadata-ms
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_METADATASERVICE_IBY
+
+// mtp_wmpextndp.iby
+#ifndef MTP_WMPEXTNDP_IBY
+#define MTP_WMPEXTNDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpwmpextndp.dll, mtpwmpextndp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\1028716c.rsc  resource\mtp\1028716c.rsc 
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_WMPEXTNDP_IBY
+
+// devicedp
+#ifndef MTP_DEVICEDP_IBY
+#define MTP_DEVICEDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Device Data Provider
+ECOM_PLUGIN(mtpdevicedp.dll, mtpdevicedp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827AF.rsc  resource\mtp\102827AF.rsc 
+#endif //SYMBIAN_EXCLUDE_MTP
+#endif  //MTP_DEVICEDP_IBY
+
+// pimproxy
+#ifndef MTP_PIMPROXY_IBY
+#define MTP_PIMPROXY_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP PIM proxy
+file=ABI_DIR\BUILD_DIR\mtppimproxy.dll    system\libs\mtppimproxy.dll
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_PIMPROXY_IBY
+
+// calendardp
+#ifndef MTP_CALENDARDP_IBY
+#define MTP_CALENDARDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpcalendardp.dll, mtpcalendardp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102871B8.rsc  resource\mtp\102871B8.rsc 
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_CALENDARDP_IBY
+
+// taskdp
+#ifndef MTP_TASKDP_IBY
+#define MTP_TASKDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtptaskdp.dll, mtptaskdp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\10287013.rsc  resource\mtp\10287013.rsc 
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_TASKDP_IBY
+
+// bluetooth
+#ifndef MTP_BT_IBY
+#define MTP_BT_IBY
+#if !defined (SYMBIAN_EXCLUDE_MTP) && !defined(SYMBIAN_EXCLUDE_USB)
+//MTP over Bluetooth Data Types Library
+file=ABI_DIR\BUILD_DIR\mtpbtdatatypes.dll               system\libs\mtpbtdatatypes.dll
+//MTP over Bluetooth transport plugin
+ECOM_PLUGIN(mtpbt.dll, mtpbt.rsc)
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif// MTP_BT_IBY
+
+#ifndef MTP_CONTROLLER_IBY
+#define MTP_CONTROLLER_IBY
+#if !defined (SYMBIAN_EXCLUDE_MTP)
+//MTP Controller LOCOD service plugin
+ECOM_PLUGIN(mtpcontroller.dll, mtpcontroller.rsc)
+#endif// SYMBIAN_EXCLUDE_MTP
+#endif// MTP_CONTROLLER_IBY
+#endif // MTPSYMBIANTEMP_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/usbmanrsc.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,24 @@
+/*
+* 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:  USB Manager resource IBY dummy
+*
+*/
+
+
+#ifndef __USBMANRSC_IBY__
+#define __USBMANRSC_IBY__
+
+//This file replaces the Symbian usbmanrsc.iby.
+
+#endif // __USBMANRSC_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/usbwatcher.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* 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:  Image description file for project UsbWatcher
+*
+*/
+
+
+#ifndef USBWATCHER_IBY__
+#define USBWATCHER_IBY__
+
+#ifdef __USB
+file=ABI_DIR\BUILD_DIR\usbwatcher.exe		PROGRAMS_DIR\usbwatcher.exe
+file=ABI_DIR\BUILD_DIR\usbwatcher.dll		PROGRAMS_DIR\usbwatcher.dll
+file=ABI_DIR\BUILD_DIR\usbpersonality.dll		PROGRAMS_DIR\usbpersonality.dll
+data=DATAZ_\private\101F9696\backup_registration.xml	private\101F9696\backup_registration.xml
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/usbwatcher_resources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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: personality resources for UsbMan.
+*
+*/
+#ifndef __USBWATCHERRESOURCES_IBY__
+#define __USBWATCHERRESOURCES_IBY__
+
+#ifdef __USB
+
+#ifdef __MEDIA_TRANSFER_PROTOCOL
+
+#ifdef FF_USB_MODEM
+data=DATAZ_\private\101fe1db\usbman_pcsmtppam.rsc    \private\101fe1db\usbman.rsc
+#else // !FF_USB_MODEM
+data=DATAZ_\private\101fe1db\usbman_pcsmtp.rsc    \private\101fe1db\usbman.rsc
+#endif // FF_USB_MODEM
+
+#else // !__MEDIA_TRANSFER_PROTOCOL
+
+#ifdef FF_USB_MODEM
+data=DATAZ_\private\101fe1db\usbman_pcspam.rsc    \private\101fe1db\usbman.rsc
+#else // !FF_USB_MODEM
+data=DATAZ_\private\101fe1db\usbman_pcs.rsc    \private\101fe1db\usbman.rsc
+#endif // FF_USB_MODEM
+
+#endif // __MEDIA_TRANSFER_PROTOCOL
+
+#endif // __USB
+
+#endif // __USBWATCHERRESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,610 @@
+/*
+* Copyright (c) 2002-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:  This implements UsbActivePersonalityHandler class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <etelmm.h>             // for fetching the IMEI code
+#include <mmtsy_names.h>        // for RTelServer names
+#include <UsbWatcherInternalCRKeys.h>
+#include <cusbpersonalitynotifier.h>
+#include <cusbpersonalityplugin.h>
+#include <tusbpersonalityparams.h>
+#include <startupdomainpskeys.h> //for global system state
+#include "cusbactivepersonalityhandler.h"
+#include "cusbglobalsystemstateobserver.h"
+#include <usbuinotif.h>
+
+// CONSTANTS
+const TInt KSerialNumberLength = 12;
+
+const TUid KUsbmanSvrUid = {0x101fe1db};
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbActivePersonalityHandler::CUsbActivePersonalityHandler(
+    RUsb& aUsbMan, CUsbWatcher& aOwner )
+    : CActive( EPriorityStandard )
+    , iUsbMan( aUsbMan )
+    , iOwner( aOwner )
+    , isFailureCleanup( EFalse )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::ConstructL()
+    {
+    LOG_FUNC
+
+    iPersonalityNotifier = CUsbPersonalityNotifier::NewL();
+    iPersonalityParams = new ( ELeave ) TUsbPersonalityParams( iUsbMan,
+            *iPersonalityNotifier );
+
+    ConstructUsbSerialNumberL();
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbActivePersonalityHandler* CUsbActivePersonalityHandler::NewL(
+        RUsb& aUsbMan, CUsbWatcher& aOwner )
+    {
+    LOG_FUNC
+
+    CUsbActivePersonalityHandler* self = new ( ELeave )
+            CUsbActivePersonalityHandler( aUsbMan, aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+
+// Destructor
+CUsbActivePersonalityHandler::~CUsbActivePersonalityHandler()
+    {
+    LOG_FUNC
+
+    Cancel(); // cancel any outstanding requests
+
+    delete iCurrentPersonalityHandler;
+    delete iPersonalityNotifier;
+    delete iPersonalityParams;
+    }
+
+// ----------------------------------------------------------------------------
+// Construct USB serial number. Some of the personalities may need this.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::ConstructUsbSerialNumberL()
+    {
+    LOG_FUNC
+
+    RTelServer telServer;
+    RMobilePhone phone;
+
+    LEAVEIFERROR( telServer.Connect() );
+    CleanupClosePushL( telServer );
+
+    LEAVEIFERROR( telServer.LoadPhoneModule( KMmTsyModuleName ) );
+
+    LEAVEIFERROR( phone.Open( telServer, KMmTsyPhoneName ) );
+    CleanupClosePushL( phone );
+
+    // to store the serial number to be published as the USB device's serial
+    // number, fetch it from telephony server.
+    TRequestStatus status;
+    phone.GetPhoneId( status, iPhoneInfo );
+    User::WaitForRequest( status );
+
+    // make sure that the serial number fulfills USB requirements and then
+    // convert the serial number so that it can be printed to log
+    TLex lex( iPhoneInfo.iSerialNumber );
+    TInt length = iPhoneInfo.iSerialNumber.Length();
+
+    if( length < KSerialNumberLength )
+        {
+        // In GSM, the complete IMEI can be used as USB serial
+        // number. But in CDMA, the ESN is too short for a valid Mass
+        // Storage serial number (Mass-Storage and Bulk Only Transport
+        // specs both require minimum 12 byte number), so it is
+        // extended with trailing zeroes. When doing this, make sure
+        // not to write anything over descriptor's max length
+        if( iPhoneInfo.iSerialNumber.MaxLength() < KSerialNumberLength )
+            {
+            iPhoneInfo.iSerialNumber.SetLength( KSerialNumberLength );
+            }
+        while( length < KSerialNumberLength )
+            {
+            iPhoneInfo.iSerialNumber.Append( '0' );
+            ++length;
+            }
+        }
+
+    CleanupStack::PopAndDestroy( 2, &telServer );
+    }
+
+// ----------------------------------------------------------------------------
+// Confirm that personality can be loaded.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::ConfirmPersonalityUnload( TRequestStatus&
+        aStatus )
+    {
+    LOG_FUNC
+
+    aStatus = KRequestPending;
+    iRequestStatus = &aStatus;
+
+    if( iState != EUsbPersonalityStarted )
+        {
+        TRequestStatus* status = &iStatus;
+        SetActive();
+        User::RequestComplete( status, KErrGeneral );
+        return;
+        }
+
+    // Cancel all notes before confirmation
+    iPersonalityParams->PersonalityNotifier().CancelAll();
+
+    if( iCurrentPersonalityHandler )
+        {
+        iCurrentPersonalityHandler->ConfirmPersonalityUnload( iStatus );
+        SetActive();
+        }
+    else
+        {
+        TRequestStatus* status = &iStatus;
+        SetActive();
+        User::RequestComplete( status, KErrNone );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Start personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::StartPersonality( TInt& aPersonalityId,
+        TInt aAskOnConnectionSetting, TRequestStatus& aStatus )
+    {
+    LOG_FUNC
+
+    LOG2( "PersonalityId = %d, AskOnConnectionSetting = %d", aPersonalityId,
+            aAskOnConnectionSetting );
+
+    // Remove all notes.
+    iPersonalityNotifier->CancelAll();
+     
+
+    iPersonalityId = &aPersonalityId;
+    iAskOnConnectionSetting = aAskOnConnectionSetting;
+    aStatus = KRequestPending;
+    iRequestStatus = &aStatus;
+
+    // prepare current personality for start and return
+    if( iCurrentPersonalityHandler )
+        {
+        LOG( "Previous PersonalityHandler not deleted" );
+        User::RequestComplete( iRequestStatus, KErrGeneral );
+        return;
+        }
+
+    TRAPD( ret, ( iCurrentPersonalityHandler = NewPersonalityHandlerL(
+            *iPersonalityId ) ) );
+
+    if( ( ret == KErrNone) && iCurrentPersonalityHandler )
+        {
+        LOG( "PersonalityHandler created" );
+        iCurrentPersonalityHandler->PreparePersonalityStart( iStatus );
+        iState = EUsbPersonalityPrepareStart;
+        isFailureCleanup = EFalse;
+        SetActive();
+        }
+    else
+        {
+        LOG( "Error: PersonalityHandler create failed" );
+        User::RequestComplete( iRequestStatus, KErrGeneral );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Stop current personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::StopPersonality( TRequestStatus& aStatus )
+    {
+    LOG_FUNC
+
+    aStatus = KRequestPending;
+    iRequestStatus = &aStatus;
+
+    iState = EUsbPersonalityPrepareStop;
+    isFailureCleanup = EFalse;
+    
+    // prepare current personality for stop and return
+    if( iCurrentPersonalityHandler )
+        {
+        LOG( "Call PersonalityPlugin to prepare stop" );
+        iCurrentPersonalityHandler->PreparePersonalityStop( iStatus );
+        SetActive();
+        }
+    else
+        {
+        LOG( "No current PersonalityPlugin, return immediately" );
+        TRequestStatus* status = &iStatus;
+        SetActive();
+        User::RequestComplete( status, KErrNone );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Indicates USB device state change to personality when USB is started.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::StateChangeNotify(
+        TUsbDeviceState aStateOld, TUsbDeviceState aStateNew )
+    {
+    LOG_FUNC
+
+    iDeviceState = aStateNew;        
+    switch ( aStateNew )
+        {
+        case EUsbDeviceStateAddress:
+            {
+            if( iAskOnConnectionSetting &&
+                    ( aStateOld != EUsbDeviceStateSuspended ) &&
+                    ( aStateOld != EUsbDeviceStateConfigured ) 
+                     )
+                {
+                iPersonalityParams->PersonalityNotifier().ShowQuery(
+                        KCableConnectedNotifierUid, iDummy,
+                        iPersonalityPckgBuf);
+                }
+            break;
+            }
+		case EUsbDeviceStateUndefined:
+            {
+            iPersonalityNotifier->CancelQuery(KQueriesNotifier);
+            break;
+			}
+       default:
+            // We do not handle other state here
+			LOG( "DeviceStatechange ignored by ActivePersonalityhandler or EUsbDeviceStateConfigured" );
+            break;
+        }
+
+    if( iCurrentPersonalityHandler )
+        {
+        LOG( "Notifying PersonalityPlugin of the new state" );
+        iCurrentPersonalityHandler->StateChangeNotify( aStateNew );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object error function. Handle error and complete
+// outstanding request. We must not come here.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActivePersonalityHandler::RunError( TInt aError )
+    {
+    LOG_FUNC
+    
+    LOG2("Returned error: %d, iState: %d", aError, iState);
+
+    switch ( aError )
+        {
+        case KErrNoMemory:
+            iQueryParams().iQuery = EUSBNotEnoughRam;
+            iPersonalityParams->PersonalityNotifier().ShowQuery(KQueriesNotifier, 
+    	                iQueryParams, iDummyBuf);
+            break;
+        case KErrDiskFull:
+            iQueryParams().iQuery = EUSBDiskFull;
+            iPersonalityParams->PersonalityNotifier().ShowQuery(KQueriesNotifier, 
+    	                iQueryParams, iDummyBuf);
+            break;
+        default:
+        	LOG( "Ignored" );
+        }
+
+    //only handle error when TryStart fails now
+	//clean up work to be done in the personality
+    if (iState == EUsbPersonalityStartUsb)
+        {
+        iState = EUsbPersonalityPrepareStop;
+		isFailureCleanup = ETrue;
+		
+	    // prepare current personality for stop and return
+	    if( iCurrentPersonalityHandler )
+	        {
+	        LOG( "Call PersonalityPlugin to prepare stop" );
+	        iCurrentPersonalityHandler->PreparePersonalityStop( iStatus );
+	        SetActive();
+	        }
+	    else
+	    	{    
+            LOG( "No current PersonalityPlugin" );
+            }
+
+        //complete StartPersonality with aError
+        User::RequestComplete( iRequestStatus, aError );
+        }
+    else
+        {
+	    LOG( "Ignore error in other states" );
+        }
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Executed when iStatus is completed.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::RunL()
+    {
+    LOG_FUNC
+
+    TInt ret = iStatus.Int();
+    
+    LOG2( "CUsbActivePersonalityHandler::RunL iStatus = %d, iState = %d", ret, iState );
+
+    switch( iState )
+        {
+        case EUsbPersonalityIdle:
+            break;
+
+        case EUsbPersonalityPrepareStart:
+            {
+            LOG( "EUsbPersonalityPrepareStart" );
+            // then write the serial number to P&S for USB Manager
+            PublishSerialNumber();
+            iUsbMan.TryStart( *iPersonalityId, iStatus );
+            iState = EUsbPersonalityStartUsb;
+            SetActive();
+            }
+            break;
+
+        case EUsbPersonalityStartUsb:
+            LEAVEIFERROR( ret );
+            LOG( "EUsbPersonalityStartUsb" );
+            iState = EUsbPersonalityFinishStart;
+            if( iCurrentPersonalityHandler )
+                {
+                iCurrentPersonalityHandler->FinishPersonalityStart( iStatus );
+                SetActive();
+                }
+            else
+                {
+                TRequestStatus* status = &iStatus;
+                SetActive();
+                User::RequestComplete( status, KErrNone );
+                }
+            break;
+
+        case EUsbPersonalityFinishStart:
+            LOG( "EUsbPersonalityFinishStart" );
+            User::RequestComplete( iRequestStatus, ret );
+            iState = EUsbPersonalityStarted;
+            break;
+
+        case EUsbPersonalityPrepareStop:
+            LOG( "EUsbPersonalityPrepareStop" );
+            iUsbMan.TryStop( iStatus );
+            iState = EUsbPersonalityStopUsb;
+            SetActive();
+            break;
+
+        case EUsbPersonalityStopUsb:
+            LOG( "EUsbPersonalityStopUsb" );
+            iState = EUsbPersonalityFinishStop;
+            if( iCurrentPersonalityHandler )
+                {
+                iCurrentPersonalityHandler->FinishPersonalityStop( iStatus );
+                SetActive();
+                }
+            else
+                {
+                TRequestStatus* status = &iStatus;
+                SetActive();
+                User::RequestComplete( status, KErrNone );
+                }
+            break;
+
+        case EUsbPersonalityFinishStop:
+            LOG( "EUsbPersonalityFinishStop" );
+
+            delete iCurrentPersonalityHandler;
+            iCurrentPersonalityHandler = NULL;
+
+            //iAskOnConnectionSetting may be have been set to off
+            if ( iDeviceState == EUsbDeviceStateUndefined )
+                {
+	            iPersonalityParams->PersonalityNotifier().CancelQuery(
+	                    KCableConnectedNotifierUid );
+                }
+            //the request should be completed with error code in RunError if failed
+            if ( !isFailureCleanup )
+                {
+                User::RequestComplete( iRequestStatus, ret );
+                }
+            
+            iState = EUsbPersonalityIdle;
+            break;
+
+        case EUsbPersonalityStarted:
+            // This must unload event. Let's complete.
+            User::RequestComplete( iRequestStatus, ret );
+            break;
+
+        default:
+            LOG( "ERROR: unexpected state" );
+            PANIC( KErrGeneral );
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::DoCancel()
+    {
+    LOG_FUNC
+
+    LOG1( "CUsbActivePersonalityHandler::iState = %d", iState );
+    switch( iState )
+        {
+        case EUsbPersonalityFinishStart:
+            {
+            TRequestStatus status;
+
+            iUsbMan.TryStop( status );
+            SetActive();
+            User::WaitForRequest( status );
+            }
+            // Don't break. We need to cancel outstanding request.
+
+        case EUsbPersonalityStarted:
+        case EUsbPersonalityPrepareStop:
+        case EUsbPersonalityFinishStop:
+            if( iCurrentPersonalityHandler )
+                {
+                iCurrentPersonalityHandler->Cancel();
+                }
+            break;
+
+        case EUsbPersonalityStopUsb:
+            iUsbMan.CancelInterest( RUsb::ETryStop );
+            break;
+
+        case EUsbPersonalityStartUsb:
+            iUsbMan.StartCancel();
+            break;
+
+        default:
+            break;
+        }
+
+    if( iCurrentPersonalityHandler && ( iState != EUsbPersonalityStarted ) )
+        {
+        delete iCurrentPersonalityHandler;
+        iCurrentPersonalityHandler = NULL;
+        }
+
+    // if started then this must unload confirmation
+    if( iState != EUsbPersonalityStarted )
+        {
+        iState = EUsbPersonalityIdle;
+        }
+
+    // When cancel happens it means that we can cancel all queries & notes
+    iPersonalityParams->PersonalityNotifier().CancelAll();
+
+    User::RequestComplete( iRequestStatus, KErrCancel );
+    }
+
+// ----------------------------------------------------------------------------
+// Creates and returns a class handler object for the given personality.
+// ----------------------------------------------------------------------------
+//
+CUsbPersonality* CUsbActivePersonalityHandler::NewPersonalityHandlerL(
+        TInt aPersonality )
+    {
+    LOG_FUNC
+
+    TInt personalityCount = iOwner.Personalities().Count();
+
+    for (TInt i = 0; i < personalityCount; i++)
+        {
+        const TUsbSupportedPersonalityInf& pinf = iOwner.Personalities()[i];
+        if( pinf.iPersonalityId == aPersonality )
+            {
+            iPersonalityParams->SetPersonalityId( aPersonality );
+            CUsbPersonalityPlugin* plugin = CUsbPersonalityPlugin::NewL(
+                    *iPersonalityParams, pinf.iPersonalityUid );
+            iUseSerialNumber = pinf.iUseSerialNumber;
+            return plugin;
+            }
+        }
+
+    return NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// Publish serial number for USB Manager, if needed.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbActivePersonalityHandler::PublishSerialNumber()
+    {
+    LOG_FUNC
+
+    TInt err = KErrNone;
+
+    if( !iUseSerialNumber && iSerialNumberWritten )
+        {
+        // We are either in test mode or going to start up PC Suite
+        // personality -> delete USB Manager's serial number P&S key
+        // (if necessary)
+        LOG( "Deleting published USB serial number" );
+        err = RProperty::Delete( KUidSystemCategory, KUsbmanSvrUid.iUid );
+        iSerialNumberWritten = EFalse;
+        }
+    else if( iUseSerialNumber && !iSerialNumberWritten )
+        {
+        // to finish, define and write the serial number P&S so that USB
+        // Manager can fetch it
+        _LIT_SECURITY_POLICY_PASS( KAPReadPolicy );
+        _LIT_SECURITY_POLICY_PASS( KAPWritePolicy );
+
+        err = RProperty::Define( KUidSystemCategory, KUsbmanSvrUid.iUid,
+                RProperty::EText, KAPReadPolicy, KAPWritePolicy,
+                KUsbStringDescStringMaxSize );
+
+        if( !err )
+            {
+            err = RProperty::Set( KUidSystemCategory, KUsbmanSvrUid.iUid,
+                    iPhoneInfo.iSerialNumber );
+            iSerialNumberWritten = ( err == KErrNone );
+            }
+        }
+
+    LOG1(" ret = %d", err );
+
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel cable connected notifier
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::CancelCableConnectedNotifier()
+    {
+    LOG_FUNC
+
+    iPersonalityParams->PersonalityNotifier().CancelQuery(
+            KCableConnectedNotifierUid );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbactivestate.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2002-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 implements CUsbActiveState class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <usbman.h>
+#include "debug.h"
+#include "cusbactivestate.h"
+#include "cusbwatcher.h"
+
+// CONSTANTS
+const TUint KUsbAllStates = 0xFFFFFFFF;
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveState::CUsbActiveState( RUsb& aUsbMan, CUsbWatcher& aOwner )
+    : CActive( EPriorityStandard )
+    , iUsbMan( aUsbMan )
+    , iOwner( aOwner )
+    , iPreviousState( EUsbDeviceStateUndefined )
+    {
+    LOG_FUNC
+
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveState::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR( iUsbMan.GetDeviceState( iCurrentState ) );
+    LOG1( "Intial UsbDeviceState = %d" , iCurrentState );
+        
+    // start USB if cable is pluged-in at bootup
+    if( EUsbDeviceStateUndefined != iCurrentState )
+        {
+        iOwner.StateChangeNotify( iPreviousState, iCurrentState );
+        iPreviousState = iCurrentState;
+        }
+    iUsbMan.DeviceStateNotification( KUsbAllStates, iCurrentState, iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbActiveState* CUsbActiveState::NewL( RUsb& aUsbMan, CUsbWatcher& aOwner )
+    {
+    LOG_FUNC
+
+    CUsbActiveState* self = new ( ELeave ) CUsbActiveState( aUsbMan, aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+
+// Destructor
+CUsbActiveState::~CUsbActiveState()
+    {
+    LOG_FUNC
+
+    Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// This function is called when device state is changed.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveState::RunL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR( iStatus.Int() ); // Close process if error happens here
+
+    TUsbDeviceState newState = iCurrentState;
+    iUsbMan.DeviceStateNotification( KUsbAllStates, iCurrentState,
+            iStatus );
+    SetActive();
+    
+    // Notify only if there is a change
+    if ( newState != iPreviousState )
+        {
+        LOG2( "USB device state changed: %d ==> %d", iPreviousState,
+            newState );
+        iOwner.StateChangeNotify( iPreviousState, newState );
+        iPreviousState = newState;
+        }
+     else
+        {
+        LOG2("USB device change ignored: %d -> %d", iPreviousState,
+            newState ); 
+        }
+    }
+ 
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+//
+void CUsbActiveState::DoCancel()
+    {
+    LOG_FUNC
+
+    iUsbMan.DeviceStateNotificationCancel();
+    }
+
+// ----------------------------------------------------------------------------
+// Get current device state.
+// ----------------------------------------------------------------------------
+//
+TUsbDeviceState CUsbActiveState::CurrentState()
+    {
+    LOG_FUNC
+
+    return iCurrentState;
+    }
+
+// ----------------------------------------------------------------------------
+// Get previous device state.
+// ----------------------------------------------------------------------------
+//
+TUsbDeviceState CUsbActiveState::PreviousState()
+    {
+    LOG_FUNC
+
+    return iPreviousState;
+    }
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbdevconstarter.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* 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:  Implement class CUsbDevConStarter
+*
+*/
+
+
+#include "cusbdevconstarter.h"
+#include "debug.h"
+
+_LIT16( KUsbDevConPath, "z:\\sys\\bin\\usbdevcon.exe" );
+_LIT16( KUsbDevConParams, "" );
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ----------------------------------------------------------------------------
+// NewL
+// ----------------------------------------------------------------------------
+//
+CUsbDevConStarter* CUsbDevConStarter::NewL()
+    {
+    LOG_FUNC
+
+    CUsbDevConStarter* self = new ( ELeave ) CUsbDevConStarter();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbDevConStarter::~CUsbDevConStarter()
+    {
+    LOG_FUNC
+
+    Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// Start usbdevcon process unless it is already running.
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::Start()
+    {
+    LOG_FUNC
+
+    iStarted = ETrue;
+    if ( EIdle == iState )
+        {
+        TInt err = iProcess.Create( KUsbDevConPath, KUsbDevConParams );
+        if ( KErrNone == err )
+            {
+            //start process and wait until it is constructed
+            iProcess.Resume();
+            iState = EWaitingRendezvous;
+            iProcess.Rendezvous( iStatus );
+            SetActive();
+            }
+        else
+            {
+            //error in starting, no restarting needed
+            iStarted = EFalse;
+            LOG1( "ERROR: RProcess::Create = %d" ,  err );
+            }
+        }
+
+    }
+
+
+// ----------------------------------------------------------------------------
+// Logon to usbdevcon process for termination
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::Logon()
+    {
+    LOG_FUNC
+
+    iState = ERunning;
+
+    //request termination notify
+    iProcess.Logon( iStatus );
+    SetActive();
+    }
+
+
+// ----------------------------------------------------------------------------
+// StopRestarting prevents usbdevcon process restarting.
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::StopRestarting()
+    {
+    LOG_FUNC
+
+    iStarted = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// RunL handles the process termination.
+// The process is restarted, if Stop has not been requested and it terminated
+// without error.
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::RunL()
+    {
+    LOG_FUNC
+
+    LOG2( "iStatus = %d, iState = %d", iStatus.Int(), iState );
+    switch( iState )
+        {
+        case EIdle:
+            {
+            break;
+            }
+        case EWaitingRendezvous:
+            {
+            Logon();
+            break;
+            }
+        case ERunning:
+            {
+            iState = EIdle;
+            iProcess.Close();
+
+            //Do not restart, if terminated with error.
+            if( iStarted && ( iStatus == KErrNone ) )
+                {
+                Start();
+                }
+            break;
+            }
+        default:
+            LOG( "Unhandled state" );
+			break;
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// Log error, if RunL leaves. RunL should never leave.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbDevConStarter::RunError( TInt aError )
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d", aError );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// DoCancel
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::DoCancel()
+    {
+    LOG_FUNC
+
+    iProcess.LogonCancel( iStatus );
+    iProcess.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CUsbDevConStarter::CUsbDevConStarter()
+    : CActive( EPriorityStandard )
+    , iStarted( EFalse )
+    , iState( EIdle )
+    {
+    LOG_FUNC
+
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructL
+// ----------------------------------------------------------------------------
+//
+void CUsbDevConStarter::ConstructL()
+    {
+    LOG_FUNC
+    //empty
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbdevicelock.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,212 @@
+/*
+* 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:  Implements device lock feature in case of USB
+*
+*/
+
+
+#include <featmgr.h>
+#include <bldvariant.hrh>
+
+#include <e32base.h>
+#include <e32property.h>
+#include <coreapplicationuisdomainpskeys.h>
+#include <e32property.h>
+
+#include "debug.h"
+#include "cusbdevicelock.h"
+#include "cusbwatcher.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CUsbDeviceLock::CUsbDeviceLock( CUsbWatcher& aOwner )
+    : CActive( EPriorityNormal )
+    , iOwner( aOwner )
+    {
+    LOG_FUNC
+
+    CActiveScheduler::Add(this);
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbDeviceLock::~CUsbDeviceLock()
+    {
+    LOG_FUNC
+
+    if( FeatureManager::FeatureSupported( KFeatureIdUsbDeviceLock ) )
+        {
+        Cancel();
+        iProperty.Close();
+        }
+
+    FeatureManager::UnInitializeLib();
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbDeviceLock* CUsbDeviceLock::NewL( CUsbWatcher& aOwner )
+    {
+    LOG_FUNC
+
+    CUsbDeviceLock* self = new ( ELeave ) CUsbDeviceLock( aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbDeviceLock::ConstructL()
+    {
+    LOG_FUNC
+
+    FeatureManager::InitializeLibL();
+
+    if( FeatureManager::FeatureSupported( KFeatureIdUsbDeviceLock ) )
+        {
+        LEAVEIFERROR( iProperty.Attach( KPSUidCoreApplicationUIs,
+            KCoreAppUIsAutolockStatus ) );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Subscribes to P&S property.
+// ----------------------------------------------------------------------------
+//
+void CUsbDeviceLock::Subscribe()
+    {
+    LOG_FUNC
+
+    if( FeatureManager::FeatureSupported( KFeatureIdUsbDeviceLock ) )
+        {
+        if ( !IsActive() )
+            {
+            iProperty.Subscribe( iStatus );
+            SetActive();
+            }
+        else
+            {
+            LOG( "ERROR: request exists" );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Get device lock state.
+// ----------------------------------------------------------------------------
+//
+TBool CUsbDeviceLock::Locked()
+    {
+    LOG_FUNC
+
+    TInt command;
+    if( FeatureManager::FeatureSupported( KFeatureIdUsbDeviceLock ) )
+        {
+        TInt err = iProperty.Get( command );
+        if(  KErrNone == err )
+            {
+            LOG1( "Autolock status = %d", command );
+            if( EAutolockOff == command )
+                {
+                LOG("Device UNLOCKED" );
+                return EFalse;
+                }
+            else
+                {
+                LOG( "Device LOCKED"  );
+                }
+            }
+        else
+            {
+            LOG1( "ERROR: RProperty::Get = %d", err );
+            }
+
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbDeviceLock::RunError( TInt /*aError*/ )
+    {
+    LOG_FUNC
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// When device lock state changes this method is executed.
+// ----------------------------------------------------------------------------
+//
+void CUsbDeviceLock::RunL()
+    {
+    LOG_FUNC
+    LOG1( "iStatus: %d", iStatus.Int() );
+    Subscribe();
+    TInt command = EAutolockStatusUninitialized;
+    TInt err = iProperty.Get( command );
+    if ( err == KErrNone )
+        {
+        LOG1( "Autolock status: %d", command );
+        switch ( command )
+            {
+            case EAutolockOff:
+                iOwner.Unlock();
+                break;
+            case ERemoteLocked:
+                iOwner.Lock();
+                break;
+            default:
+                LOG1( "Unhandled state: %d",  command );
+                break;
+            }
+        }
+    else
+        {
+        LOG1( "RProperty::Get ERROR %d", err );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbMediaWatcher::CUsbDeviceLock::DoCancel
+// Basic DoCancel.
+// ----------------------------------------------------------------------------
+//
+void CUsbDeviceLock::DoCancel()
+    {
+    LOG_FUNC
+
+    if( FeatureManager::FeatureSupported( KFeatureIdUsbDeviceLock ) )
+        {
+        iProperty.Cancel();
+        }
+    }
+
+// End if file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbglobalsystemstateobserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,181 @@
+/*
+* 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:  Subscribe to global system state events
+*
+*/
+
+
+#include <startupdomainpskeys.h> //for global system state
+#include "cusbglobalsystemstateobserver.h"
+#include "cusbwatcher.h"
+
+// ----------------------------------------------------------------------------
+// Two-phase constructor
+// ----------------------------------------------------------------------------
+//
+CUsbGlobalSystemStateObserver* CUsbGlobalSystemStateObserver::NewL(
+        CUsbWatcher& aUsbWatcher )
+    {
+    LOG_FUNC
+
+    CUsbGlobalSystemStateObserver* me = CUsbGlobalSystemStateObserver::NewLC(
+            aUsbWatcher );
+    CleanupStack::Pop();
+    return me;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phase constructor, instance put in cleanupstack
+// ----------------------------------------------------------------------------
+//
+CUsbGlobalSystemStateObserver* CUsbGlobalSystemStateObserver::NewLC(
+        CUsbWatcher& aUsbWatcher )
+    {
+    LOG_FUNC
+
+    CUsbGlobalSystemStateObserver* me = new ( ELeave )
+            CUsbGlobalSystemStateObserver( aUsbWatcher );
+    CleanupStack::PushL( me );
+    me->ConstructL();
+    return me;
+    }
+
+// ----------------------------------------------------------------------------
+// 2nd Phase Construction
+// ----------------------------------------------------------------------------
+//
+void CUsbGlobalSystemStateObserver::ConstructL()
+    {
+    LOG_FUNC
+
+    User::LeaveIfError( iProperty.Attach( KPSUidStartup,
+            KPSGlobalSystemState ) );
+    }
+
+// ----------------------------------------------------------------------------
+// C++ Constructor
+// ----------------------------------------------------------------------------
+//
+CUsbGlobalSystemStateObserver::CUsbGlobalSystemStateObserver(
+        CUsbWatcher& aUsbWatcher )
+    : CActive( EPriorityNormal )
+    , iUsbWatcher( aUsbWatcher )
+    {
+    LOG_FUNC
+
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbGlobalSystemStateObserver::~CUsbGlobalSystemStateObserver()
+    {
+    LOG_FUNC
+
+    Cancel();
+    iProperty.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// Return global system state
+// ----------------------------------------------------------------------------
+//
+TInt CUsbGlobalSystemStateObserver::GlobalSystemState()
+    {
+    LOG_FUNC
+
+    TInt state;
+    RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
+    return state;
+    }
+
+// ----------------------------------------------------------------------------
+// Start observing the state P&S key
+// ----------------------------------------------------------------------------
+//
+void CUsbGlobalSystemStateObserver::Subscribe()
+    {
+    LOG_FUNC
+
+    if( IsActive() )
+        {
+        LOG( "Already observing" );
+        return; // already observing
+        }
+
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// Stop observing the state P&S key
+// ----------------------------------------------------------------------------
+//
+void CUsbGlobalSystemStateObserver::DoCancel()
+    {
+    LOG_FUNC
+
+    iProperty.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// Called when the state changes
+// ----------------------------------------------------------------------------
+//
+void CUsbGlobalSystemStateObserver::RunL()
+{
+    LOG_FUNC
+    LOG1( "iStatus = %d", iStatus.Int() );
+
+    Subscribe();
+    TInt systemState = 0;
+    User::LeaveIfError( iProperty.Get( systemState ) );
+    LOG1( "SystemState= %d", systemState );
+
+    if (  ( systemState == ESwStateChargingToNormal )
+       || ( systemState == ESwStateAlarmToNormal )  )
+        {
+        iUsbWatcher.StopPersonality();
+        }
+    else if ( systemState == ESwStateCharging )
+        {
+        //USBWatcher started before charging state
+        iUsbWatcher.StartPersonality();
+        }
+    else if (
+        (systemState == ESwStateNormalRfOn) ||
+        (systemState == ESwStateNormalRfOff) ||
+        (systemState == ESwStateNormalBTSap) )
+        {
+        //after ESwStateChargingToNormal
+        Cancel();
+        iUsbWatcher.StartPersonality();
+        }
+}
+
+// ----------------------------------------------------------------------------
+// Handle RunL leaving
+// ----------------------------------------------------------------------------
+//
+TInt CUsbGlobalSystemStateObserver::RunError( TInt aError )
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d", aError );
+    return ( KErrNone );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbpersonality.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* 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:  Base class for personalitites
+*
+*/
+
+
+#include <usbman.h>
+#include <usbuinotif.h>
+#include <cusbpersonality.h>
+#include <tusbpersonalityparams.h>
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonality::CUsbPersonality( TUsbPersonalityParams&
+        aPersonalityParams )
+    : CActive( EPriorityStandard )
+    , iPersonalityParams( aPersonalityParams )
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CUsbPersonality::~CUsbPersonality()
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// Called by CUsbActivePersonalityHandler.
+// DEPRICATED
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CUsbPersonality::ShowUsbConnectionNote()
+    {
+    LOG_FUNC
+
+    }
+    
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbpersonalitynotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,446 @@
+/*
+* 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:  CUsbPersonalityNotifier class prevents confirmation notes
+*                from overlapping.
+*
+*/
+
+
+#include <cusbpersonalitynotifier.h>
+#include "debug.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CUsbPersonalityNotifier::CUsbPersonalityNotifier()
+    : CActive( EPriorityStandard )
+    {
+    LOG_FUNC
+        
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbPersonalityNotifier::ConstructL()
+    {
+    LOG_FUNC
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityNotifier* CUsbPersonalityNotifier::NewL()
+    {
+    LOG_FUNC
+
+    CUsbPersonalityNotifier* self = new ( ELeave ) CUsbPersonalityNotifier();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+    
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityNotifier::~CUsbPersonalityNotifier()
+    {
+    LOG_FUNC
+    
+    Cancel();
+    
+    for( TInt i = 0; iNotifierClient.Count(); i++ )
+        {
+        delete iNotifierClient[i];
+        }
+        
+    iNotifierClient.Reset();
+    iNotifierClient.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// Called when information note or query is completed.
+// ----------------------------------------------------------------------------
+//
+void CUsbPersonalityNotifier::RunL()
+    {
+    LOG_FUNC
+        
+    LOG1( "iStatus = %d", iStatus.Int() );
+        
+    if( iCallBack )
+        {
+        iCallBack->CallBack( iStatus.Int() );
+        }
+        
+    iNotifier.CancelNotifier( iNotifierUid );
+    iNotifier.Close();
+    
+    iState = EUsbPersonalityNotifierIdle;
+    
+    if( iRequestStatus )
+        {
+        User::RequestComplete( iRequestStatus, iStatus.Int() );
+        iRequestStatus = NULL;
+        }
+    
+    if( iNotifierClient.Count() )
+        {        
+        if( iNotifierClient[0]->iConfirmation )
+            {
+            DoShowQuery( iNotifierClient[0]->iCallBack,
+                    iNotifierClient[0]->iNotifierUid,
+                    iNotifierClient[0]->iBuffer,
+                    iNotifierClient[0]->iResponse,
+                    iNotifierClient[0]->iRequestStatus );
+            }
+        else
+            {
+            DoShowNote( iNotifierClient[0]->iNotifierUid,
+                    iNotifierClient[0]->iBuffer,
+                    iNotifierClient[0]->iResponse );
+            }
+        
+        delete iNotifierClient[0];
+        iNotifierClient.Remove( 0 );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is never called in this implementation.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbPersonalityNotifier::RunError( TInt aError )
+    {
+    LOG_FUNC
+    
+    LOG1( "aError %d", aError );
+    // Currently no leaving functions called in RunL, thus nothing should cause
+    // this to be called -> return.
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Called if there is outstanding request.
+// ----------------------------------------------------------------------------
+//
+void CUsbPersonalityNotifier::DoCancel()
+    {
+    LOG_FUNC
+    
+    if( EUsbPersonalityNotifierStarted == iState )
+        {
+        LOG( "Canceling and closing notifier" );
+        iNotifier.CancelNotifier( iNotifierUid );
+        iNotifier.Close();
+        iState = EUsbPersonalityNotifierIdle;
+        
+        if( iRequestStatus )
+            {
+            LOG( "Completing request" );
+            User::RequestComplete( iRequestStatus, KErrCancel );
+            iRequestStatus = NULL;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Show query or queue it.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt CUsbPersonalityNotifier::ShowQuery( TUid aNotifierUid,
+        const TDesC8 &aBuffer, TDes8 &aResponse, 
+        MUsbNotifierCallBack* aCallBack, TRequestStatus* aStatus )
+    {
+    LOG_FUNC
+
+    TInt ret = KErrNone;
+        
+    if( aStatus )
+        {
+        // set to pending
+        *aStatus = KRequestPending;
+        }
+    
+    if( iState == EUsbPersonalityNotifierIdle )
+        {
+        // no request pending, don't que the requests
+        ret = DoShowQuery( aCallBack, aNotifierUid, aBuffer, aResponse,
+                aStatus );
+        }
+    else
+        {
+        // request pending, put request to the queue
+        TNotifierClient* ptr;
+        
+        if( (ptr = new TNotifierClient( aCallBack, aNotifierUid, aBuffer,
+                aResponse, aStatus, ETrue ) ) == NULL )
+            {
+            return KErrGeneral;
+            }
+                
+        iNotifierClient.Append(ptr);
+        }
+    
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Show note or queue it.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt CUsbPersonalityNotifier::ShowNote( TUid aNotifierUid, 
+        const TDesC8 &aBuffer, TDes8 &aResponse )
+    {
+    LOG_FUNC
+        
+    TInt ret = KErrNone;
+    
+    if( EUsbPersonalityNotifierIdle == iState )
+        {
+        // no request pending, don't que the requests
+        ret = DoShowNote( aNotifierUid, aBuffer, aResponse );
+        }
+    else
+        {
+        // request pending, put request to the queue
+        TNotifierClient* ptr;
+        
+        if( ( ptr = new TNotifierClient( NULL, aNotifierUid, aBuffer, 
+                aResponse, NULL, EFalse ) ) == NULL )
+            {
+            return KErrGeneral;
+            }
+                
+        iNotifierClient.Append( ptr );
+        }
+    
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel currently on going query and all queued gueries and notes.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CUsbPersonalityNotifier::CancelAll()
+    {
+    LOG_FUNC
+
+    Cancel();
+    
+    for (TInt i = 0; i < iNotifierClient.Count(); i++ )
+        {
+        LOG( "Deleting client entry" );
+        
+        if( iNotifierClient[i]->iRequestStatus )
+            {
+            LOG( "Completing request" );
+            User::RequestComplete( iNotifierClient[i]->iRequestStatus, 
+                KErrCancel );
+            }
+        
+        delete iNotifierClient[i];
+        iNotifierClient[i] = NULL;
+        }
+    
+    iNotifierClient.Reset();
+    
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel specific query.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CUsbPersonalityNotifier::CancelQuery( TUid aNotifierUid )
+    {
+    LOG_FUNC
+
+    TBool done = EFalse;
+    TInt i = 0;
+    
+    if( iNotifierUid == aNotifierUid )
+        {
+        Cancel();
+        }
+
+    while( !done )
+        {
+        for( i = 0; i < iNotifierClient.Count(); i++ )
+            {
+            LOG1( "CancelQuery i = %d", i );
+
+            if(iNotifierClient[i]->iNotifierUid == aNotifierUid)
+                {
+                LOG( "Uid match" );
+                if(iNotifierClient[i]->iRequestStatus)
+                    {
+                    User::RequestComplete(iNotifierClient[i]->iRequestStatus,
+                        KErrCancel);
+                    }
+
+                delete iNotifierClient[i];
+                iNotifierClient.Remove(i);
+                break;
+                }
+            }
+        
+        if( i >= iNotifierClient.Count() )
+            {
+            done = ETrue;
+            }
+        }    
+    }
+    
+// ----------------------------------------------------------------------------
+// Cancel all other queued gueries and notes but the current.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CUsbPersonalityNotifier::CancelAllButCurrent()
+    {
+    LOG_FUNC
+
+    if( iNotifierClient.Count() > 0 )
+        {
+        //The index 0 is the current, which is not deleted.
+        for( TInt i = 1; i < iNotifierClient.Count(); i++ )
+            {
+           LOG( "Deleting client entry" );
+            
+            if( iNotifierClient[i]->iRequestStatus )
+                {
+                LOG( "Completing request" );
+                User::RequestComplete( iNotifierClient[i]->iRequestStatus,
+                        KErrCancel);
+                }
+            
+            delete iNotifierClient[i];
+        }
+
+        //Remove all but the 1st
+        TNotifierClient* ptr = iNotifierClient[0];
+        iNotifierClient.Reset();
+        iNotifierClient.Append( ptr );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Return ETrue, if the notifier with the UID is currently showing.
+// DEPRICATED
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TBool CUsbPersonalityNotifier::IsShowing( TUid aNotifierUid )
+    {
+    LOG_FUNC
+
+    return ( ( iState == EUsbPersonalityNotifierStarted ) 
+        && ( iNotifierUid == aNotifierUid) );
+    }
+
+// ----------------------------------------------------------------------------
+// Implementation for showing notes.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbPersonalityNotifier::DoShowNote( TUid aNotifierUid, 
+    const TDesC8 &aBuffer, TDes8 &aResponse )
+    {
+    LOG_FUNC
+
+    TInt ret = KErrNone;
+            
+    iCallBack = NULL;
+    iNotifierUid = aNotifierUid;
+    iRequestStatus = NULL;
+    
+    // initializations
+    ret = iNotifier.Connect();
+    
+    if( ret != KErrNone )
+        {
+        LOG1( "ERROR: RNotifier::Connect = %d", ret );
+        return ret;
+        }
+    
+    ret = iNotifier.StartNotifier( aNotifierUid, aBuffer, aResponse );
+    
+    if( ret != KErrNone )
+        {
+        LOG1( "ERROR: StartNotifier() failed. Code: %d", ret );
+        }
+        
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, ret );
+    SetActive();
+    iState = EUsbPersonalityNotifierStarted;
+    
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Implementation for showing queries.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbPersonalityNotifier::DoShowQuery( MUsbNotifierCallBack* aCallBack, 
+        TUid aNotifierUid, const TDesC8 &aBuffer, TDes8 &aResponse,
+        TRequestStatus* aStatus )
+    {
+    LOG_FUNC
+        
+    TInt ret;
+        
+    iCallBack = aCallBack;
+    iNotifierUid = aNotifierUid;
+    iRequestStatus = aStatus;
+    
+    if( ( ret = iNotifier.Connect() ) != KErrNone )
+        {
+        LOG( "ERROR in notifier connection!" );
+        return ret;
+        }
+
+    iNotifier.StartNotifierAndGetResponse( iStatus, aNotifierUid, aBuffer,
+            aResponse );
+    SetActive();
+    iState = EUsbPersonalityNotifierStarted;
+    
+    return ret;
+    }
+    
+// ----------------------------------------------------------------------------
+// Constructor of TNotifierClient
+// ----------------------------------------------------------------------------
+//
+CUsbPersonalityNotifier::TNotifierClient::TNotifierClient(
+        MUsbNotifierCallBack* aCallBack, TUid aNotifierUid, 
+        const TDesC8 &aBuffer, TDes8 &aResponse, TRequestStatus* aStatus,
+        TBool aConfirmation )
+    : iCallBack( aCallBack )
+    , iNotifierUid( aNotifierUid )
+    , iBuffer( aBuffer )
+    , iResponse( aResponse )
+    , iRequestStatus( aStatus )
+    , iConfirmation( aConfirmation )
+    {
+    LOG_FUNC
+        
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbpersonalityplugin.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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:  Personality plugins must be inherited from this class.
+*
+*/
+
+
+#include <cusbpersonalityplugin.h>
+#include <ecom/ecom.h>
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityPlugin::CUsbPersonalityPlugin(
+        TUsbPersonalityParams& aPersonalityParams )
+    : CUsbPersonality( aPersonalityParams )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Factory function
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityPlugin* CUsbPersonalityPlugin::NewL( 
+        TUsbPersonalityParams& aPersonalityParams, TUid aImplementationId ) 
+    {
+    return ( reinterpret_cast<CUsbPersonalityPlugin*>(
+            REComSession::CreateImplementationL( aImplementationId, 
+                    _FOFF(CUsbPersonalityPlugin, iPrivateEComUID),
+                    ( TAny* ) &aPersonalityParams ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor will destroy the implementation
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityPlugin::~CUsbPersonalityPlugin()
+    {
+    REComSession::DestroyedImplementation(iPrivateEComUID);
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbwatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,1082 @@
+/*
+* 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:  This implements CUsbWatcher class.
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <utf.h>
+#include <coreapplicationuisdomainpskeys.h>
+//CleanupResetAndDestroyPushL
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <UsbWatcherInternalCRKeys.h>
+#include <cusbpersonalitynotifier.h>
+#include <UsbWatcherInternalPSKeys.h>
+#include <e32property.h>
+#include <startupdomainpskeys.h> //for global system state
+
+#include "cusbwatcher.h"
+#include "cusbactivestate.h"
+#include "cusbactivepersonalityhandler.h"
+#include "cusbwatchersession.h"
+#include "cusbdevicelock.h"
+#include "cusbdevconstarter.h"
+#include "cusbglobalsystemstateobserver.h"
+#include "cusbotgwatcher.h"
+
+_LIT_SECURITY_POLICY_PASS( KAlwaysPassPolicy );
+_LIT_SECURITY_POLICY_C1( KLocalServicesPolicy, ECapabilityLocalServices );
+
+const TUint32 KUsbWatcherUseSerialNumber = 0x80000000;
+const TUint32 KUsbWatcherPersonalityIdMask = 0x0000FFFF;
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbWatcher::CUsbWatcher()
+    : CActive( EPriorityStandard )
+    {
+    LOG_FUNC
+
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::ConstructL()
+    {
+    LOG_FUNC
+
+    LEAVEIFERROR( RProperty::Define( KPSUidUsbWatcher,
+            KUsbWatcherSelectedPersonality, RProperty::EInt, KAlwaysPassPolicy,
+            KLocalServicesPolicy ) );
+
+    LEAVEIFERROR( RProperty::Set( KPSUidUsbWatcher,
+            KUsbWatcherSelectedPersonality,
+            KUsbWatcherSelectedPersonalityNone ) );
+
+    iPersonalityRepository = CRepository::NewL( KCRUidUsbWatcher );
+
+    LEAVEIFERROR( iPersonalityRepository->Get( KUsbWatcherPersonality,
+            iPersonalityId ) );
+    LOG1( "iPersonalityId from CenRep = %d", iPersonalityId );
+    iPrevPersonalityId = iPersonalityId;
+    iOldPrevPersonalityId = iPersonalityId;
+    LEAVEIFERROR( iUsbMan.Connect() );
+
+    TInt ret = iUsbMan.SetCtlSessionMode( ETrue );
+    if( KErrNone == ret )
+        {
+        LOG( "Creating CUsbOtgWatcher..."  );
+        iOtgWatcher = CUsbOtgWatcher::NewL( iUsbMan );
+        }
+    else if( KErrNotSupported == ret )
+        {
+        LOG( "Non-OTG configuration detected!"  );
+        }
+    else
+        {
+        LOG( "ERROR: is there another USB Control process? LEAVE" );
+        LEAVE( ret );
+        }
+
+    iPersonalityHandler
+        = CUsbActivePersonalityHandler::NewL( iUsbMan, *this );
+
+    GetPersonalityPluginsL();
+    iUsbDeviceLock = CUsbDeviceLock::NewL( *this );
+    iUsbDeviceLock->Subscribe();
+    iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this );
+    iUsbDevConStarter = CUsbDevConStarter::NewL();
+    iActiveState = CUsbActiveState::NewL( iUsbMan, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbWatcher* CUsbWatcher::NewL()
+    {
+    LOG_FUNC
+
+    CUsbWatcher* self = new ( ELeave ) CUsbWatcher();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // pop self
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CUsbWatcher::~CUsbWatcher()
+    {
+    LOG_FUNC
+
+    RProperty::Delete( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality );
+
+    iUsbMan.Close();
+    iObservers.Reset();
+    if( iUsbDeviceLock )
+        {
+        iUsbDeviceLock->Cancel();
+        }
+    delete iActiveState;
+    delete iUsbDevConStarter;
+    delete iPersonalityHandler;
+    delete iPersonalityRepository;
+    delete iOtgWatcher;
+    delete iUsbDeviceLock;
+    delete iGlobalStateObserver;
+    iSupportedPersonalities.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// Get personality plugins. Note that this is done only in normal mode.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::GetPersonalityPluginsL()
+    {
+    LOG_FUNC
+    
+    // Get personality plugins
+    RImplInfoPtrArray implementations;
+    CleanupResetAndDestroyPushL( implementations );
+
+    const TEComResolverParams noResolverParams;
+
+    REComSession::ListImplementationsL( KUidPersonalityPlugIns,
+            noResolverParams, KRomOnlyResolverUid, implementations );
+    TInt personalityNum = implementations.Count();
+    LOG1( "Number of PersonalityPlugin(s): %d", personalityNum );
+    
+    if( personalityNum < 1 )
+        {
+        LOG( "No PersonalityPlugin available. LEAVE" );
+        LEAVE( KErrGeneral );
+        }
+
+    for( TInt i = 0; i < personalityNum; i++ )
+        {
+        TUsbSupportedPersonalityInf inf;
+        TLex8 lex;
+        TUint32 confValue;
+
+        // save implementation uid
+        inf.iPersonalityUid = implementations[i]->ImplementationUid();
+        lex.Assign( implementations[i]->DataType() );
+
+        if( lex.Val( confValue, EHex ) != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( &implementations );
+            iSupportedPersonalities.Close();
+            LEAVE( KErrGeneral );
+            }
+
+        // check whether personality requires serial number
+        if( confValue & KUsbWatcherUseSerialNumber )
+            {
+            inf.iUseSerialNumber = ETrue;
+            }
+        else
+            {
+            inf.iUseSerialNumber = EFalse;
+            }
+
+        // save personality id
+        inf.iPersonalityId = static_cast<TInt>( ( KUsbWatcherPersonalityIdMask
+                & confValue ) );
+
+        LOG1( "PersonalityId = %d" , inf.iPersonalityId );
+
+        iSupportedPersonalities.AppendL( inf );
+        }
+
+    CleanupStack::PopAndDestroy( &implementations );
+    }
+
+// ----------------------------------------------------------------------------
+// This method notifies CUsbWatcher class about USB state changes.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld,  
+        TUsbDeviceState aStateNew )
+    {
+    LOG_FUNC
+
+    // Handling USB indicator. This is valid for both A- and B-device cases.
+    // Not show USB indicator in charging mode
+    if ( iNormalStart ) 
+        {
+        iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew );
+        }
+        
+    if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher
+        {
+        LOG( "Device state change ignored by UsbWatcher in A-device state" );
+        return;
+        }
+
+    LOG1( "WatcherState = %d", iState );
+        
+    // Notify personality handler first
+    switch( aStateNew )
+        {
+        case EUsbDeviceStatePowered:
+            // Case for Attached state missed 
+            // NO break here;
+        case EUsbDeviceStateAttached:
+            {
+            if( EUsbDeviceStateUndefined != aStateOld )
+                {
+                LOG1( "Not starting personality, previous state: %d", 
+                    aStateOld);
+                break;
+                }
+            LOG1( "Starting USB personality in device state: %d", aStateNew );
+            iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew );
+            // Check AskOnConnection setting every time
+            if( ( iSupportedPersonalities.Count() > 1 ) &&
+                    !IsAskOnConnectionSuppression() )
+                {
+                // read setting if there is more than one personality
+                iPersonalityRepository->Get(
+                        KUsbWatcherChangeOnConnectionSetting,
+                        iAskOnConnectionSetting );
+                }
+
+            if( ( iState == EUsbIdle ) && !iPersonalityChangeOngoing )
+                {
+                Start();
+                }
+            else if( ( iState != EUsbStarted ) && !iPersonalityChangeOngoing )
+                {
+                Cancel();
+                Start();
+                }
+
+            // Let's turn ask on connection off after start cause we will
+            // issue it only when cable is connected
+            iAskOnConnectionSetting = KUsbWatcherChangeOnConnectionOff;
+
+            //start usbdevcon only in normal global state
+            TInt globalState =
+                    CUsbGlobalSystemStateObserver::GlobalSystemState();
+            if( ( ESwStateNormalRfOn == globalState ) ||
+                    ( ESwStateNormalRfOff == globalState ) ||
+                    ( ESwStateNormalBTSap == globalState ) )
+                {
+                iUsbDevConStarter->Start();
+                }
+            }
+            break;
+
+        case EUsbDeviceStateUndefined:
+            {
+            iGlobalStateObserver->Cancel();
+            // Notify clients currently loaded personality will be unloaded
+            iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew );
+            iUsbDevConStarter->StopRestarting();
+            // This must be done before Notify()
+            if( iSetPreviousPersonalityOnDisconnect )
+                {
+                TInt temp = iPersonalityId;
+                iPersonalityId = iPrevPersonalityId;
+                iPrevPersonalityId = temp;
+                WritePersonalityId( iPersonalityId );
+                iSetPreviousPersonalityOnDisconnect = EFalse;
+                }
+
+            Notify( KErrCancel );
+            if (iState == EUsbStarting)
+                {
+                LOG( "StartCancel USB" );
+                Cancel();
+                }
+            else
+                {
+                LOG( "Stop USB" );
+                
+                if( EUsbConfirmStop == iState )
+                    {
+                    // We have request pending on personality handler
+                    Cancel();
+                    }
+                
+                    Stop();
+                    }
+            }
+            break;
+
+        default:
+            if ( EUsbStarted == iState )
+                {
+                iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew );
+                }
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// From class CActive.
+// This method cancels any outstanding request.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::DoCancel()
+    {
+    LOG_FUNC
+
+    LOG1( "WatcherState = %d", iState );
+    if( ( EUsbStarting == iState ) || ( EUsbStopping == iState ) )
+        {
+        iPersonalityHandler->Cancel();
+
+        RProperty::Set( KPSUidUsbWatcher,
+                KUsbWatcherSelectedPersonality,
+                KUsbWatcherSelectedPersonalityNone );
+        LOG( "personality set to none" );
+
+        iState = EUsbIdle;
+        }
+    else if( EUsbConfirmStop == iState )
+        {
+        iPersonalityHandler->Cancel();
+        iState = EUsbStarted;
+        }
+    else
+        {
+        LOG( "Nothingh to cancel" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method implements state machine for personality start and stop.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::RunL()
+    {
+    LOG_FUNC
+
+    LOG1( "WatcherState = %d", iState );
+    TInt ret = iStatus.Int();
+    if ( KErrNone != ret  )
+        {
+        LOG1( "ERROR: CUsbWatcher::RunL iStatus = %d", ret );
+        }
+
+    switch ( iState )
+        {
+        case EUsbStarting:
+            LOG( "Personality started" );
+            Notify( ret );
+            if( iStopStartScenario )
+                {
+                iStopStartScenario = EFalse;
+                }
+            //check if StartPersonality() fails     
+            LEAVEIFERROR( ret );
+            iState = EUsbStarted;
+            break;
+
+        case EUsbStopping:
+            LOG( "Personality stopped" );
+            iState = EUsbIdle;
+            if( iStopStartScenario )
+                {
+                Start();
+                }
+            else
+                {
+                RProperty::Set( KPSUidUsbWatcher,
+                    KUsbWatcherSelectedPersonality,
+                    KUsbWatcherSelectedPersonalityNone );
+                }
+            break;
+
+        case EUsbStarted:
+            if( iStopStartScenario )
+                {
+                break;
+                }
+
+            iPersonalityHandler->StopPersonality( iStatus );
+            SetActive();
+            iState = EUsbStopping;
+            break;
+
+        case EUsbIdle:
+            if( iStopStartScenario )
+                {
+                Start();
+                }
+            break;
+
+        case EUsbConfirmStop:
+            if( iStatus == KErrNone )
+                {
+                iStopStartScenario = ETrue;
+                iPersonalityHandler->StopPersonality( iStatus );
+                SetActive();
+                iState = EUsbStopping;
+                }
+            else
+                {
+                Notify( ret );
+                iState = EUsbStarted;
+                }
+            break;
+
+        default:
+            LOG( "ERROR: unexpected state" );
+            PANIC( KErrGeneral );
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is not called cause RunL() never leaves.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcher::RunError(TInt aError)
+    {
+    LOG_FUNC
+    
+    LOG2("Returned error: %d, iState: %d", aError, iState);
+    if ( iState == EUsbStarting )
+        {
+        RProperty::Set( KPSUidUsbWatcher,
+                KUsbWatcherSelectedPersonality,
+                KUsbWatcherSelectedPersonalityNone );
+        LOG( "personality set to none" );
+
+        iState = EUsbIdle;
+        }
+    
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Function is called when state of the device is locked.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Lock()
+    {
+    LOG_FUNC
+
+    if( IsDeviceA() ) // Not applicable in case of A-device
+        {
+        LOG( "Lock ignored in A-device state" );
+        return;
+        }
+
+    
+    TUsbDeviceState state = iActiveState->CurrentState();
+
+    LOG1( "USB device state after lock: %d", state );
+
+    if( EUsbDeviceStateUndefined != state ) // Stop personality
+        {
+        LOG( "Stopping USB persoanlity on device remote-lock" );
+
+        iPersonalityHandler->CancelCableConnectedNotifier();
+
+        if( iState != EUsbStarted )
+            {
+            Cancel();
+            }
+        else
+            {
+            Stop();
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Function is called when state of the device is unlocked.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Unlock()
+    {
+    LOG_FUNC
+
+    if( IsDeviceA() ) // Not applicable in case of A-device
+        {
+        LOG( "Unlock ignored in A-device state" );
+        return;
+        }
+
+    TUsbDeviceState state = iActiveState->CurrentState();
+
+    LOG1( "USB device state after unlock: %d", state );
+    if( EUsbDeviceStateAttached == state || EUsbDeviceStatePowered == state)
+        {
+        LOG( "Starting USB personality" );
+        TInt err = iPersonalityRepository->Get(
+           KUsbWatcherChangeOnConnectionSetting, iAskOnConnectionSetting );
+        if( KErrNone == err )
+            {
+            Start();
+            iAskOnConnectionSetting = KUsbWatcherChangeOnConnectionOff;
+            }
+        else
+            {
+            LOG1( "Error: CRepository::Get = %d", err );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is called when client wants to set new personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::SetPersonality( TInt aPersonalityId, TBool aNonBlocking )
+    {
+    LOG_FUNC
+
+    LOG2( "aPersonalityId=%d, aNonBlocking=%d", aPersonalityId, aNonBlocking );
+
+    // Check if personality is exist
+    TBool found = EFalse;
+
+    for( TInt i = 0; i < iSupportedPersonalities.Count(); i++ )
+        {
+        if( iSupportedPersonalities[i].iPersonalityId == aPersonalityId )
+            {
+            found = ETrue;
+            }
+        }
+
+    if( !found )
+        {
+        Notify( KErrNotFound );
+        return;
+        }
+
+    iSetPersonalityOngoing = ETrue;
+    iPersonalityChangeOngoing = ETrue;
+
+    //The previous personality is not changed, if the client wanted the
+    //previous personality change to be temporary. The client has to call
+    //SetPreviousPersonalityOnDisconnect after each SetPersonality to be
+    //intended as temporary.
+    if( iSetPreviousPersonalityOnDisconnect )
+        {
+        iSetPreviousPersonalityOnDisconnect = EFalse;
+        }
+    else
+        {
+        iOldPrevPersonalityId = iPrevPersonalityId;
+        iPrevPersonalityId = iPersonalityId;
+        LOG( "CUsbWatcher::SetPersonality setting previous" );
+        }
+    LOG1( " iPrevPersonalityId = %d", iPrevPersonalityId );
+    if( iPersonalityId != aPersonalityId )
+        {
+        iPersonalityId = aPersonalityId;
+        SwitchPersonality( aNonBlocking );
+        }
+    else
+        {
+        Notify( KErrNone );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is called when client wants to cancel set personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::CancelSetPersonality()
+    {
+    LOG_FUNC
+
+    Notify( KErrCancel );
+    iPersonalityChangeOngoing = ETrue;
+    iStopStartScenario = EFalse;
+    SwitchPersonality();
+    }
+
+// ----------------------------------------------------------------------------
+// This method is called when client wants to set previous personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::SetPreviousPersonality()
+    {
+    LOG_FUNC
+
+    if( IsDeviceA() ) 
+        {
+        LOG( "SetPreviousPersonality not allowed in A-device state" );
+        Notify( KErrAccessDenied );
+        return;
+        }
+    
+    TInt temp = iPersonalityId;
+    iSetPreviousPersonalityOnDisconnect = EFalse;
+
+    iPersonalityId = iPrevPersonalityId;
+    iPrevPersonalityId = temp;
+    iSetPreviousPersonalityOngoing = ETrue;
+    iPersonalityChangeOngoing = ETrue;
+
+    if( iPersonalityId != iPrevPersonalityId )
+        {
+        SwitchPersonality();
+        }
+    else
+        {
+        Notify( KErrNone );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is called when client wants to cancel set previous personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::CancelSetPreviousPersonality()
+    {
+    LOG_FUNC
+
+    Notify( KErrCancel );
+    iPersonalityChangeOngoing = ETrue;
+    iStopStartScenario = EFalse;
+    SwitchPersonality();
+    }
+
+// ----------------------------------------------------------------------------
+// This method is called when client wants to set previous personality on
+// disconnect.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::SetPreviousPersonalityOnDisconnect()
+    {
+    LOG_FUNC
+
+    if( IsDeviceA() ) 
+        {
+        LOG( "Not allowed in A-device state" );
+        Notify( KErrAccessDenied );
+        return;
+        }
+
+    TUsbDeviceState state = iActiveState->CurrentState();
+    LOG1( "Device state : %d", state );
+    if( state != EUsbDeviceStateUndefined )
+        {
+        iSetPreviousPersonalityOnDisconnect = ETrue;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method starts personality change, if there is cable connected.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::SwitchPersonality( TBool aNonBlocking )
+    {
+    LOG_FUNC
+
+
+    TUsbDeviceState state = iActiveState->CurrentState();
+    LOG2( "IsDeviceA: %d, Device state : %d", IsDeviceA(), state );
+
+    // As A-device, only cenrep will be updated for the reasons of
+    // - In A-host state, device state will be undefined 
+    // - In A-peripheral state, personality change can not happen otherwise 
+    // the connection will be lost
+    if ( IsDeviceA() || ( EUsbDeviceStateUndefined == state ) )
+        {
+        // if no connection -> just save the setting
+        LOG( "CUsbWatcher::SwitchPersonality: Notify" );
+        Notify( KErrNone );
+        }
+    else
+        {
+        switch ( iState )
+            {
+            case EUsbStopping:
+            case EUsbStarting:
+                {
+                LOG( "CUsbWatcher::SwitchPersonality: Cancel & Start USB" );
+                Cancel();
+                Start();
+                }
+                break;
+            case EUsbConfirmStop:
+                {
+                Cancel();
+                iState = EUsbStarted;
+                StopStart( aNonBlocking );
+                }
+                break;
+            case EUsbStarted:
+                {
+                LOG( "CUsbWatcher::SwitchPersonality: Stop & Start USB" );
+                StopStart( aNonBlocking );
+                }
+                break;
+            default:
+                {
+                LOG( "CUsbWatcher::SwitchPersonality: Start USB" );
+                Start();
+                }
+                break;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method starts personality loading or continues stop start scenario.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Start()
+    {
+    LOG_FUNC
+
+    TInt globalState = CUsbGlobalSystemStateObserver::GlobalSystemState();
+
+    if( iState == EUsbIdle )
+        {
+        iStarted = EFalse;
+        iNormalStart = EFalse;
+        if( globalState == ESwStateCharging )
+            {
+            LOG( "Global state: charging" );
+            iGlobalStateObserver->Subscribe();
+            iPrevPersonalityId=iPersonalityId;
+            TInt ret = GetChargingPersonalityId( iPersonalityId );
+            //do not start if charging personality not assigned
+            if( KErrNone == ret )
+                {
+                RProperty::Set( KPSUidUsbWatcher,
+                        KUsbWatcherSelectedPersonality, iPersonalityId );
+                iStarted = ETrue;
+                // Restore personality to normal in charging mode
+                iSetPreviousPersonalityOnDisconnect = ETrue;
+                iPersonalityHandler->StartPersonality( iPersonalityId,
+                    KUsbWatcherChangeOnConnectionOff, iStatus );
+                }
+            else
+                {
+                LOG1( "GetChargingPersonalityId = %d. Not started", ret );
+                }
+            }
+        else if( ( ( ESwStateNormalRfOn == globalState ) ||
+                   ( ESwStateNormalRfOff == globalState ) ||
+                   ( ESwStateNormalBTSap == globalState ) ))
+            {
+            LOG( "Global state: normal" );
+            iNormalStart = ETrue;
+            if( ! iUsbDeviceLock->Locked() )
+                {
+                iGlobalStateObserver->Cancel();
+                RProperty::Set( KPSUidUsbWatcher,
+                            KUsbWatcherSelectedPersonality, iPersonalityId );
+                iStarted = ETrue;
+                iPersonalityHandler->StartPersonality( iPersonalityId,
+                        iAskOnConnectionSetting, iStatus );
+                }
+            else
+                {
+                LOG( "Device LOCKED, USB personality NOT start" );
+                }
+            }
+        else
+            {
+            LOG1( "Global state: = %d", globalState );
+            //Cable connected in e.g. ChargingToNormal state and
+            // personality started later in a normal state.
+            iGlobalStateObserver->Subscribe();
+            }
+        if( iStarted )
+            {
+            SetActive();
+            iState = EUsbStarting;
+            }
+        }
+    else
+        {
+        LOG( "Tryign to call CUsbWatcher::Start in non-idle state " );
+        PANIC( KErrGeneral );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method starts personality unloading or cancels personality start.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Stop()
+    {
+    LOG_FUNC
+
+    LOG1( "WatcherState = %d", iState );
+    if( EUsbStarted == iState )
+        {
+        iPersonalityHandler->StopPersonality( iStatus );
+        SetActive();
+        iState = EUsbStopping;
+        
+        }
+    else if( EUsbStarting  == iState )
+        {
+        LOG( "Cancel ongoing start." );
+        Cancel();
+        }
+    
+    else
+        {
+        LOG( "Wrong state for Stop" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is used when there is need to change currently loaded
+// personality.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::StopStart( TBool aNonBlocking )
+    {
+    LOG_FUNC
+
+    LOG1( "WatcherState = %d", iState );
+    if( iState == EUsbStarted )
+        {
+        iState = EUsbConfirmStop;
+        if( !aNonBlocking )
+            {
+            iPersonalityHandler->ConfirmPersonalityUnload( iStatus );
+            SetActive();
+            }
+        else
+            {
+            LOG( "CUsbWatcher::StopStart not confirming" );
+            SetActive();
+            TRequestStatus* status = &iStatus;
+            User::RequestComplete( status, KErrNone );
+            }
+        }
+    else
+        {
+        LOG( "Wrong state to StopStart" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbWatcherSession uses this method to register observer.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::RegisterObserverL( MUsbWatcherNotify* aObserver )
+    {
+    LOG_FUNC
+
+    TInt index = iObservers.Find( aObserver );
+    if( index < 0 )
+        {
+        iObservers.AppendL( aObserver );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbWatcherSession uses this method to deregister observer.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::DeRegisterObserver( MUsbWatcherNotify* aObserver )
+    {
+    LOG_FUNC
+
+    TInt index = iObservers.Find( aObserver );
+
+    if( index >= 0 )
+        {
+        iObservers.Remove( index );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// This method is used to complete any outstanding request.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Notify( TInt aStatus )
+    {
+    LOG_FUNC
+
+    LOG1( "aStatus = %d", aStatus );
+    TInt status = aStatus;
+
+    // clear every time when notified
+    iPersonalityChangeOngoing = EFalse;
+
+    if( iSetPersonalityOngoing || iChangePersonalityOngoing )
+        {
+        iSetPersonalityOngoing = EFalse;
+        iChangePersonalityOngoing = EFalse;
+
+        if( status == KErrNone )
+            {
+            status = WritePersonalityId( iPersonalityId );
+            }
+        else
+            {
+            // in case of error return to state before SetPersonality
+            iPersonalityId = iPrevPersonalityId;
+            iPrevPersonalityId = iOldPrevPersonalityId;
+            }
+        }
+
+    if( iSetPreviousPersonalityOngoing )
+        {
+        iSetPreviousPersonalityOngoing = EFalse;
+
+        if( status == KErrNone )
+            {
+            WritePersonalityId( iPersonalityId );
+            }
+        else
+            {
+            // in case of error return to state before SetPreviousPersonality
+            TInt temp = iPrevPersonalityId;
+
+            iPrevPersonalityId = iPersonalityId;
+            iPersonalityId = temp;
+            }
+        }
+
+    for( TInt i = 0; i < iObservers.Count(); i++ )
+        {
+        iObservers[i]->Notify( iPersonalityId, status );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Stop loaded personality. Called from global state handler
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::StopPersonality()
+    {
+    LOG_FUNC
+    // restore settings
+    iPersonalityId = iPrevPersonalityId;
+
+    Stop();
+    iStarted = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// Start personality. Called from global state handler
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::StartPersonality()
+    {
+    LOG_FUNC
+
+    if( !iStarted )
+        {
+        Start();
+        }
+
+    //start usbdevcon only in normal global state
+    TInt globalState = CUsbGlobalSystemStateObserver::GlobalSystemState();
+    if( ( globalState == ESwStateNormalRfOn ) ||
+            ( globalState == ESwStateNormalRfOff ) ||
+            ( globalState == ESwStateNormalBTSap ) )
+        {
+        iUsbDevConStarter->Start();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Read default personality from ini file. Used in charging mode
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId )
+    {
+    LOG_FUNC
+
+    TInt ret = iPersonalityRepository->Get(
+            KUsbWatcherChargingDefaultPersonality, aPersonalityId );
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Check if there is an observer with ask on connection suppression
+// ----------------------------------------------------------------------------
+//
+TBool CUsbWatcher::IsAskOnConnectionSuppression()
+    {
+    LOG_FUNC
+    
+    TBool ret( EFalse );
+    for( TInt i = 0; i < iObservers.Count(); i++ )
+        {
+        if( iObservers[i]->IsAskOnConnectionSuppressed() )
+            {
+            ret = ETrue;
+            break;
+            }
+        }
+    LOG1( "Return = %d", ret );
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Check current A or B device state
+// ----------------------------------------------------------------------------
+//
+TBool CUsbWatcher::IsDeviceA()
+    {
+    //NOT LOGGED
+    // return EFalse in non-OTG configuration otherwise ask UsbOtgWatcher
+    return iOtgWatcher ? iOtgWatcher->IsDeviceA() : EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// Write new personality to central repository.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId )
+    {
+    LOG_FUNC
+    
+    // Save as the default personality only if it is not hidden
+    TUint32 property(0);
+    TInt ret =  iUsbMan.GetPersonalityProperty( aPersonalityId, property );
+    if ( ret == KErrNone )
+        {
+        LOG2( "Personality %d property: 0x%x", aPersonalityId, property );
+        }
+    else
+        {
+        //Not fatal, treat as non-hidden
+        LOG1( "ERROR: GetPersonalityProperty = %d", ret );
+        property = 0;
+        }
+    if ( property & KUsbPersonalityPropertyHidden ) //Bitwise AND
+        {
+        LOG( "Hidden personality not saved to central repository" );
+        ret = KErrNone;
+        }
+    else
+        {
+        ret =  iPersonalityRepository->Set( KUsbWatcherPersonality,
+            aPersonalityId );
+        }
+    return ret;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbwatcherscheduler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2002-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 class reports possible scheduling errors to server.
+*
+*/
+
+
+#include "cusbwatcherscheduler.h"
+#include "cusbwatcherserver.h"
+#include "debug.h"
+
+// ----------------------------------------------------------------------------
+// Symbian two-phase constructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherScheduler* CUsbWatcherScheduler::NewL()
+    {
+    LOG_FUNC
+
+    CUsbWatcherScheduler* self = new( ELeave ) CUsbWatcherScheduler;
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherScheduler::~CUsbWatcherScheduler()
+    {
+    LOG_FUNC
+
+    }
+
+// ----------------------------------------------------------------------------
+// Set server
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherScheduler::SetServer( CUsbWatcherServer& aServer )
+    {
+    LOG_FUNC
+
+    iServer = &aServer;
+    }
+
+// ----------------------------------------------------------------------------
+// Error handle
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherScheduler::Error( TInt aError ) const
+    {
+    LOG_FUNC
+
+    LOG1( "aError = %d", aError );
+    if (iServer)
+        {
+        iServer->Error( aError );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbwatcherserver.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* 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:  USB Watcher server class implementation.
+*
+*/
+
+
+#include <e32svr.h>
+#include "usbwatchershared.h"
+#include "cusbwatcherserver.h"
+#include "cusbwatchersession.h"
+#include "usbwatcherserversecuritypolicy.h"
+#include "cusbwatcher.h"
+#include "debug.h"
+
+// ----------------------------------------------------------------------------
+// Symbian two-phase constructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherServer* CUsbWatcherServer::NewLC()
+    {
+    LOG_FUNC
+
+    CUsbWatcherServer* r = new ( ELeave ) CUsbWatcherServer();
+    CleanupStack::PushL( r );
+    r->StartL( KUsbWatcherServerName );
+    r->ConstructL();
+    return r;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherServer::~CUsbWatcherServer()
+    {
+    LOG_FUNC
+
+    delete iUsbWatcher;
+    }
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherServer::CUsbWatcherServer()
+     : CPolicyServer( EPriorityHigh, KUsbWatcherServerPolicy )
+    {
+    LOG_FUNC
+
+    }
+
+// ----------------------------------------------------------------------------
+// Second-phase constructor
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherServer::ConstructL()
+    {
+    LOG_FUNC
+
+    iUsbWatcher = CUsbWatcher::NewL();
+    }
+
+// ----------------------------------------------------------------------------
+// Create a new session
+// ----------------------------------------------------------------------------
+//
+CSession2* CUsbWatcherServer::NewSessionL( const TVersion &aVersion,
+        const RMessage2& aMessage ) const
+    {
+    LOG_FUNC
+
+    (void)aMessage;//Remove compiler warning
+
+    TVersion v( KUsbWatcherSrvMajorVersionNumber,
+        KUsbWatcherSrvMinorVersionNumber, KUsbWatcherSrvBuildVersionNumber );
+
+    if ( !User::QueryVersionSupported( v, aVersion ) )
+        {
+        LEAVE( KErrNotSupported );
+        }
+
+    CUsbWatcherServer* ncThis = const_cast< CUsbWatcherServer* >( this );
+
+    CUsbWatcherSession* sess = CUsbWatcherSession::NewL( ncThis );
+
+    return sess;
+    }
+
+// ----------------------------------------------------------------------------
+// Error handle
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherServer::Error( TInt aError )
+    {
+    LOG_FUNC
+
+    LOG1( "Error = %d", aError );
+    Message().Complete( aError );
+    LOG( "Restarting..." );
+    ReStart();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbwatchersession.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,348 @@
+/*
+* 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:  USB Watcher session class implementation.
+*
+*/
+
+
+#include "cusbwatchersession.h"
+#include "usbwatchershared.h"
+#include "cusbwatcher.h"
+#include "cusbwatcherserver.h"
+#include "debug.h"
+
+// ----------------------------------------------------------------------------
+// Symbian two-phase constructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherSession* CUsbWatcherSession::NewL( CUsbWatcherServer* aServer )
+    {
+    LOG_FUNC
+
+    CUsbWatcherSession* r = new ( ELeave ) CUsbWatcherSession( aServer );
+    CleanupStack::PushL( r );
+    r->ConstructL();
+    CleanupStack::Pop();
+    return r;
+    }
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherSession::CUsbWatcherSession( CUsbWatcherServer* aServer )
+    : iUsbWatcherServer( aServer )
+    {
+    LOG_FUNC
+
+    }
+
+// ----------------------------------------------------------------------------
+// Second-phase constructor
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherSession::ConstructL()
+    {
+    LOG_FUNC
+
+    iUsbWatcherServer->Watcher().RegisterObserverL( this );
+    }
+
+// ----------------------------------------------------------------------------
+// Desstructor
+// ----------------------------------------------------------------------------
+//
+CUsbWatcherSession::~CUsbWatcherSession()
+    {
+    LOG_FUNC
+
+    // if server isn't exist then session can not be exist
+    if ( iUsbWatcherServer )
+        {
+        iUsbWatcherServer->Watcher().DeRegisterObserver( this );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Request handle entry point
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherSession::ServiceL( const RMessage2& aMessage )
+    {
+    LOG_FUNC
+
+    DispatchMessageL( aMessage );
+    }
+
+// ----------------------------------------------------------------------------
+// Request dispatch function
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherSession::DispatchMessageL( const RMessage2& aMessage )
+    {
+    LOG_FUNC
+
+    LOG1( "Message = %d", aMessage.Function() );
+
+    TBool complete( ETrue );
+    TInt ret( KErrNone );
+
+
+    switch ( aMessage.Function() )
+        {
+        case EUsbWatcherSetPersonality:
+            ret = SetPersonality( aMessage, complete );
+            break;
+
+        case EUsbWatcherCancelSetPersonality:
+            ret = CancelSetPersonality( aMessage, complete );
+            break;
+
+        case EUsbWatcherSetPreviousPersonality:
+            ret = SetPreviousPersonality( aMessage, complete );
+            break;
+
+        case EUsbWatcherSetPreviousPersonalitySync:
+            ret = SetPreviousPersonalitySync( aMessage, complete );
+            break;
+
+        case EUsbWatcherCancelSetPreviousPersonality:
+            ret = CancelSetPreviousPersonality( aMessage, complete );
+            break;
+
+        case EUsbWatcherSetPreviousPersonalityOnDisconnect:
+            ret = SetPreviousPersonalityOnDisconnect( aMessage, complete );
+            break;
+
+        default:
+            aMessage.Panic( KUsbWatcherCliPncCat, EUsbWatcherPanicIllegalIPC );
+            break;
+        }
+
+    if ( complete )
+        {
+        aMessage.Complete( ret );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Set certain personality
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::SetPersonality( const RMessage2& aMessage,
+        TBool& aComplete )
+    {
+    LOG_FUNC
+
+    if( iSetPersonalityOutstanding )
+        {
+        LOG( "Completing outstanding" );
+        iSetPersonalityMessage.Complete( KErrNone );
+        iSetPersonalityOutstanding = EFalse;
+        }
+
+    // Cancel all other pending requests
+    iUsbWatcherServer->Watcher().Notify( KErrCancel );
+
+    iSetPersonalityMessage = aMessage;
+    aComplete = EFalse;
+    iSetPersonalityOutstanding = ETrue;
+
+    //Set force parameter to this session.
+    SetAskOnConnectionSuppression( aMessage.Int1() );
+
+    iUsbWatcherServer->Watcher().SetPersonality( aMessage.Int0(),
+        static_cast<TBool>( aMessage.Int2() ) );
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel pending set personality request
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::CancelSetPersonality( const RMessage2& aMessage,
+        TBool& aComplete )
+    {
+    LOG_FUNC
+
+    if ( !iSetPersonalityOutstanding )
+        {
+        LOG( "No outstanding SetPersonality request" );
+        return KErrNone;
+        }
+
+    SetAskOnConnectionSuppression( EFalse );
+    aComplete = EFalse;
+    iCancelSetPersonalityMessage = aMessage;
+    iCancelSetPersonalityOutstanding = ETrue;
+
+    iUsbWatcherServer->Watcher().CancelSetPersonality();
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Change to previous personality, asynchronous version
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::SetPreviousPersonality( const RMessage2& aMessage,
+        TBool& aComplete )
+    {
+    LOG_FUNC
+
+    if( iSetPreviousPersonalityOutstanding )
+        {
+        iSetPreviousPersonalityMessage.Complete( KErrNone );
+        iSetPreviousPersonalityOutstanding = EFalse;
+        }
+
+    // Cancel all other pending requests
+    iUsbWatcherServer->Watcher().Notify( KErrCancel );
+
+    SetAskOnConnectionSuppression( EFalse );
+    iSetPreviousPersonalityOutstanding = ETrue;
+    iSetPreviousPersonalityMessage = aMessage;
+    aComplete = EFalse;
+
+    iUsbWatcherServer->Watcher().SetPreviousPersonality();
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Change to previous personality, synchronous version
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::SetPreviousPersonalitySync( const RMessage2& /*aMsg*/,
+        TBool& /*aComplete*/ )
+    {
+    LOG_FUNC
+
+    if( iSetPreviousPersonalityOutstanding )
+        {
+        iSetPreviousPersonalityMessage.Complete( KErrNone );
+        iSetPreviousPersonalityOutstanding = EFalse;
+        }
+
+    // Cancel all other pending requests
+    iUsbWatcherServer->Watcher().Notify( KErrCancel );
+
+    SetAskOnConnectionSuppression( EFalse );
+    iUsbWatcherServer->Watcher().SetPreviousPersonality();
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel pending request to set previous personality
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::CancelSetPreviousPersonality( const RMessage2& aMsg,
+        TBool& aComplete )
+    {
+    LOG_FUNC
+
+    if( !iSetPreviousPersonalityOutstanding )
+        {
+        return KErrNone;
+        }
+
+    aComplete = EFalse;
+    iCancelSetPreviousPersonalityMessage = aMsg;
+    iCancelSetPreviousPersonalityOutstanding = ETrue;
+
+    iUsbWatcherServer->Watcher().CancelSetPreviousPersonality();
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Set the flag to restore personality when disconnected
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcherSession::SetPreviousPersonalityOnDisconnect( const RMessage2&
+        /*aMessage*/, TBool& /*aComplete*/ )
+    {
+    LOG_FUNC
+
+    //connected currently, so ask on connection can be enabled
+    SetAskOnConnectionSuppression( EFalse );
+    iUsbWatcherServer->Watcher().SetPreviousPersonalityOnDisconnect();
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Complete request
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherSession::Notify( TInt /*aPersonalityId*/, TInt aStatus )
+    {
+    LOG_FUNC
+
+    if( iCancelSetPersonalityOutstanding )
+        {
+        iCancelSetPersonalityOutstanding = EFalse;
+        iCancelSetPersonalityMessage.Complete( KErrNone );
+
+        iSetPersonalityMessage.Complete( aStatus );
+        iSetPersonalityOutstanding = EFalse;
+        }
+
+    if ( iSetPersonalityOutstanding )
+        {
+        iSetPersonalityMessage.Complete( aStatus );
+        iSetPersonalityOutstanding = EFalse;
+        }
+
+    if ( iCancelSetPreviousPersonalityOutstanding )
+        {
+        iCancelSetPreviousPersonalityOutstanding = EFalse;
+        iCancelSetPreviousPersonalityMessage.Complete( KErrNone );
+
+        iSetPreviousPersonalityMessage.Complete( aStatus );
+        iSetPreviousPersonalityOutstanding = EFalse;
+        }
+
+    if ( iSetPreviousPersonalityOutstanding )
+        {
+        iSetPreviousPersonalityMessage.Complete( aStatus );
+        iSetPreviousPersonalityOutstanding = EFalse;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Set or clear AskOnConnection suppression
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcherSession::SetAskOnConnectionSuppression( TBool aSuppress )
+    {
+    LOG_FUNC
+
+    iSuppressAskOnConnection = aSuppress;
+    }
+
+// ----------------------------------------------------------------------------
+// Check if AskOnConnection is suppressed
+// ----------------------------------------------------------------------------
+//
+TBool CUsbWatcherSession::IsAskOnConnectionSuppressed()
+    {
+    LOG_FUNC
+
+    return iSuppressAskOnConnection;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/rusbwatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* 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:  This class implements UsbWatcher Server API
+*
+*/
+
+#include <e32uid.h>
+#include <e32base.h>
+#include <usb.h>
+#include <usbwatcher.h>
+#include "rusbwatcher.h"
+#include "usbwatchershared.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RUsbWatcher::RUsbWatcher()
+    {
+    LOG_FUNC
+    
+    }
+
+// ---------------------------------------------------------------------------
+// C++ default destructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RUsbWatcher::~RUsbWatcher()
+    {
+    LOG_FUNC
+
+    }
+
+// ---------------------------------------------------------------------------
+// Server version.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TVersion RUsbWatcher::Version() const
+    {
+    LOG_FUNC
+
+    return( TVersion( KUsbWatcherSrvMajorVersionNumber,
+            KUsbWatcherSrvMinorVersionNumber,
+            KUsbWatcherSrvBuildVersionNumber ) );
+    }
+
+// ---------------------------------------------------------------------------
+// Creates session to UsbWatcher server.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RUsbWatcher::Connect()
+    {
+    LOG_FUNC
+    
+    return CreateSession( KUsbWatcherServerName, Version(), 10 );
+    }
+    
+// ---------------------------------------------------------------------------
+// Set new personality. If USB cable is connected change will happen
+// immediately.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::SetPersonality( TRequestStatus& aStatus, 
+    TInt aPersonalityId, TBool aForce, TBool aNonBlocking )
+    {   
+    LOG_FUNC
+
+    TIpcArgs ipcArgs( aPersonalityId, aForce, aNonBlocking );
+    SendReceive( EUsbWatcherSetPersonality, ipcArgs, aStatus );
+    }
+    
+// ---------------------------------------------------------------------------
+// Cancel setting of new personality. 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::CancelSetPersonality()
+    {
+    LOG_FUNC
+
+    SendReceive( EUsbWatcherCancelSetPersonality );
+    }
+
+// ---------------------------------------------------------------------------
+// Set previous personality. 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::SetPreviousPersonality( TRequestStatus& aStatus )
+    {
+    LOG_FUNC
+
+    SendReceive( EUsbWatcherSetPreviousPersonality, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Set previous personality synchronously. Request is completed before
+// it has been finished.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::SetPreviousPersonality()
+    {
+    LOG_FUNC
+
+    SendReceive( EUsbWatcherSetPreviousPersonalitySync );
+    }
+
+// ---------------------------------------------------------------------------
+// Cancel setting of previous personality. 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::CancelSetPreviousPersonality()
+    {
+    LOG_FUNC
+
+    SendReceive( EUsbWatcherCancelSetPreviousPersonality );
+    }
+
+// ---------------------------------------------------------------------------
+// Set previous personality when cable is disconnected. This will do nothing
+// if cable isn't connected.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RUsbWatcher::SetPreviousPersonalityOnDisconnect()
+    {
+    LOG_FUNC
+
+    SendReceive( EUsbWatcherSetPreviousPersonalityOnDisconnect );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/tusbindicatorhandler.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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:  This implements TUsbIndicatorHandler class.
+*
+*/
+
+
+#include <e32std.h>
+#include <AknNotifySignature.h> // SAknNotifierPackage
+#include <avkon.hrh> //EAknIndicatorUSBConnection
+#include "tusbindicatorhandler.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// C++ Constructor 
+// ---------------------------------------------------------------------------
+//
+TUsbIndicatorHandler::TUsbIndicatorHandler() 
+    : iDevStateB4Suspend( EUsbDeviceStateUndefined )
+    , iUsbIndicator(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Change USB Indicator 
+// ---------------------------------------------------------------------------
+//
+void TUsbIndicatorHandler::HandleDeviceStateChange( TUsbDeviceState aStateOld, 
+            TUsbDeviceState aStateNew )
+    {
+    LOG_FUNC
+
+    LOG2( "USB device state changed: %d ==> %d", aStateOld, aStateNew );
+    
+    if ( EUsbDeviceStateConfigured == aStateNew ) // Entering configed state 
+        {
+        // filter out case of configed -> suspended -> configed
+        if ( ( EUsbDeviceStateSuspended != aStateOld ) || 
+             ( EUsbDeviceStateConfigured != iDevStateB4Suspend) )
+            {
+            ShowUsbIndicator( ETrue );
+            }
+        }
+    else if ( EUsbDeviceStateSuspended == aStateNew )
+    // If current state is suspend, we do not change the indicator, but save
+    // the previous state
+        {
+        iDevStateB4Suspend = aStateOld;
+        }
+    else // New device state is not configured, nor suspended
+        {
+        // Hide USB indicator if previous state is either configured, or
+        // suspended AND state before is not configured
+        if( ( EUsbDeviceStateConfigured == aStateOld ) ||
+            ( ( EUsbDeviceStateSuspended == aStateOld ) &&
+              ( EUsbDeviceStateConfigured == iDevStateB4Suspend ) ) ) 
+            {
+            ShowUsbIndicator( EFalse );
+            }
+        } 
+    }
+    
+// ---------------------------------------------------------------------------
+// Show USB Indicator
+// ---------------------------------------------------------------------------
+//
+void TUsbIndicatorHandler::ShowUsbIndicator( TInt aUsbIndicatorState )
+    {
+    LOG_FUNC
+    
+    iUsbIndicator = aUsbIndicatorState;
+    LOG1( "USB indicator state %d", aUsbIndicatorState );
+    RNotifier notifier;
+    TInt err = notifier.Connect();
+    if ( KErrNone == err )
+        {
+        TPckgBuf< SAknNotifierPackage<SAknSmallIndicatorParams> > pckg;
+        pckg().iParamData.iSmallIndicatorUid =
+            TUid::Uid( EAknIndicatorUSBConnection );
+        pckg().iParamData.iValue = aUsbIndicatorState ? 
+            EAknIndicatorStateOn : EAknIndicatorStateOff ;
+        notifier.StartNotifier( KAknSmallIndicatorUid, pckg );
+        notifier.Close();
+        }
+    else
+        {
+        LOG1( "RNotifier::Connect error: %d", err );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/tusbpersonalityparams.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* 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:  Container class for personalities
+*
+*/
+
+
+#include <usbman.h>
+#include <cusbpersonalitynotifier.h>
+#include <tusbpersonalityparams.h>
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TUsbPersonalityParams::TUsbPersonalityParams( RUsb& aUsbMan,
+    CUsbPersonalityNotifier& aPersonalityNotifier )
+    : iUsbMan( aUsbMan ),
+      iPersonalityNotifier( aPersonalityNotifier )
+    {
+    LOG_FUNC
+	
+    }
+    
+// ---------------------------------------------------------------------------
+// C++ default destructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TUsbPersonalityParams::~TUsbPersonalityParams()
+    {
+    LOG_FUNC
+	
+    }
+    
+// ---------------------------------------------------------------------------
+// Handle to USB Manager.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RUsb& TUsbPersonalityParams::UsbMan() const
+    {
+    LOG_FUNC
+	
+    return iUsbMan;
+    }
+    
+// ---------------------------------------------------------------------------
+// Handle to personality notifier.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUsbPersonalityNotifier& TUsbPersonalityParams::PersonalityNotifier() 
+	const
+    {
+    LOG_FUNC
+	
+    return iPersonalityNotifier;    
+    }
+
+// ---------------------------------------------------------------------------
+// Set personality id. Set is done by CUsbActivePersonalityHandler.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void TUsbPersonalityParams::SetPersonalityId( TInt aPersonalityId )
+    {
+    LOG_FUNC
+	
+    iPersonalityId = aPersonalityId;
+    }
+
+// ---------------------------------------------------------------------------
+// Currently loaded personality's id.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TUsbPersonalityParams::PersonalityId() const
+    {
+    LOG_FUNC
+	
+    return iPersonalityId;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/usbman_pcs.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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:  Resource file for usbman configuration.
+*
+*/
+
+
+NAME USBM
+
+#include <badef.rh>
+#include <bldvariant.hrh>
+#include <usbpersonalityids.h>
+#include <usbman.loc>
+#include "usbman.rh"
+#include "usbvariation.rh"
+
+RESOURCE BA_RSS_SIGNATURE
+    {
+    signature = 3;
+    }
+
+RESOURCE usb_configuration usb_config
+    {
+    }
+    
+        
+RESOURCE PERSONALITY_ARRAY device_personalities
+    {
+    personalities = 
+        {
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PCSuite;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPCSuite;
+            class_uids = "101fbf22, 101fbf24, 10281F2A, 101FB43A";
+            description = qtn_usb_mode_ovisuite;
+            detailedDescription = qtn_usb_mode_msg_ovi_suite;
+            property = 0x00000000;
+			
+
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MassStorage;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMS;
+            class_uids = "10204bbc";
+            description = qtn_usb_mode_mass_storage;
+            detailedDescription = qtn_usb_mode_msg_mass_storage;
+            property = 0x00000000;
+			
+
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_RNDIS;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdRNDIS;
+            class_uids = "20013d2f";
+            description = qtn_usb_mode_rndis;
+            detailedDescription = qtn_usb_mode_msg_rndis;
+            property = 0x00000001;
+            }
+        };
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/usbman_pcsmtp.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,118 @@
+/*
+* 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:  Resource file for usbman configuration.
+*
+*/
+
+
+NAME USBM
+
+#include <badef.rh>
+#include <bldvariant.hrh>
+#include <usbpersonalityids.h>
+#include <usbman.loc>
+#include "usbman.rh"
+#include "usbvariation.rh"
+
+
+
+RESOURCE BA_RSS_SIGNATURE
+    {
+    signature = 3;
+    }
+
+RESOURCE usb_configuration usb_config
+    {
+    }
+    
+        
+RESOURCE PERSONALITY_ARRAY device_personalities
+    {
+    personalities = 
+        {
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PCSuiteMTP;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPCSuiteMTP;
+            class_uids = "102827B3, 101fbf22, 101fbf24, 10281F2A, 101FB43A";
+            description = qtn_usb_mode_ovisuite_mtp;
+            detailedDescription = qtn_usb_mode_msg_ovi_suite;
+            property = 0x00000000;
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MassStorage;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMS;
+            class_uids = "10204bbc";
+            description = qtn_usb_mode_mass_storage;
+            detailedDescription = qtn_usb_mode_msg_mass_storage;
+            property = 0x00000000;
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MediaTransfer;  
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMTP;
+            class_uids = "102827B3";
+            description = qtn_usb_mode_mtp;
+            detailedDescription = qtn_usb_mode_msg_mtp;
+            property = 0x00000000;
+            }
+		,
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_RNDIS;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdRNDIS;
+            class_uids = "20013d2f";
+            description = qtn_usb_mode_rndis;
+            detailedDescription = qtn_usb_mode_msg_rndis;
+            property = 0x00000001;
+            }
+        };
+    }
+            
+// End o file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/usbman_pcsmtppam.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* 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:  Resource file for usbman configuration.
+*
+*/
+
+
+NAME USBM
+
+#include <badef.rh>
+#include <bldvariant.hrh>
+#include <usbpersonalityids.h>
+#include <usbman.loc>
+#include "usbman.rh"
+#include "usbvariation.rh"
+
+
+RESOURCE BA_RSS_SIGNATURE
+    {
+    signature = 3;
+    }
+
+RESOURCE usb_configuration usb_config
+    {
+    }
+    
+        
+RESOURCE PERSONALITY_ARRAY device_personalities
+    {
+    personalities = 
+        {
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PCSuiteMTP;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPCSuiteMTP;
+            class_uids = "102827B3, 101fbf22, 101fbf24, 10281F2A, 101FB43A";
+            description = qtn_usb_mode_ovisuite_mtp;
+            detailedDescription = qtn_usb_mode_msg_ovi_suite;
+            property = 0x00000000;
+			
+
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MassStorage;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMS;
+            class_uids = "10204bbc";
+            description = qtn_usb_mode_mass_storage;
+            detailedDescription = qtn_usb_mode_msg_mass_storage;
+            property = 0x00000000;
+			
+
+            }
+#ifdef __USB_PTP        
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PTP;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPTP;
+            class_uids = "1020df81";
+            description = qtn_usb_mode_ptp;
+            detailedDescription = qtn_usb_mode_msg_ptp;
+            property = 0x00000000;
+			
+
+            }
+#endif // __USB_PTP
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MediaTransfer;  
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMTP;
+            class_uids = "102827B3";
+            description = qtn_usb_mode_mtp;
+            detailedDescription = qtn_usb_mode_msg_mtp;
+            property = 0x00000000;
+			
+
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_ModemInstall;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdModemInst;                   
+            class_uids = "2000FDA9";            
+            description = qtn_usb_mode_quickconnect;
+            detailedDescription = qtn_usb_mode_msg_pam;
+            property = 0x00000000;
+            }
+	    ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_RNDIS;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdRNDIS;
+            class_uids = "20013d2f";
+            description = qtn_usb_mode_rndis;
+            detailedDescription = qtn_usb_mode_msg_rndis;
+            property = 0x00000001;
+            }
+        };
+    }
+            
+// End o file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/usbman_pcspam.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,142 @@
+/*
+* 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:  Resource file for usbman configuration.
+*
+*/
+
+
+NAME USBM
+
+#include <badef.rh>
+#include <bldvariant.hrh>
+#include <usbpersonalityids.h>
+#include <usbman.loc>
+#include "usbman.rh"
+#include "usbvariation.rh"
+
+RESOURCE BA_RSS_SIGNATURE
+    {
+    signature = 3;
+    }
+
+RESOURCE usb_configuration usb_config
+    {
+    }
+    
+        
+RESOURCE PERSONALITY_ARRAY device_personalities
+    {
+    personalities = 
+        {
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PCSuite;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPCSuite;
+            class_uids = "101fbf22, 101fbf24, 10281F2A, 101FB43A";
+            description = qtn_usb_mode_ovisuite;
+            detailedDescription = qtn_usb_mode_msg_ovi_suite;
+            property = 0x00000000;
+			
+
+            }
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_MassStorage;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdMS;
+            class_uids = "10204bbc";
+            description = qtn_usb_mode_mass_storage;
+            detailedDescription = qtn_usb_mode_msg_mass_storage;
+            property = 0x00000000;
+			
+
+            }
+#ifdef __USB_PTP
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_PTP;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdPTP;
+            class_uids = "1020df81";
+            description = qtn_usb_mode_ptp;
+            detailedDescription = qtn_usb_mode_msg_ptp;
+            property = 0x00000000;
+			
+
+            }
+#endif // __USB_PTP
+        ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x00;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_ModemInstall;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdModemInst;                   
+            class_uids = "2000FDA9";            
+            description = qtn_usb_mode_quickconnect;
+            detailedDescription = qtn_usb_mode_msg_pam;
+            property = 0x00000000;
+            }
+	    ,
+        PERSONALITY
+            {
+            bDeviceClass = 0x02;
+            bDeviceSubClass = 0x00;
+            protocol = 0x00;
+            numConfigurations = 0x01;
+            vendorId = per_vendorId;
+            productId = per_productId_RNDIS;
+            bcdDevice = per_bcdDevice;
+            manufacturer = per_manufacturer;
+            product = per_product;
+            id = KUsbPersonalityIdRNDIS;
+            class_uids = "20013d2f";
+            description = qtn_usb_mode_rndis;
+            detailedDescription = qtn_usb_mode_msg_rndis;
+            property = 0x00000001;
+            }
+        };
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/usbwatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2002-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:  Entry point for UsbWatcher
+*
+*/
+
+
+#include <c32comm.h>
+#include "cusbwatcher.h"
+#include "cusbwatcherscheduler.h"
+#include "cusbwatcherserver.h"
+#include "usbwatchershared.h"
+
+// LITERALS
+_LIT( KUsbWatcherName, "UsbWatcher" );
+
+// LOCAL FUNCTION PROTOTYPES
+static void StartUsbWatcherL();
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Entry-point for the USB Watcher.
+// ----------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    LOG_FUNC
+
+    // rename the thread so it is easy to find the panic application
+    TInt ret = User::RenameThread( KUsbWatcherName );
+    if( KErrNone != ret ) // Not fatal
+        {
+        LOG1( "ERROR: User::RenameThread = %d", ret );
+        }
+
+    __UHEAP_MARK;
+    // create clean-up stack
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+
+    TRAP( ret, StartUsbWatcherL() );
+    if ( KErrAlreadyExists == ret )
+        {
+        LOG( "UsbWatcher is already running." );
+        }
+    else if ( KErrNone != ret )
+        {
+        LOG1( "ERROR: StartUsbWatcherL = %d", ret );
+        }
+
+    delete cleanup; // destroy clean-up stack
+    __UHEAP_MARKEND;
+
+    LOG1( "E32Main = %d", ret );
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructs and installs the active scheduler, constructs USB Watcher's
+// objects.
+// ----------------------------------------------------------------------------
+//
+static void StartUsbWatcherL()
+    {
+    LOG_FUNC
+    LOG( "Starting USB Watcher..." );
+
+    LOG( "Create CUsbWatcherScheduler..." );
+    // Construct and install the active scheduler
+    CUsbWatcherScheduler *myScheduler = CUsbWatcherScheduler::NewL();
+
+    // Push onto the cleanup stack
+    CleanupStack::PushL( myScheduler );
+
+    LOG( "Install ActiveScheduler..." );
+    // Install as the active scheduler
+    CActiveScheduler::Install( myScheduler );
+
+    CUsbWatcherServer* usbwatcher;
+
+    LOG( "Create CUsbWatcherServer..." );
+    usbwatcher = CUsbWatcherServer::NewLC();
+    RProcess::Rendezvous(KErrNone);
+        
+    LOG( "Set server..." );
+	myScheduler->SetServer( *usbwatcher );
+
+
+    LOG( "Start Active scheduler..." );
+    CActiveScheduler::Start();
+
+    LOG( "Cleanup CUsbWatcherServer and CUsbWatcherScheduler ..." );
+    CleanupStack::PopAndDestroy( 2, myScheduler ); //usbwatcher, myScheduler
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Includes all the Domain API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../pictbridge_api/group/bld.inf"
+#include "../ptp_responder_api/group/bld.inf"
+//#include "../ptp_server_api/group/bld.inf"
+#include "../ptp_transport_api/group/bld.inf"
+#include "../usb_device_control_plugin_api/group/bld.inf"
+#include "../usb_notifier_api/group/bld.inf"
+#include "../usb_personality_api_header/group/bld.inf"
+#include "../usb_personality_plugin_api/group/bld.inf"
+#include "../usb_secondary_display_api/group/bld.inf"
+#include "../usb_watcher_api/group/bld.inf"
+#include "../usb_watcher_info_api_header/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/pictbridge_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  File that exports the files belonging to 
+:                PictBridge API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/pictbridge.h     MW_LAYER_PLATFORM_EXPORT_PATH(pictbridge.h)
+../inc/dpsdefs.h     MW_LAYER_PLATFORM_EXPORT_PATH(dpsdefs.h)
+../inc/dpsparam.h     MW_LAYER_PLATFORM_EXPORT_PATH(dpsparam.h)
+../inc/dpsoperation.h     MW_LAYER_PLATFORM_EXPORT_PATH(dpsoperation.h)
+../inc/dpsparam.inl     MW_LAYER_PLATFORM_EXPORT_PATH(dpsparam.inl)
+../inc/dpsoperation.inl     MW_LAYER_PLATFORM_EXPORT_PATH(dpsoperation.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/pictbridge_api/inc/dpsdefs.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/inc/dpsoperation.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/inc/dpsoperation.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/inc/dpsparam.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/inc/dpsparam.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/inc/pictbridge.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbservices_plat/pictbridge_api/pictbridge_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="30af62d3676a09e6f1176b4318c6b02d" dataversion="2.0">
+  <name>PictBridge API</name>
+  <description>Offers methods to print using PictBridge</description>
+  <type>c++</type>
+  <collection>usbclasses</collection>
+  <libs>
+    <lib name="pictbridge.lib" />
+  </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/usbservices_plat/ptp_responder_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  File that exports the files belonging to 
+:                PTP Responder API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_responder_api/ptp_responder_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="23c29ce864f56dbfb8731c2ce1e3e621" dataversion="2.0">
+  <name>PTP Responder API</name>
+  <description>Offers methods to use the Picture Transfer Protocol (PTP) including its extended functionality</description>
+  <type>c++</type>
+  <collection>usbclasses</collection>
+  <libs>
+    <lib name="ptpstack.lib" />
+  </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/usbservices_plat/ptp_server_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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 
+:                PTP Server API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/rptp.h     MW_LAYER_PLATFORM_EXPORT_PATH(rptp.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_server_api/inc/rptp.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,186 @@
+/*
+* 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:  An interface for starting PTP Server and connecting/
+*                disconnecting PTP Stack.
+*
+*/
+
+
+#ifndef  RPTP_H
+#define  RPTP_H
+
+#include <e32base.h>
+
+const TInt KFileExtLength = 8;
+enum TDpsPrinterState
+    {
+    EPrinterNotAvailable,
+    EPrinterAvailable
+    };
+        
+
+/**
+*  RPtp class is used to create a PTP Server session and a connection to the
+*  selected transport medium.
+*
+*  @lib rptp.lib
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS(RPtp) : public RSessionBase
+	{
+	
+public:
+
+	/**
+	* C++ default constructor.
+	*/
+	
+	IMPORT_C RPtp();
+	
+	/**
+	* Creates new session to PTP Server. This also register the observer
+	*  to the ptp server. This should be only used by the client other than
+	*   the Ptp CC
+	* @since S60 3.2
+	* @return KErrNone if success or system error if failed.
+	*/	
+	IMPORT_C TInt Connect();
+	
+	/**
+    * Creates connection to the server and initializes the ptp stack based on
+    * specified transport medium.
+    * @since S60 3.2
+    * @param aTransport, Implementation UID of selected transport medium.
+    * 
+    * @return KErrNone if success or system error if failed.
+    */
+	IMPORT_C TInt CreatePtpStack( const TUid aTransport );
+	
+	/**
+    * Performs DPS discovery.
+    * 
+    * @since S60 3.2
+    * @param aStatus the result of the Dps discovery, either EAvailable or
+    *   NotAvailable from TDpsPrinterState enum
+    */
+	IMPORT_C void IsDpsPrinter(TRequestStatus& aStatus);
+	
+	/**
+	* Cancels previously issued Asynch request IsDpsPrinter
+	* @since S60 3.2
+	*/
+	IMPORT_C void CancelIsDpsPrinter();
+		
+	/**
+	* Client sends object and get informed when the object is received by
+	* the host. 
+	* @since S60 3.2
+	* @param aNameAndPath, the name and full path of the file.
+	* @param aAdd  Whether the ObjectAdded event should be sent out for this
+	*   object (DPS operation may require this)
+	* @param aTimeout whether the client needs the reply for this request. If
+	*   it needs the timeout will be true, which means if timout happened, 
+	*   the reply is KErrTimedout
+	* @param aStatus, Asynchronous completion word for the operation.
+	*/
+	IMPORT_C void SendObject(const TDesC& aNameAndPath, 
+	                         TRequestStatus& aStatus, TBool aTimeout,
+	                         TInt aSize, TBool aAdd = EFalse);
+	
+	/**
+	* Cancel object sending request.
+	* @since S60 3.2
+	*/
+	IMPORT_C void CancelSendObject();
+		
+	/**
+	*   Registers the certain files arrival (from the host) notification. 
+	* @since S60 3.2
+	* @param aFileExtension.  file extension
+	* @param aNameAndPath  name and path of the file.
+	* @param aDelete whether this object should be deleted after the 
+	*  notification. If it is, a ObjectRemoved event should be sent also.
+	* (Dps operation may need this)
+	* @param aStatus, Asynchronous completion word for the operation.
+	* @return None.
+	*/
+	IMPORT_C void ObjectReceivedNotify(const TDesC& aFileExtension,
+	                                   TDes& aNameAndPath, 
+	                                   TRequestStatus& aStatus,
+	                                   TBool aDelete = EFalse);
+	
+	/**
+	* Gets the object handle (whether the object exists).
+	* The client may use this function to delete certain file 
+	* (mainly for dps now)  
+	* @since S60 3.2
+	* @param aNameAndPath, A name and full path of the file.
+	* @param aHandle , 32bit handle of the object
+	* @param aAdd if this object is not find whether add it to the list
+	* @return KErrNone if object is found or KErrNotFound if not.
+	*/
+	IMPORT_C TInt GetObjectHandleByName(const TDesC& aNameAndPath, 
+	                                    TUint32& aHandle, 
+	                                    TBool aAdd = EFalse);
+	
+	/**
+	* Function 
+	* @since S60 3.2
+	* @param aNameAndPath, A name and full path of the file.
+	* @param aHandle , 32bit handle of the objcet
+	* @return KErrNone if successfull or system error if failed
+	*/
+	IMPORT_C TInt GetNameByObjectHandle(TDes& aNameAndPath, 
+	                                    const TUint32 aHandle );
+	
+	
+	/**
+	* Cancel Object received notification 
+	* @since S60 3.2
+	*/
+	IMPORT_C void CancelObjectReceivedNotify();
+	
+	/**
+	* Disconnects PTP from transport module and deletes the PTP stack.
+	* @since S60 3.2
+	* Must be only used by PTP Class Controller
+	*/		
+	IMPORT_C void DestroyPtpStatck();
+	
+	/**
+	* Returns name and path of folder
+	* @since S60 3.2 
+	* @return Folder Name and Path
+	*/
+	IMPORT_C const TDesC& PtpFolder();
+    
+private:
+    
+    /**
+    * only used by the client other than PTP Class Controller. There are only two clients
+    * connects to the server at the same time. PTP Class Controller only starts and closes
+    * the PTP stack.As the result not DeRegisterObserver is needed.
+    * @since S60 3.2
+    *   @return KErrNone if success or system error if failed
+    */
+    TInt RegisterObserver();    
+    
+private:
+    
+    TBuf<KFileExtLength> iExt;
+    TFileName iFile;
+	};
+	
+#endif // RPTP_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_server_api/ptp_server_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="479dd805be8708928d6ecb8f091c299f" dataversion="2.0">
+  <name>PTP Server API</name>
+  <description>Offers methods to use the Picture Transfer Protocol (PTP) via  PTP server.</description>
+  <type>c++</type>
+  <collection>usbclasses</collection>
+  <libs>
+    <lib name="rptp.lib" />
+  </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/usbservices_plat/ptp_transport_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 
+:                PTP Transport API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/ptpcallbacks.h     MW_LAYER_PLATFORM_EXPORT_PATH(ptpcallbacks.h)
+../inc/ptptransport.h     MW_LAYER_PLATFORM_EXPORT_PATH(ptptransport.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_transport_api/inc/ptpcallbacks.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* 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:  PTP transport callback interface.
+*
+*/
+
+
+#ifndef PTPCALLBACK_H
+#define PTPCALLBACK_H
+
+#include <e32std.h>
+#include <ptptransport.h>
+
+class MNPtpCallback
+/** 
+ * An interface for notification of receive completions.
+ * Transport plugins use these methods to inform PTP when an event is received
+ * or a data block has arrived through the transport interface.
+ * @lib ptpstack.lib
+ * @since S60 3.2
+ */
+	{
+public:
+
+	/**
+	* Callback for informing PTP that an event has been received.
+    * @since S60 3.2
+    * @param aEventData, Container containing event info.
+    * @return KErrNone, if successful, otherwise one of the other system-wide
+    *         error codes.
+	*/
+	virtual TInt EventReceived( TNPtpContainer& aEventData  ) = 0;
+
+    /**
+	* Callback for informing PTP that a data block has been received.
+	* @since S60 3.2
+	* @param aContainer, Container containing operation info.
+	*                    Response is returned in this parameter also.
+	* @param aDataFile, Name of the file where incoming data resides.
+	*                   Also if method returns data, the name of the data file
+	*                   is written here. When operation or response deosn't
+	*                   constain any data, this parameter should be empty.
+	* @return KErrNone, if successful, otherwise one of the other system-wide
+    *         error codes. KPtpErrDataMissing is returned if aData is empty
+    *         though operation requires data. Transport layer then re-sends the
+    *         operation with the data packed.
+	*/
+	virtual TInt DataReceived( TNPtpContainer& aContainer, TFileName& aFileName  ) = 0;
+	
+	virtual void ResponseReturned(TNPtpContainer& aContainer) = 0;
+	};
+	
+	
+#endif // PTPCALLBACK_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_transport_api/inc/ptptransport.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* 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:  PTP tranport plugin interface API
+*
+*/
+
+
+
+#ifndef PTP_TRANSPORT_H
+#define PTP_TRANSPORT_H
+
+
+// INCLUDES
+#include <e32base.h>
+
+class MNPtpCallback;
+const TUid KPtpTransportInterfaceUid = { 0x1020E46C };
+
+// Dataset to send/receive operations, responses and events.
+class TNPtpContainer
+	{
+	public:
+	TUint16 iOperationCode;
+	TUint16 iResponseCode;
+	TUint32 iSessionId; 
+	TUint32 iTransactionId;
+	TUint32 iParam1;
+	TUint32 iParam2;
+	TUint32 iParam3;
+	// events can only have three parameters.
+	TUint32 iParam4;
+	TUint32 iParam5;
+	}; 
+
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+// PTPTransport ECOM plugin interface.
+// This is the plugin interface that each plugin module must implement to provide a PTP transport
+// layer interface. Currently only USB media is supported, but each created plugin module must 
+// implement this interface.
+// 
+//  @lib ptptransport.lib
+// ------------------------------------------------------------------------------------------------
+
+class CNPtpTransport : public CBase 
+    {
+
+public:	// Constructors and destructor
+
+	/**
+    * C++ Consructor.
+    */
+	IMPORT_C CNPtpTransport();
+    /**
+    * Destructor.
+    */
+	IMPORT_C ~CNPtpTransport();
+		
+	/**
+    * Two-phased constructor.
+    */	
+	IMPORT_C static CNPtpTransport* NewL( const TUid aTransport, MNPtpCallback* aCallback );		
+				
+public:	// API
+
+	/**
+	* Connects the client transport interface with the "Host".
+	* Can be used with Bluetooth or TCP/IP transport plugin adapters in the future,
+	* USB plugin (SICD) does not need a separate connection because it is created
+	* when the USB cable is attached to the device.
+	* @since S60 3.2
+	* @return None.
+	*/	
+	IMPORT_C void ConnectL( ); 
+
+	/**
+	* Disconnects the client transport interface with the "Host".
+	* Can be used with Bluetooth or TCP/IP transport plugin adapters in the future,
+	* USB media disconnection is not needed. The connection may exists until
+	* SICD component is deleted or cable is unattached.
+	* @since S60 3.2
+	* @return None.
+	*/	
+	IMPORT_C void DisconnectL();
+	
+	/**
+	* Sends an PTP event to the connected "Host". Particulary used with USB media.
+	* @param aStatus, Asynchronous completion word for the operation.
+	* @param aEventData, PTP container containing all the information for the event.
+	* @since S60 3.2
+	* @return None.
+	*/
+	IMPORT_C void SendEventL( TRequestStatus& aStatus, const TNPtpContainer& aEventData );
+	
+    /**
+   	* Cancels the asynchronous event sending operation.
+	* @since S60 3.2
+	* @return none    	
+    */	
+	IMPORT_C void CancelEvent();
+
+protected:
+
+	// hide the virtual methods from the public interface to enable future extension without breaking BC
+	virtual void DoConnectL() = 0;
+	virtual void DoDisconnectL() = 0;
+	virtual void DoSendEventL( TRequestStatus& aStatus, const TNPtpContainer& aEventData ) = 0;
+	virtual void DoCancelEvent() = 0;
+	
+private:
+	TUid iEComTag;
+    };
+
+
+void CleanupEComArray(TAny* aArray);
+
+#endif // PTP_TRANSPORT_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/ptp_transport_api/ptp_transport_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="f0ebf932171e4cbcb9af80cb8384f345" dataversion="2.0">
+  <name>PTP Transport API</name>
+  <description>Defines interface for transport plug-ins</description>
+  <type>c++</type>
+  <collection>usbclasses</collection>
+  <libs>
+    <lib name="ptptransport.lib" />
+  </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/usbservices_plat/usb_device_control_plugin_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 
+:                USB Secondary Display API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/cusbdevicecontrolplugin.h     MW_LAYER_PLATFORM_EXPORT_PATH(cusbdevicecontrolplugin.h)
+../inc/cusbdevicecontrolplugin.inl     MW_LAYER_PLATFORM_EXPORT_PATH(cusbdevicecontrolplugin.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_device_control_plugin_api/inc/cusbdevicecontrolplugin.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,80 @@
+/*
+* 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:  USB Device Control Plug-In API
+*
+*/
+
+
+#ifndef     CUSBDEVICECONTROLPLUGIN_H__
+#define    CUSBDEVICECONTROLPLUGIN_H__
+
+#include <e32base.h>
+#include <ecom/ecom.h>
+
+const TUid KUsbCMHandlerInterface =  {0x10283306}; // this interface UID
+
+class RUsb;
+class RDevUsbcClient;
+class RUsbWatcher;
+
+/**
+ *  All USB control message handlers plugins must implement this interface.
+ *  ECOM framework is used here.
+ *  Class is inherited from CBase, to have an access to virtual destructor
+ *  NewL is not provided, due to class is not intended for instantiation 
+ *
+ *  @since S60 5.0
+ */
+class CUsbCMHandler: public CBase
+    {
+public: 
+    
+    /**
+     * Destruction
+     * 
+     */
+     virtual ~CUsbCMHandler();
+    
+     /**
+     * Handler
+     *
+     * @since S60 v.5.0
+     * @param aSetupPacket Request to be handled
+     * @param aData Either data for request, or result of request handling
+     * @return Errorcode
+     */
+    virtual TInt Handle(const RBuf8& aSetupPacket, RBuf8& aData) = 0;
+    
+    /**
+     * Provides handlers with links to USB services 
+     *
+     * @since S60 v.5.0
+     * @param aUsbcClient Link to LDD services
+     * @param aUsbWatcher Link to USB Watcher services
+     * @param aUsbManager Link to USB Manager services 
+     */
+     virtual void Initialize(RDevUsbcClient& aUsbcClient, RUsbWatcher& aUsbWatcher, RUsb& aUsbManager) = 0;
+     
+    /**
+     * UID given to us by ECOM when the instance is created. Used when the 
+     * instance is destroyed.
+     * The class member is public one, due to when instantiate the plugin, there is need access to this member by _FOFF macro
+     * This member is not intended for initialization, modification, or any else type of use
+     */
+    TUid iPrivateEComUID;
+    };
+    
+    #include <cusbdevicecontrolplugin.inl>
+
+#endif // CUSBDEVICECONTROLPLUGIN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_device_control_plugin_api/inc/cusbdevicecontrolplugin.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Inline methods for CUsbCMHandler class
+*
+*/
+
+
+// ----------------------------------------------------------------------------
+// Destructor; destructs the ECOM session first 
+// ----------------------------------------------------------------------------
+//
+inline CUsbCMHandler::~CUsbCMHandler()
+  { 
+  REComSession::DestroyedImplementation(iPrivateEComUID);
+  }
+ 	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_device_control_plugin_api/usb_device_control_plugin_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="f3e7a19b52969b3e33a9f4d99913ae35" dataversion="2.0">
+  <name>USB Device Control Plug-in API</name>
+  <description>Defines interface for USB Device Control Plug-ins. The plug-ins handle a specific set of class specific USB control transfers that are directed to the device (not to endpoint or interface).</description>
+  <type>c++</type>
+  <collection>usbengines</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/usbservices_plat/usb_notifier_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,25 @@
+/*
+ * 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:
+ *
+ */
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/usbuinotif.h     MW_LAYER_PLATFORM_EXPORT_PATH(usbuinotif.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_notifier_api/inc/usbuinotif.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,158 @@
+/*
+ * 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:
+ *
+ */
+
+#ifndef USBUINOTIF_H
+#define USBUINOTIF_H
+
+#include <eiknotapi.h>
+
+/**
+ * Different note types
+ */
+enum TUSBUINotes
+    {
+   };
+
+/**
+ * Used with information notes
+ */
+struct TUSBNotesNotiferParams
+    {
+    TUSBUINotes iNote;
+    };
+
+/**
+ * Used with connection notifier
+ */
+struct TUSBConnectionNotiferParams
+    {
+    TInt iPersonalityId;
+    };
+
+/**
+ * Package for information notes
+ */
+typedef TPckgBuf<TUSBNotesNotiferParams> TUSBNotesNotifierParamsPckg;
+
+/**
+ * Package for connection note
+ */
+typedef TPckgBuf<TUSBConnectionNotiferParams> TUSBConnectionNotifierParamsPckg;
+
+/**
+ * Different query types
+ */
+enum TUSBUIQueries
+    {
+    EUSBMemoryCardUnlocked,
+    EUSBStorageMediaFailure,    
+    EUSBPossibleDataLossCable,
+    EUSBPossibleDataLossMMC,
+    EUSBChangeFromMassStorage,
+    EUSBNoMemoryCard,
+    EUSBNotEnoughRam,
+    EUSBDiskFull
+   };
+
+/**
+ * Used with queries
+ */
+struct TUSBQueriesNotiferParams
+    {
+    TUSBUIQueries iQuery;
+    TInt          iDrive;
+    };
+
+/**
+ * Package for queries
+ */
+typedef TPckgBuf<TUSBQueriesNotiferParams> TUSBQueriesNotifierParamsPckg;
+
+/**
+ * Notifier id for USB Cable Connection
+ */
+const TUid KCableConnectedNotifierUid = {0x102068DE}; 
+
+/**
+ * Notifier id for USB Notes
+ */
+const TUid KNotesNotifier             = {0x102068E0}; 
+
+/**
+ * Notifier id for USB Queries
+ */
+const TUid KQueriesNotifier           = {0x102068E1}; 
+
+/**
+ * Notifier id for USB connection
+ */
+const TUid KUsbConnectionNotifier     = {0x10282544};
+
+
+/**
+ * Notifier id for USB OTG Warning
+ */
+const TUid KUsbUiNotifOtgWarning      = {0x2000B001};
+
+/**
+ * Notifier id for USB OTG Error
+ */
+const TUid KUsbUiNotifOtgError     = {0x2000B002};
+
+/**
+ * Notifier id for USB OTG indicator
+ */
+const TUid KUsbUiNotifOtgIndicator      = {0x2000B003};
+
+/**
+ * Notifier id for mass storage mount manager error
+ * THostMsErrData is used as parameter  for delivering error 
+ * information
+ */
+const TUid KUsbUiNotifMsmmError     = {0x2001FE3A};
+
+/**
+ * Parameter for both KUsbUiNotifOtgWarning and KUsbUiNotifOtgError
+ * Possible values listed in following two enums
+ */
+typedef TPckgBuf<TInt> TUsbUiNotifOtgParam;  
+
+/**
+ * Possible parameter values for KUsbUiNotifOtgNote
+ */
+enum TUsbUiNotifOtgWarning
+    {
+    EUsbOtgPartiallySupportedDevice
+    };
+
+/**
+ * Possible parameter values for KUsbUiNotifOtgQuery
+ */
+enum TUsbUiNotifOtgError
+    {
+    EUsbOtgTooMuchPower,		// Error during operating
+    EUsbOtgTooMuchPowerRequired,// Error during enumerating
+    EUsbOtgUnsupportedDevice,
+    EUsbOtgHubUnsupported,
+    EUsbOtgErrorInConnection,
+    EUsbOtgErrorAttachTimedOut,
+    EUsbOtgErrorNoMemory
+    };
+
+#endif // USBUINOTIF_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_notifier_api/usb_notifier_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="344725524fbda27651b54aea9913b6a7" dataversion="2.0">
+  <name>USB Notifier API</name>
+  <description>Common constants for USB Watcher and USB UI Notifier</description>
+  <type>c++</type>
+  <collection>usbengines</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/usbservices_plat/usb_personality_api_header/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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 
+:                USB Personality API header
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/UsbWatcherInternalCRKeys.h     MW_LAYER_PLATFORM_EXPORT_PATH(UsbWatcherInternalCRKeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_api_header/inc/UsbWatcherInternalCRKeys.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* 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:  USB Watcher's internal Central Repository keys
+*
+*/
+
+
+#ifndef USBWATCHERINTERNALCRKEYS_H
+#define USBWATCHERINTERNALCRKEYS_H
+
+// CONSTANTS
+const TUid KCRUidUsbWatcher = { 0x101F8801 };
+
+const TUint32 KUsbWatcherChangeOnConnectionSetting = 0x00000001;
+    const TInt KUsbWatcherChangeOnConnectionOff = 0;
+    const TInt KUsbWatcherChangeOnConnectionOn = 1;
+
+const TUint32 KUsbWatcherPersonality = 0x00000002;
+
+const TUint32 KUsbWatcherChargingDefaultPersonality = 0x00000003;
+
+#endif      // USBWATCHERINTERNALCRKEYS_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_api_header/usb_personality_api_header.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="a6aed446302883823a3a04f59a718f0b" dataversion="2.0">
+  <name>USB Personality API header</name>
+  <description>This is header file for "USB Personality API" which is CenRep API</description>
+  <type>c++</type>
+  <collection>usbengines</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/usbservices_plat/usb_personality_plugin_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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 
+:                USB Personality Plug-in API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/cusbpersonality.h     MW_LAYER_PLATFORM_EXPORT_PATH(cusbpersonality.h)
+../inc/cusbpersonalitynotifier.h     MW_LAYER_PLATFORM_EXPORT_PATH(cusbpersonalitynotifier.h)
+../inc/tusbpersonalityparams.h     MW_LAYER_PLATFORM_EXPORT_PATH(tusbpersonalityparams.h)
+../inc/musbnotifiercallback.h     MW_LAYER_PLATFORM_EXPORT_PATH(musbnotifiercallback.h)
+../inc/cusbpersonalityplugin.h     MW_LAYER_PLATFORM_EXPORT_PATH(cusbpersonalityplugin.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/inc/cusbpersonality.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* 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:  Basic class for personalitites
+*
+*/
+
+
+#ifndef CUSBPERSONALITY_H
+#define CUSBPERSONALITY_H
+
+#include <bldvariant.hrh>
+#include <e32base.h>
+#include <usbman.h>
+#include <usbuinotif.h>
+#include <cusbpersonalitynotifier.h>
+
+class RUsb;
+class TUsbPersonalityParams;
+
+/**
+*  Abstract interface to personality handler objects.
+*
+*  @lib -
+*  @since Series 60 3.0
+*/
+class CUsbPersonality : public CActive
+    {
+    public: // New functions
+    
+        /**
+        * Destructor.
+        */
+        
+        virtual ~CUsbPersonality();
+
+        /**
+        * DEPRICATED
+        */
+        IMPORT_C virtual void ShowUsbConnectionNote();
+        
+        virtual void ConfirmPersonalityUnload(TRequestStatus& aStatus) = 0;
+                
+        /**
+        * Called by personality handler when personality start needs to be
+        * prepared
+        * @since Series 60 3.0
+        */
+        virtual void PreparePersonalityStart(TRequestStatus& aStatus) = 0;
+        
+        /**
+        * Called by personality handler when personality start needs to be 
+        * finished
+        * @since Series 60 3.0
+        */
+        virtual void FinishPersonalityStart(TRequestStatus& aStatus) = 0; 
+
+        /**
+        * Called by personality handler when personality stop needs to be 
+        * prepared
+        * @since Series 60 3.0
+        */
+        virtual void PreparePersonalityStop(TRequestStatus& aStatus) = 0; 
+                
+        /**
+        * Called by personality handler when personality stop needs to be 
+        * finished
+        * @since Series 60 3.0
+        */
+        virtual void FinishPersonalityStop(TRequestStatus& aStatus) = 0; 
+                
+        /**
+        * State change notify
+        * @since Series 60 3.0
+        * @param aState state of the device
+        */
+        virtual void StateChangeNotify( TUsbDeviceState aState ) = 0;
+
+protected:
+        
+        /**
+        * Constructor
+        * @since S60 3.2
+        * @param aPersonalityParams Used to deliver information for personality
+        */
+        IMPORT_C CUsbPersonality(TUsbPersonalityParams& aPersonalityParams);
+        
+
+        /**
+         * This class contains information what might be needed by the personality
+         */
+        TUsbPersonalityParams& iPersonalityParams;
+
+        /**
+         * Member variable used by connection notifier
+         */
+        TUSBConnectionNotifierParamsPckg iPckg;
+        
+        /**
+         * Member variable used by connection notifier
+         */
+        TBuf8<1> iNoResult;
+    };
+
+#endif   // CUSBPERSONALITY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/inc/cusbpersonalitynotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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:  Header file for personality notifier
+*
+*/
+
+
+#ifndef CUSBPERSONALITYNOTIFIER_H
+#define CUSBPERSONALITYNOTIFIER_H
+
+#include <e32base.h>
+#include <musbnotifiercallback.h>
+
+NONSHARABLE_CLASS(CUsbPersonalityNotifier) : public CActive
+    {
+public:
+    IMPORT_C ~CUsbPersonalityNotifier();
+        
+    IMPORT_C static CUsbPersonalityNotifier* NewL();
+    
+    IMPORT_C TInt ShowQuery(TUid aNotifierUid, const TDesC8 &aBuffer, TDes8 &aResponse, 
+        MUsbNotifierCallBack* aCallBack = NULL, TRequestStatus* aStatus = NULL);
+    
+    IMPORT_C TInt ShowNote(TUid aNotifierUid, const TDesC8 &aBuffer, TDes8 &aResponse);
+    
+    IMPORT_C void CancelAll();
+    
+    IMPORT_C void CancelQuery(TUid aNotifierUid);
+    
+    /** Cancel all queued queries and notes but the currently shown */
+    IMPORT_C void CancelAllButCurrent();
+
+    /** Return ETrue, if the notifier is showing currently */
+    /** DEPRICATED */
+    IMPORT_C TBool IsShowing(TUid aNotifierUid);
+
+private:
+
+    CUsbPersonalityNotifier();
+    
+    void ConstructL();
+    
+    enum TNotifierState
+        {
+        EUsbPersonalityNotifierIdle,
+        EUsbPersonalityNotifierStarted
+        };
+        
+    void DoCancel();
+    void RunL();
+    TInt RunError( TInt /*aError*/ );
+        
+    TInt DoShowQuery(MUsbNotifierCallBack* aCallBack, TUid aNotifierUid, 
+        const TDesC8 &aBuffer, TDes8 &aResponse, TRequestStatus* aStatus);
+    
+    TInt DoShowNote(TUid aNotifierUid, const TDesC8 &aBuffer, TDes8 &aResponse);
+
+    class TNotifierClient
+        {
+    public:
+        TNotifierClient::TNotifierClient(MUsbNotifierCallBack* aCallBack, TUid aNotifierUid, 
+            const TDesC8 &aBuffer, TDes8 &aResponse, TRequestStatus* iRequestStatus, 
+            TBool aConfirmation);
+            
+        MUsbNotifierCallBack* iCallBack; 
+        TUid iNotifierUid;
+        const TDesC8 &iBuffer; 
+        TDes8 &iResponse;
+        TRequestStatus* iRequestStatus;
+        TBool iConfirmation;
+        };
+    
+    RPointerArray<TNotifierClient> iNotifierClient;
+    
+    MUsbNotifierCallBack* iCallBack;
+    TUid iNotifierUid;
+    RNotifier iNotifier;
+    TNotifierState iState;
+    TRequestStatus* iRequestStatus;
+    };
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/inc/cusbpersonalityplugin.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* 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:  Header file for CUsbPersonalityPlugin class
+*
+*/
+
+
+#ifndef CUSBPERSONALITYPLUGIN_H__
+#define CUSBPERSONALITYPLUGIN_H__
+
+#include <cusbpersonality.h>
+
+class RUsb;
+
+/**
+ *  All personalities must be inherited from this class.
+ *  ECOM framework is used here.
+ *
+ *  @lib euser.lib, ecom.lib
+ *  @since S60 3.2
+ */
+class CUsbPersonalityPlugin : public CUsbPersonality
+	{
+public: 
+	/** 
+	 * Factory function
+	 *
+     * @since S60 3.2
+	 * @param aPersonalityParams Reference to container class
+	 * @param aImplementationId The UID of this implementation.
+	 * @return Ownership of a new CUsbPersonalityPlugin.
+	 */
+	IMPORT_C static CUsbPersonalityPlugin* NewL(TUsbPersonalityParams& aPersonalityParams, TUid aImplementationId);
+
+	/** 
+	 * Destructor
+	 */
+	IMPORT_C virtual ~CUsbPersonalityPlugin();
+
+protected:
+
+	/** 
+	 * Constructor
+	 */
+	IMPORT_C CUsbPersonalityPlugin(TUsbPersonalityParams& aPersonalityParams);
+
+protected:
+	
+	/**
+	 * UID given to us by ECOM when the instance is created. Used when the 
+     * instance is destroyed.
+     */
+	TUid iPrivateEComUID;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/inc/musbnotifiercallback.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  This class is used to get callbacks from the UI
+*
+*/
+
+
+#ifndef MUSBNOTIFIERCALLBACK_H
+#define MUSBNOTIFIERCALLBACK_H
+
+class MUsbNotifierCallBack
+    {
+public:
+    virtual void CallBack(TInt aStatus) = 0;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/inc/tusbpersonalityparams.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* 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:  Container class for USB personalities
+*
+*/
+
+
+#ifndef TUSBPERSONALITYPARAMS_H
+#define TUSBPERSONALITYPARAMS_H
+
+class RUsb;
+class CUsbPersonalityNotifier;
+
+/**
+ *  Container class for USB personalities
+ *
+ *  Personality id, handle for Usb Manager and personality notifier
+ *  is given with this class to USB personalities.
+ *
+ *  @lib euser.lib, usbman.lib
+ *  @since S60 3.2
+ */
+class TUsbPersonalityParams
+    {
+public:    
+    IMPORT_C TUsbPersonalityParams(RUsb& aUsbMan, CUsbPersonalityNotifier& aPersonalityNotifier);
+    IMPORT_C ~TUsbPersonalityParams();
+    
+    /**
+     * Method to get handle to USB Manager
+     *
+     * @since S60 3.2
+     * @return Handle to USB Manager
+     */
+    IMPORT_C RUsb& UsbMan() const;
+    
+    /**
+     * Method to get handle to personality notifier
+     *
+     * @since S60 3.2
+     * @return Handle to personality notifier
+     */    
+    IMPORT_C CUsbPersonalityNotifier& PersonalityNotifier() const;
+    
+    /**
+     * Set personality id.
+     *
+     * @since S60 3.2
+     * @param Personality id
+     */    
+    IMPORT_C void SetPersonalityId(TInt aPersonalityId);
+    
+    /**
+     * Method to get current personality id
+     *
+     * @since S60 3.2
+     * @return Personality id
+     */        
+    IMPORT_C TInt PersonalityId() const;
+    
+private:
+    /**
+     * Handle to USB Manager
+     */
+    RUsb& iUsbMan;
+
+    /**
+     * Handle to personality notifier
+     */    
+    CUsbPersonalityNotifier& iPersonalityNotifier;
+
+    /**
+     * Current personality id
+     */    
+    TInt iPersonalityId;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_personality_plugin_api/usb_personality_plugin_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="11046198b2f847504093aab807ea1010" dataversion="2.0">
+  <name>USB Personality Plug-in API</name>
+  <description>Defines interface for UsbWatcher personality plug-ins.</description>
+  <type>c++</type>
+  <collection>usbengines</collection>
+  <libs>
+    <lib name="usbpersonality.lib" />
+  </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/usbservices_plat/usb_secondary_display_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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 
+:                USB Secondary Display API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/usbuinotifsecondarydisplay.h     MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/usbuinotifsecondarydisplay.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_secondary_display_api/inc/usbuinotifsecondarydisplay.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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:  Contains dialog index for cover UI.
+*
+*/
+
+
+#ifndef USBUINOTIFSECONDARYDISPLAY_H
+#define USBUINOTIFSECONDARYDISPLAY_H
+
+// Category
+const TUid KUSBUINotifCategory = { 0x102068DC };
+
+/**
+* Enumerates types.
+* Do not use value 0 as a dialog ID, since it is reserved for special cases 
+* in AknGlobalUI. Note that the notes start from 1, queries from 0x100, and
+* list queries from 0x200. 
+*/
+enum TUSBUINotifDialogIndex
+    {
+    /**
+     * Not a valid dialog ID.
+     * This value is not associated with any dialog to be shown. 
+     */
+    EUSBCoverInvalidDialogId = -1,
+    
+    // ===== notes =====
+    
+    /**
+     * Connected in %U mode. 
+     * %U is for example "PC Suite" or "Mass storage".
+     */
+    EUSBCoverConnectionNote = 0x1,
+    
+    // ===== queries =====
+
+#ifndef RD_MULTIPLE_DRIVE    
+    /** Memory card needs to be unlocked: OK */
+    EUSBCoverMemoryCardUnlocked = 0x100, 
+#endif //RD_MULTIPLE_DRIVE
+
+    /** Storage media not accessible: OK */
+    EUSBCoverStorageMediaFailure = 0x101, 
+    
+#ifndef RD_MULTIPLE_DRIVE    
+    /** 
+     * Data loss may have occurred. In future, stop file transfers 
+     * before removing the cable: OK
+     */
+    EUSBCoverPossibleDataLossCable = 0x102,
+    
+    /** In future, stop file transfers before removing the memory card: OK */
+    EUSBCoverPossibleDataLossMMC = 0x103,
+#endif //RD_MULTIPLE_DRIVE
+    
+    /** Data loss might occur. Change mode anyway? OK, Cancel */
+    EUSBCoverChangeFromMassStorage = 0x104,
+
+    EUSBCoverNoMemoryCard = 0x105,
+               
+    // ===== list queries =====
+    
+    /** USB mode: <list> */
+    EUSBCoverCableConnected = 0x200
+    };
+    
+#endif      // USBUINOTIFSECONDARYDISPLAY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_secondary_display_api/usb_secondary_display_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="531303722a586d84a7b247238718874c" dataversion="2.0">
+  <name>USB Secondary Display API</name>
+  <description>API for Cover UI use.</description>
+  <type>c++</type>
+  <collection>usbuis</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/usbservices_plat/usb_watcher_api/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 
+:                USB Watcher API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/usbwatcher.h     MW_LAYER_PLATFORM_EXPORT_PATH(usbwatcher.h)
+../inc/usbpersonalityids.h     MW_LAYER_PLATFORM_EXPORT_PATH(usbpersonalityids.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_watcher_api/inc/usbpersonalityids.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Header file specifying usb personality ids
+*
+*/
+
+
+#ifndef USBPERSONALITYIDS_H
+#define USBPERSONALITYIDS_H
+
+#define KUsbPersonalityIdPCSuite   0x01
+#define KUsbPersonalityIdMS            0x02
+#define KUsbPersonalityIdPTP          0x03
+#define KUsbPersonalityIdMTP          0x04
+#define KUsbPersonalityIdPCSuiteMTP  0x05
+#define KUsbPersonalityIdModemInst  0x06
+#define KUsbPersonalityIdRNDIS       0x08
+
+#endif   // USBPERSONALITYIDS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_watcher_api/inc/usbwatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* 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:  UsbWatcher server API
+*
+*/
+
+
+#ifndef RUSBWATCHER_H
+#define RUSBWATCHER_H
+
+#include <e32std.h>
+#include <usb.h>
+
+/**
+ *  RUsbWatcher class
+ *
+ *  This class offers access to UsbWatcher server to make personality
+ *  related operations.
+ *
+ *  @lib usbwatcher.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS(RUsbWatcher) : public RSessionBase
+    {
+public:
+	IMPORT_C RUsbWatcher();
+
+	IMPORT_C ~RUsbWatcher();
+
+    /**
+     * Return version of the server.
+     *
+     * @since S60 3.2
+     * @return Version of the server
+     */
+	IMPORT_C TVersion Version() const;
+
+    /**
+     * Connect to the server
+     *
+     * @since S60 3.2
+     * @return KErrNone if successful, otherwise one of the other system-wide error codes.
+     */
+	IMPORT_C TInt Connect();
+    
+    /**
+     * Set and select personality
+     * Personality is saved to central repository and if there is an active 
+     * USB connection also current personality is changed to new one.
+     *
+     * If the aForce parameter is set ETrue, the Ask on connection mode query
+     * is not shown at the following cable connections until 
+     * - the session is closed 
+     * - or aForce is set EFalse in subsequent SetPersonality
+     * - or CancelSetPersonality is called for outstanding SetPersonality
+     * - or SetPreviousPersonality or SetPreviousPersonalitySync is called
+     * - or SetPreviousPersonalityOnDisconnect is called.
+     * The Ask on connection is suppressed until all the sessions using aForce 
+     * have been closed or have been resetted the suppression with one of the 
+     * function calls listed above. Do not leave session open without resetting 
+     * aForce, if Ask on connection needs to work normally.
+     *
+     * Note that if KErrDiskFull is returned in aStatus, while the cable is 
+     * connected, the personality was loaded, but the new personality was not 
+     * stored to Central Repository.
+     *
+     * @since S60 3.2
+     * @param aStatus The completion status of the request.
+     * @param aId Identifies personality to set.
+     * @param aForce If this parameter has value ETrue, USB mode is not asked from the user.
+     * @param aNonBlocking If ETrue, no personality switch blocking queries are shown.
+     */
+    IMPORT_C void SetPersonality(TRequestStatus& aStatus, TInt aId, TBool aForce = EFalse, 
+        TBool aNonBlocking = EFalse);
+    
+    /**
+     * Cancel pending set personality request.
+     *
+     * @since S60 3.2
+     */    
+    IMPORT_C void CancelSetPersonality();
+
+    /**
+     * Set to previous personality. Central repository key is updated with the previous one and if
+     * USB is connected current personality is replaced with previous one.
+     * 
+     * @since S60 3.2
+     * @param aStatus The completion status of the request.
+     */
+    IMPORT_C void SetPreviousPersonality(TRequestStatus& aStatus);
+
+    /**
+     * This service is same as previous one. Except that this one is comleted before it is ready.
+     * 
+     * @since S60 3.2
+     */
+    IMPORT_C void SetPreviousPersonality();
+
+    /**
+     * This service cancels pending SetPreviousPersonality() request.
+     * 
+     * @since S60 3.2
+     */
+    IMPORT_C void CancelSetPreviousPersonality();
+    
+    /**
+     * This service will set the previous personality on cable disconnect. If cable is disconnected
+     * already when this service is used, nothing will happen.
+     * 
+     * @since S60 3.2
+     */    
+    IMPORT_C void SetPreviousPersonalityOnDisconnect();
+    };
+    
+#endif //RUSBWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_watcher_api/usb_watcher_api.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="5769e9616f484c2af8e6053119478571" dataversion="2.0">
+  <name>USB Watcher API</name>
+  <description>Defines interface for setting personalities via UsbWatcher.</description>
+  <type>c++</type>
+  <collection>usbengines</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/usbservices_plat/usb_watcher_info_api_header/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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 
+:                USB Watcher Info API header
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/UsbWatcherInternalPSKeys.h     MW_LAYER_PLATFORM_EXPORT_PATH(UsbWatcherInternalPSKeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_watcher_info_api_header/inc/UsbWatcherInternalPSKeys.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  USB Watcher's internal Publish & Subscribe keys
+*
+*/
+
+
+#ifndef USBWATCHERINTERNALPSKEYS_H
+#define USBWATCHERINTERNALPSKEYS_H
+
+// CONSTANTS
+const TUid KPSUidUsbWatcher = { 0x101F8801 };
+
+const TUint32 KUsbWatcherSelectedPersonality = 0x00000001;
+const TInt KUsbWatcherSelectedPersonalityNone = -1;
+
+// specifies whether peripheral is connected, and device perform as host. 
+const TUint32 KUsbWatcherIsPeripheralConnected = 0x00000002;  
+    
+#endif      // USBWATCHERINTERNALPSKEYS_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbservices_plat/usb_watcher_info_api_header/usb_watcher_info_api_header.metaxml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="9b7ed6942f45ceeb62fcbb1ee8320888" dataversion="2.0">
+  <name>USB Watcher Info API header</name>
+  <description>This is header file for "USB Watcher Info API" which is PubSub API</description>
+  <type>c++</type>
+  <collection>usbengines</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/usbuis/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Build information file for project usbuis
+*
+*/
+
+
+#include "../usbui/group/bld.inf"
+#include "../usbuinotif/group/bld.inf"
+#include "../imageprintuiprovider/group/bld.inf"
+#include "../imageprintui/group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/data/imageprintui.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,508 @@
+/*
+* 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 Image Print UI
+*
+*/
+
+
+NAME IMPR
+
+#include <eikon.rh>	
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.hrh>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <AvkonIcons.hrh>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include <badef.rh>
+
+#include "imageprintui.hrh"
+#include <imageprintui.loc> // Localisation file
+
+
+RESOURCE BA_RSS_SIGNATURE { signature = 1; }
+RESOURCE TBUF { buf="IMAGEPRINTAPP"; }
+
+// ---------------------------------------------------------------------------
+// eik_app_info, standard resource for symbian application
+// This is empty when using avkon's view architecture
+// ---------------------------------------------------------------------------
+//
+
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// r_empty_view
+// Empty view resource, shown when the application starts
+// ---------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_empty_view
+    {
+    menubar = R_AVKON_MENUPANE_EMPTY;
+    cba = R_AVKON_SOFTKEYS_EXIT;
+    }
+
+// ---------------------------------------------------------------------------
+// r_imageprint_softkeys_options_change_exit
+// Print preview view resource
+// ---------------------------------------------------------------------------
+//
+RESOURCE CBA r_imageprint_softkeys_options_change_exit
+    {
+    flags = 0;
+    buttons =
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyExit; txt = text_softkey_exit;},
+        CBA_BUTTON {id=ECmdSettingsChange; txt = qtn_msk_change;}
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_settings_view
+// settings view resource
+// ---------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_settings_view
+    {
+    menubar = r_settings_view_menubar;
+    cba = r_imageprint_softkeys_options_change_exit;
+    }
+
+// ---------------------------------------------------------------------------
+// r_settings_view_menubar
+// settings view menu bar
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_settings_view_menubar
+    {
+    titles =
+        {
+        MENU_TITLE 
+            { 
+            menu_pane = r_settings_view_menu; 
+            txt = " ";  
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_settings_view_menu
+// settings view menu pane
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_settings_view_menu
+    {           
+    items =
+        {
+        MENU_ITEM
+	        {
+            command = ECmdSettingsChange;
+            txt = qtn_usb_opt_change;
+            },
+        MENU_ITEM
+            {
+            command = ECmdSettingsPrint; 
+            txt = qtn_usb_option_print;
+            },
+            
+        #ifdef __SERIES60_HELP  
+        MENU_ITEM
+            {
+            command = ECmdSettingsHelp;
+            txt = qtn_options_help;
+            },
+        #endif
+            
+				MENU_ITEM
+            {
+            command = EAknCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+    
+// ---------------------------------------------------------------------------
+// r_imageprintui_localisable_app_info
+// settings view menu pane
+// ---------------------------------------------------------------------------
+//    
+RESOURCE LOCALISABLE_APP_INFO r_imageprintui_localisable_app_info
+    {
+    short_caption = qtn_usb_title_image_print;
+    caption_and_icon =
+        CAPTION_AND_ICON_INFO
+            {
+            caption = qtn_usb_title_image_print;
+        	  #ifdef __SCALABLE_ICONS
+         	  number_of_icons = 1;
+            icon_file = APP_BITMAP_DIR"\\imageprintui_aif.mif";
+            #else
+            number_of_icons = 2; 
+            icon_file = APP_BITMAP_DIR"\\imageprintui_aif.mbm"; 
+        	  #endif // __SCALABLE_ICONS
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_print_progress_note
+// Resource for print progress dialog
+// ---------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_print_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EBitmapCtrl;
+            id = EBrandingBitmap;   
+            },      
+        DLG_LINE
+            {
+            type 	= EAknCtNote;
+            id 		= EAknNoteProgressBar;
+            control = AVKON_NOTE
+                {
+                layout = EProgressLayout;
+                singular_label = qtn_usb_wait_printing;
+                imageid = EMbmAvkonQgn_note_progress;
+                imagemask = EMbmAvkonQgn_note_progress_mask;
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_connect_usb
+// Dialog resource for "Connect USB Printer" 
+// ---------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_connect_usb
+    {
+    flags = EAknWaitNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items = 
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EAknNoteProgressBar;
+            control = AVKON_NOTE
+                {
+                layout = EWaitLayout;
+								singular_label = qtn_usb_wait_connect_cable;     
+								animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_connect_usb
+// Dialog resource for "Connect USB Printer" 
+// ---------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_not_connect_printer
+    {
+    flags = EAknWaitNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items = 
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EAknNoteProgressBar;
+            control = AVKON_NOTE
+                {
+                layout = EWaitLayout;
+				singular_label = qtn_usb_wait_connect_cable_compatible;     
+				animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_cancel_printing_dialog
+// Dialog resource for "Cancel printing"
+// ---------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_cancel_printing_dialog
+	{
+	flags = EAknWaitNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_EMPTY;
+    items=
+		{
+		DLG_LINE
+			{
+			type = EAknCtNote;
+			id = EGeneralNote;
+			control= AVKON_NOTE 
+                { 
+				layout = EWaitLayout;
+				singular_label = qtn_usb_wait_cancelling; 
+				animation =R_QGN_GRAF_WAIT_BAR_ANIM;
+				};
+			}
+		};
+	}
+
+//
+RESOURCE LISTBOX r_usb_print_mode_setting_editor
+    {
+    flags = EEikListBoxMultipleSelection;
+    }
+
+//-----------------------------------------------------------------------------
+//
+// r_usb_print_mode_setting_page
+// Setting page for setting the USB mode
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_usb_print_mode_setting_page
+	{
+	label              = "";
+    	hint_text          = " ";
+    	type               = EAknSetListBox;	
+	editor_resource_id = r_usb_print_mode_setting_editor;
+	}
+
+// ---------------------------------------------------------------------------
+// Layout strings
+// ---------------------------------------------------------------------------
+//
+RESOURCE TBUF r_usb_print_layout 
+{
+    buf = qtn_usb_print_layout;    
+}
+
+RESOURCE TBUF r_usb_print_layout_default 
+{
+    buf = qtn_usb_print_layout_default;    
+}
+
+RESOURCE TBUF r_usb_print_layout_1_up 
+{
+    buf = qtn_usb_print_layout_1_up;    
+}
+
+RESOURCE TBUF r_usb_print_layout_2_up 
+{
+    buf = qtn_usb_print_layout_2_up;    
+}
+
+RESOURCE TBUF r_usb_print_layout_4_up 
+{
+    buf = qtn_usb_print_layout_4_up;    
+}
+
+RESOURCE TBUF r_usb_print_layout_6_up 
+{
+    buf = qtn_usb_print_layout_6_up;    
+}
+
+RESOURCE TBUF r_usb_print_layout_9_up 
+{
+    buf = qtn_usb_print_layout_9_up;    
+}
+
+RESOURCE TBUF r_usb_print_layout_borderless 
+{
+    buf = qtn_usb_print_layout_borderless;    
+}
+
+// ---------------------------------------------------------------------------
+// Paper size strings
+// ---------------------------------------------------------------------------
+//
+
+RESOURCE TBUF r_usb_print_paper_size
+{
+    buf = qtn_usb_print_paper_size;    
+}
+
+RESOURCE TBUF r_usb_print_paper_size_automatic
+{
+    buf = qtn_usb_print_paper_size_automatic;  
+}
+
+RESOURCE TBUF r_usb_print_paper_size_a4
+{
+    buf = qtn_usb_print_paper_size_a4;  
+}
+
+RESOURCE TBUF r_usb_print_paper_size_a6
+{
+    buf = qtn_usb_print_paper_size_a6;  
+}
+
+RESOURCE TBUF r_usb_print_paper_size_inch
+{
+    buf = qtn_usb_print_paper_size_inch;  
+}
+
+RESOURCE TBUF r_usb_print_paper_size_card
+{
+    buf = qtn_usb_print_paper_size_card;  
+}
+
+RESOURCE TBUF r_usb_print_paper_size_letter
+{
+    buf = qtn_usb_print_paper_size_letter;  
+}
+
+// ---------------------------------------------------------------------------
+// Quality strings
+// ---------------------------------------------------------------------------
+//
+
+RESOURCE TBUF r_usb_print_quality
+{
+    buf = qtn_usb_print_quality;    
+}
+
+RESOURCE TBUF r_usb_print_quality_default
+{
+    buf = qtn_usb_print_quality_default;    
+}
+
+RESOURCE TBUF r_usb_print_quality_high
+{
+    buf = qtn_usb_print_quality_high;    
+}
+
+RESOURCE TBUF r_usb_print_quality_normal
+{
+    buf = qtn_usb_print_quality_normal;    
+}
+
+RESOURCE TBUF r_usb_print_quality_draft
+{
+    buf = qtn_usb_print_quality_draft;    
+}
+
+
+// ---------------------------------------------------------------------------
+// Printing Error strings
+// ---------------------------------------------------------------------------
+//
+
+RESOURCE TBUF r_error_unable_to_connect 
+                { 
+                buf = qtn_usb_error_unable_to_connect; 
+                }
+RESOURCE TBUF r_error_printer_busy 
+                { 
+                buf = qtn_usb_error_printer_busy; 
+                }
+RESOURCE TBUF r_error_connection_lost 
+                { 
+                buf = qtn_usb_error_connection_lost; 
+                } 
+RESOURCE TBUF r_error_general 
+                { 
+                buf = qtn_usb_error_in_printing; 
+                }
+RESOURCE TBUF   r_error_check_status 
+                { 
+                buf = qtn_usb_error_check_status; 
+                }
+RESOURCE TBUF r_error_out_of_paper 
+                { 
+                buf = qtn_usb_error_out_of_paper; 
+                }
+RESOURCE TBUF   r_error_out_of_ink 
+                { 
+                buf = qtn_usb_error_out_of_ink; 
+                }
+RESOURCE TBUF   r_error_ink_low 
+                { 
+                buf = qtn_usb_error_ink_low; 
+                }
+RESOURCE TBUF   r_error_paper_jam 
+                { 
+                buf = qtn_usb_error_paper_jam; 
+                }
+
+
+// ---------------------------------------------------------------------------
+// Other error strings
+// ---------------------------------------------------------------------------
+//
+
+RESOURCE TBUF r_error_file_not_supported 
+                { 
+                buf = qtn_usb_error_file_not_supported; 
+                }
+RESOURCE TBUF r_error_file_not_found 
+                { 
+                buf = qtn_usb_error_file_not_found; 
+                }
+
+RESOURCE TBUF r_error_unsupported_files_removed 
+                { 
+                buf = qtn_usb_error_unsupported_files_removed; 
+                }
+
+RESOURCE TBUF r_info__select_new_images 
+                { 
+                buf = qtn_usb_info_select_new_images; 
+                }
+RESOURCE TBUF r_info_app_in_use 
+                { 
+                buf = qtn_usb_info_app_in_use; 
+                }
+
+
+RESOURCE TBUF r_change_value {buf = qtn_usb_opt_change;}
+RESOURCE TBUF r_printing {buf = qtn_usb_option_print;}
+RESOURCE TBUF r_help  {buf = qtn_options_help;}
+RESOURCE TBUF r_qtn_print_progress_note_title { buf = qtn_usb_wait_printing; }
+
+
+// ---------------------------------------------------------------------------
+// Note resources
+// ---------------------------------------------------------------------------
+//
+
+// modified note resource
+RESOURCE DIALOG r_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EAknCtNote;
+            control = AVERELL_NOTE
+                {
+                layout = EProgressLayout;
+		            singular_label = qtn_usb_wait_printing;
+                imagefile = AVKON_ICON_FILE;
+                imageid = EMbmAvkonQgn_note_progress;
+                imagemask = EMbmAvkonQgn_note_progress_mask;                
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/data/imageprintui_reg.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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:  Resource definitions for project Image Print UI
+*
+*/
+
+
+#include <appinfo.rh>
+#include <imageprintui.rsg>
+#include <data_caging_paths_strings.hrh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x1020E470
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "imageprintui";
+
+    localisable_resource_file = APP_RESOURCE_DIR"\\imageprintui";
+    localisable_resource_id = R_IMAGEPRINTUI_LOCALISABLE_APP_INFO;
+    
+    hidden = KAppIsHidden;
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/data/phonecapability.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Resource definitions for phone capability
+*
+*/
+
+NAME IMPR
+
+#include <appinfo.rh>
+#include <badef.rh>
+#include "phonecapability.rh"
+
+
+RESOURCE BA_RSS_SIGNATURE { signature = 1; }
+
+RESOURCE phonecapability_configuration phonecapability_config
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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:
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../loc/imageprintui.loc             MW_LAYER_LOC_EXPORT_PATH(imageprintui.loc)
+../rom/imageprintui.iby             CORE_MW_LAYER_IBY_EXPORT_PATH(imageprintui.iby)
+../rom/imageprintuiresources.iby    LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(imageprintuiresources.iby)
+
+PRJ_MMPFILES
+imageprintui.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/group/imageprintui.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* 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:
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET                  imageprintui.exe
+TARGETTYPE              exe
+EPOCSTACKSIZE           0x5000
+UID                     0x100039CE 0x1020E470
+
+CAPABILITY              CAP_APPLICATION
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  imageprintuiapp.cpp
+SOURCE                  imageprintuiappui.cpp
+SOURCE                  imageprintuidocument.cpp
+
+SOURCE                  emptyview.cpp
+SOURCE                  emptycontainer.cpp
+SOURCE                  settingsview.cpp
+SOURCE                  settingscontainer.cpp
+SOURCE                  settingsitems.cpp
+
+SOURCE                  connectionmanager.cpp
+SOURCE                  capabilitymanager.cpp
+SOURCE                  eventmanager.cpp
+SOURCE                  requestmanager.cpp
+SOURCE                  notes.cpp
+SOURCE                  notetimer.cpp
+
+USERINCLUDE             ../inc
+
+
+START RESOURCE          ../data/imageprintui.rss
+HEADER
+TARGETPATH              APP_RESOURCE_DIR
+LANGUAGE_IDS
+END 
+
+
+START RESOURCE         ../data/phonecapability.rss
+HEADER
+TARGETPATH              /private/1020e470
+LANGUAGE_IDS
+END 
+
+
+
+START RESOURCE          ../data/imageprintui_reg.rss
+DEPENDS imageprintui.rsg
+TARGETPATH              /private/10003a3f/apps
+END 
+
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 euser.lib apparc.lib cone.lib eikcore.lib 
+LIBRARY                 eikcoctl.lib avkon.lib
+LIBRARY                 bafl.lib            // Basic Application Framework 
+LIBRARY                 AknSkins.lib        // Skinned icons
+LIBRARY                 aknicon.lib
+LIBRARY                 commonengine.lib    // Series 60 common components library
+LIBRARY                 pictbridge.lib
+LIBRARY                 eikcdlg.lib eikctl.lib estor.lib efsrv.lib
+LIBRARY                 ServiceHandler.lib 
+LIBRARY                 DRMCommon.lib
+LIBRARY                 ImageConversion.lib
+LIBRARY                 PlatformEnv.lib // PathInfo
+LIBRARY                 CommonUI.lib
+
+
+
+#ifdef __SERIES60_HELP
+LIBRARY hlplch.lib                          // Help library
+#endif
+
+
+DEBUGLIBRARY            flogger.lib         // File logging services
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/group/imageprintui_icons_aif_bitmaps_dc.mk	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,71 @@
+#
+# 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:  Fork icon for Image Print UI. 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\imageprintui_aif.mbm
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\imageprintui.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_usb.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/group/imageprintui_icons_aif_scalable_dc.mk	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,71 @@
+#
+# 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:  Fork icon for Image Print UI. 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\imageprintui_aif.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\imageprintui.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_usb.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/capabilitymanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,276 @@
+/*
+* 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:  Header file for capabilitymanager
+*
+*/
+
+
+#ifndef CAPABILITYMANAGER_H
+#define CAPABILITYMANAGER_H
+
+#include <e32base.h>
+#include <pictbridge.h>
+#include <dpsoperation.h>
+#include <dpsparam.h>
+#include <badesca.h>
+
+
+const TInt KPhoneCapabilityVersion = 0;
+const TInt KRetryAsk = 2 * 100 * 1000; // 200 ms
+const TInt KDefaultArray = 5;
+_LIT(KPhoneCapability, "private\\1020e470\\phonecapability.rsc");
+
+class CImagePrintUiAppUi;
+
+/**
+* CCapabilityManager is an active object that sends an asynchronous request 
+* to retrieve capabilities
+*/
+class CCapabilityManager : public CActive
+    {
+        
+public:
+
+    /**
+    * Factory method NewL
+    * @param aOwner  The observer to be notified on the change. 
+    * @param aEngine the pointer to the PictBridge engine
+    * @return instance of capability manager        
+    */
+    static CCapabilityManager* NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine);
+
+
+    /**
+    * Destructor.
+    */
+    virtual ~CCapabilityManager();
+        
+       
+    /**
+     * Gives current qualities for doDpsRequest 
+     * 
+     */   
+     TUint Quality();
+
+	
+	/**
+     * Gives current paper size for doDpsRequest
+     * 
+     */  
+     TUint PaperSize();
+	
+	/**
+     * Gives current  paper layout for doDpsRequest
+     * 
+     */  
+     TUint Layout();
+    
+	/**
+     * Gives current print setting to UI
+     * 
+     */  
+	 TUint CurrentPrintSettings(TInt aDpsArg);
+	
+	/**
+     * All qualities asked by UI engine
+     * @param aReason the answer for request complete to UI capability query 
+     */  
+	void QualitiesAsked(TInt aReason);
+
+
+    /**
+     * Return certain type list of Capabilities
+     * @param aCapability the Capabilities type requested
+     */
+    RArray<TUint>& GetCapabilities(TInt aCapability);
+    
+    /**
+    * Stores value choosed by user
+    */
+    void SetValue(TInt aCapability, TUint aValue);
+    
+    /**
+    * Ask capabilities when needed
+    *
+    */
+    void AskCapabilitiesL(TBool aChanged);
+    
+    
+     /**
+    * Ask layout when user has selected certain papersize
+    *
+    */
+    void AskLayoutForPaperSizeL(TUint aPaperSize);
+    
+    
+    
+    /**
+    * Check if capabilities differ when user start print
+    *
+    */ 
+    void CheckIfNewCapabilityDiffer();
+   
+
+private: //from CActive
+    /**
+    *	Implements CActive
+    *   If this is not a one-shot CR watcher, the listening is restarted.
+    *	@param none
+    *	@return none
+    */
+    void RunL();
+    
+    /**
+    *	Implements CActive
+    *	@param aError the error returned
+    *	@return error
+    */
+    TInt RunError(TInt aError);
+
+    /**
+    *	Implements CActive
+    *	@param none
+    *	@return none
+    */
+    void DoCancel();
+    
+    
+    /**
+     * Stores current qualities 
+     * 
+     */   
+    void StoreQualitiesL(RArray<TUint>& aCurrQualities);
+    
+    /**
+     * Stores current paper size 
+     * 
+     */   
+    void StorePaperSizeL(RArray<TUint>& aSuppPaperSize);
+    
+    /**
+     * Stores current first paper layout 
+     * 
+     */    	
+     void StoreLayouts(RArray<TUint>& aSuppLayouts);
+    
+    /**
+     * Ask quality from printer
+     */  
+    void AskQualityL();
+    
+    /**
+     * Ask paper size from printer 
+     */  
+    void AskPaperSizeL();
+    
+    /**
+     *  Ask layout from printer
+     */  
+    void AskLayoutL();
+    
+
+private: //own methods
+
+    enum TCapabilityType
+    	{
+		EQualities,
+		EPaperSize,
+		ELayouts
+  		};    
+
+   /**
+    *   Second phase constructor. Operations which might leave should 
+    *   be called here
+    */ 
+    void ConstructL();
+
+       
+    /**
+    * Handles capabilities after RunL
+    *
+    */
+    void HandleCapabilitiesL(TCapabilityType aType);
+    
+    /**
+    * Read phone supported capabilities
+    *
+    */
+    void GetPhoneConfigL();
+
+    /**
+    * C++ default constructor
+    * @param aAppUi the pointer to the AppUi instance 
+    * @param aEngine the pointer to the PictBridge engine
+    */
+    CCapabilityManager( CImagePrintUiAppUi* aAppUi, 
+                        CDpsEngine* aEngine);
+    
+    
+    
+    /**
+    * Handles result of asking layout for certain papersize
+    *
+    */ 
+    void HandleLayoutForPaperSize();
+      
+     
+private: //data
+    
+    CImagePrintUiAppUi* iAppUi;
+    
+    /**
+     * Instance to PictBridge Engine to get capabilities
+     * Not own
+     */
+    CDpsEngine* iDpsEngine; 
+    
+    TBool iCapabilityAskFailed;
+    TBool iCapabilityNotChanged;
+    TBool iIsCapabilityEmpty;
+    TBool iLayoutForPaperSize;
+    
+    TCapabilityType iCapabilityType;
+    
+    // types for DoDpsRequest
+    TDpsGetCapability      iCap;
+        
+    
+    //Arrays for storing and maintaining capabilities data after 
+    //comparing printer and phone supported capabilities
+    RArray<TUint> iCurrentQualities; 
+    RArray<TUint> iCurrentPaperSizes;
+    RArray<TUint> iCurrentLayouts;
+    
+        
+    TUint iCurrentQuality;
+    TUint iCurrentPaperSize;
+    TUint iCurrentLayout;
+    
+    TUint iUserSelectedQuality;
+    TUint iUserSelectedPaperSize;
+    TUint iUserSelectedLayout;
+    
+    //phone supported capabilities
+    RArray<TUint>  iPhoneSuppLayout;   
+    RArray<TUint>  iPhoneSuppPaperSize;   
+    RArray<TUint>  iPhoneSuppQuality;  
+    
+    RArray<TUint> iReturnArray;  
+     
+    };
+
+
+#endif      // CAPABILITYMANAGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/connectionmanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,121 @@
+/*
+* 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:  Header file for connectionmanager
+*
+*/
+
+
+#ifndef CONNECTIONMANAGER_H
+#define CONNECTIONMANAGER_H
+
+#include <e32base.h>
+
+class CDpsEngine; 
+class CNotes;
+class CImagePrintUiAppUi;
+
+/**
+* CConnectionManager is an active object that sends an asynchronous request 
+* to know about the connection status.
+*/
+class CConnectionManager : public CActive 
+    {
+        
+public:
+
+    /**
+     * Factory method NewL
+     * @param aAppUi the pointer to the AppUi instance 
+     * @param aEngine    Instance to DpsEngine
+     * @param aNotes     Instance to Notes class
+     * @return           The new object. 
+     */
+    static CConnectionManager* NewL(CImagePrintUiAppUi* aAppUi, 
+    						        CDpsEngine* aEngine, CNotes* aNotes);
+
+   /**
+    * Destructor.
+    */
+   virtual ~CConnectionManager();
+
+   /**
+    * Starts search printer
+    */
+   void StartSearchPrinter();
+
+private: 
+
+//from CActive
+
+    /**
+     *	Implements CActive
+     *	@param none
+     *	@return none
+     */
+    void RunL();
+    
+    /**
+     *  Implements CActive
+     *  @param aError the error returned
+     *  @return error
+     */
+    TInt RunError(TInt aError);
+
+    /**
+     *	Implements CActive
+     *	@param none
+     *	@return none
+     */
+    void DoCancel();
+
+private: 
+
+    /**
+     * Starts listening for notifications. If already listening, nothing 
+     * happens.
+     * @param none
+     * @return none
+     */
+    void StartListening();
+
+    /**
+     * C++ default constructor
+     * @param aAppUi the pointer to the AppUi instance  
+     * @param aEngine   Instance of DpsEngine
+     * @param aNotes     Instance to Notes class
+     */
+    CConnectionManager( CImagePrintUiAppUi* aAppUi, 
+                        CDpsEngine* aEngine, CNotes* aNotes);
+     
+private: //data
+
+
+    CImagePrintUiAppUi* iAppUi;
+
+    /**
+     * Instance to DpsEngine to get connection status
+     * Not own
+     */
+    CDpsEngine* iDpsEngine; 
+
+    TBool iActiveNote;
+    TBool iSetPrintCall;
+    CNotes* iNotes;
+    TInt iPreviousStatus;
+    };
+
+
+#endif      // CONNECTIONMANAGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/emptycontainer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* 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:  Header file for emptycontainer
+*
+*/
+
+#ifndef CEMPTYCONTAINER_H
+#define CEMPTYCONTAINER_H
+
+
+// INCLUDES
+#include <coecntrl.h>
+
+
+// FORWARD DECLARATIONS
+class CAknsBasicBackgroundControlContext;
+
+
+/**
+* Container class for emptyview
+*/
+class CEmptyContainer : public CCoeControl
+    {
+
+
+public:
+
+    /**
+     * Factory method NewL
+     * @param aRect Container area 
+     * @return   The new object. 
+     */ 
+    static CEmptyContainer* NewL( const TRect& aRect );
+
+    /**
+     * Factory method NewLC
+     * @param aRect Container area 
+     * @return   The new object. 
+     */ 
+    static CEmptyContainer* NewLC( const TRect& aRect );
+
+
+    /**
+    * Destructor.
+    */
+    virtual ~CEmptyContainer();
+    
+
+private: // Methods derived from CCoeControl
+
+
+   /**
+    * From CCoeControl Draw screen
+    */
+    void Draw( const TRect& aRect ) const;	
+    
+   /**
+    * From CCoeControl Handles a chage of client area size.
+    */
+    void SizeChanged(); 	
+
+   /**
+    * From CCoeControl, Handles a change to the control's resources.
+    */
+    void HandleResourceChange( TInt aType ); 	
+
+   
+private:
+
+   /**
+    * C++ default constructor
+    */
+    CEmptyContainer();
+
+   /**
+    *   Second phase constructor. Operations which might leave should 
+    *   be called here
+    */ 
+    void ConstructL( const TRect& aRect );
+
+
+private: // data
+
+    CAknsBasicBackgroundControlContext* iSkinContext; // skin data
+
+    };
+
+#endif // CEMPTYCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/emptyview.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* 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:  Header file for emptyview
+*
+*/
+
+#ifndef CIMAGEPRINTEMPTYVIEW_H
+#define CIMAGEPRINTEMPTYVIEW_H
+
+
+#include <aknview.h>
+
+// FORWARD DECLARATIONS
+class CEmptyContainer;
+
+const TUid KImagePrintEmptyViewId = { 1 };
+
+/**
+*  Class for showing empty view before capabilities has retrieved
+*/
+class CEmptyView : public CAknView
+    {
+
+public:
+
+   /**
+    * Factory method NewL
+    * @return   The new object. 
+    */ 
+    static CEmptyView* NewL();
+
+   /**
+    * Factory method NewLC
+    * @return   The new object. 
+    */ 
+    static CEmptyView* NewLC();
+
+   /**
+    * Destructor.
+    */ 
+    virtual ~CEmptyView();
+    
+private: // from base class CAknView
+
+    /**
+     * From CAknView 
+     * Returns view id.
+     * @param None.
+     * @return View id.
+     */
+    TUid Id() const;
+
+    /**
+     * From CAknView 
+     * Handles user commands.
+     * @param aCommand A command id.        
+     * @return None.
+     */
+    void HandleCommandL(TInt aCommand);
+
+    /**
+     * From CAknView 
+     * Activates view.
+     * @param aPrevViewId Id of previous view.
+     * @param aCustomMessageId Custom message id.
+     * @param aCustomMessage Custom message.
+     * @return None.
+     */
+    void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+                     const TDesC8& aCustomMessage);
+
+    /**
+     * From CAknView 
+     * Deactivates view.        
+     * @param None.
+     * @return None.
+     */
+    void DoDeactivate();
+
+   /**
+    * C++ default constructor
+    */
+    CEmptyView();
+
+    /**
+     * Symbian 2nd phase constructor.
+     * @param None
+     * @return None
+     */
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Container control of this view
+     * Own
+     */
+    CEmptyContainer* iContainer; 
+ 
+    };
+
+#endif // CIMAGEPRINTEMPTYVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/eventmanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Header file for eventmanager
+*
+*/
+
+
+
+#ifndef C_EVENTMANAGER_H
+#define C_EVENTMANAGER_H
+
+#include <dpsoperation.h>
+#include <dpsparam.h>
+#include <eikenv.h>
+
+class CDpsEngine;
+class CImagePrintUiAppUi;
+
+/**
+*  Class for requesting DPS event
+*/
+class CEventManager : public CActive
+    {
+    
+public:
+
+    enum TEventNotifyType
+    	{
+    	ENewJobOK = 1,
+    	ENewJobNOK,
+    	EInkEmpty,
+    	ECapabilityChange,
+    	EWarning,
+    	EErrorState,
+    	ENotErrorState,
+    	ESeriousError,
+		EShowError
+    	};     
+
+public:
+
+    /**
+     * Two-phase constructors
+     * @since S60 v3.2 
+     * @param aAppUi the pointer to the AppUi instance  
+     * @param aEngine   Instance of DpsEngine
+     * @return  Initialiazed instance of EventManager 
+     */
+    static CEventManager* NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aDpsEngine);
+
+    /**
+     *  Destructor.
+     */	
+    virtual ~CEventManager();
+    
+
+    
+private:
+
+   /**
+    *   @see CActive
+    */
+    void RunL();
+    
+   /**
+	*   @see CActive
+	*/
+    void DoCancel();
+    
+    /**
+	*   @see CActive
+	*/
+    void RunError();
+
+
+private:
+
+    
+    /**
+     * C++ default constructor
+     * @param aAppUi the pointer to the AppUi instance  
+     * @param aEngine   Instance of DpsEngine
+     */
+    CEventManager(CImagePrintUiAppUi* aAppUi, CDpsEngine* aDpsEngine);
+
+
+     /**
+     * Handles return status  from PictBridge Engine.  
+     * 
+     */
+	void HandleReturnStatusL();
+	
+	
+    /**
+     * Start listening events from PictBridge Engine.  
+     * 
+     */
+	void StartListening();
+	
+	/**
+     * Handles error status  
+     * 
+     */
+	void HandleErrorStatusL(TInt aStatus);
+	
+	/**
+     * Handles job status  
+     * 
+     */
+	void HandleJobStatusL(TInt aStatus);
+	
+	/**
+     * Handles hardware error.  
+     * 
+     */
+    void HandleHardwareErrorL(TInt aError);
+    
+    
+    /**
+     * Handles ink error.  
+     * 
+     */
+    void HandleInkErrorL(TInt aError);
+    
+    /**
+     * Handles paper error.  
+     * 
+     */
+    void HandlePaperErrorL(TInt aError);
+    
+    /**
+     * Handles file error.  
+     * 
+     */
+    void HandleFileErrorL(TInt aError);
+    
+private: 
+    
+    CImagePrintUiAppUi* iAppUi;
+    CDpsEngine*      iDpsEngine;
+    TDpsEvents       iEventRequest;
+    TBool            iErrorState;
+   
+    };
+
+
+#endif // C_EVENTMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/imageprintui.hrh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* 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:  Resource headers for project Image Print UI
+*
+*/
+
+
+
+#ifndef IMAGEPRINTUI_HRH
+#define IMAGEPRINTUI_HRH
+
+enum TCustomControlsIDs
+    {
+    EPrintProgressNote = 0x2000,
+    EPrintWaitNote,
+    ENoPrintersConfirmation,
+    EBitmapCtrl,
+    EBrandingBitmap
+    };
+
+
+/** Commands in settings view */
+enum TImagePrintSettingsCommands
+    {
+    ECmdSettingsChange = 0x6100,
+    ECmdSettingsPrint,
+    ECmdSettingsHelp
+    
+    };
+
+enum TImagePrintSettingsListItemIndexes
+    {
+    ESettingsListItemLayout = 0,
+    ESettingsListItemPaperSize,
+    ESettingsListItemPrintQuality
+    };
+
+/* note enums */
+enum 
+	{
+	EProgressNoteId = 0
+	};
+
+
+#define KImagePrintComponentCount 1
+
+
+#define KNumberOfSettingsViewItems 3
+
+
+
+#endif // IMAGEPRINTUI_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/imageprintuiapp.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* 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:  Header file for imageprintuiapp 
+*
+*/
+
+
+#ifndef CIMAGEPRINTUIAPP_H
+#define CIMAGEPRINTUIAPP_H
+
+//  EXTERNAL INCLUDES
+#include <e32base.h>
+#include <aknapp.h>
+
+//  CONSTANTS
+/**
+* UID of the application
+*/
+const TUid KUidImagePrint = { 0x1020E470 };
+const TUid KUidUSB = { 0x102068E2 }; 
+
+//  CLASS DEFINITION
+/**
+ * S60 Application class
+ */
+class CImagePrintUiApp : public CAknApplication
+	{
+
+private:	// Constructors and destructors
+
+    /**
+     * From CAknApplication, creates CImagePrintUiDocument document
+     * object.
+     * @return A pointer to the created document object.
+     */
+    CApaDocument* CreateDocumentL();
+
+private:	// Methods derived from CApaApplication
+
+    /**
+     * From CAknApplication, returns application's UID.
+     * @return The value of KUidImagePrint.
+     */
+    TUid AppDllUid() const;
+
+    };
+
+#endif // IMAGEPRINTUIAPP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/imageprintuiappui.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,336 @@
+/*
+* 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:  Header file for imageprintuiappui
+*
+*/
+
+
+#ifndef C_CIMAGEPRINTUIAPPUI_H
+#define C_CIMAGEPRINTUIAPPUI_H
+
+#include <aknViewAppUi.h>
+#include <AknProgressDialog.h>
+#include <AknWaitDialog.h>
+#include <badesca.h>
+#include "connectionmanager.h"
+#include "capabilitymanager.h"
+#include "eventmanager.h"
+#include "requestmanager.h"
+
+#include <AiwServiceIfMenu.h>
+#include <GenericParamConsumer.h>
+#include <eikenv.h>
+
+#include <pictbridge.h>
+
+class CNotes;
+class CNoteTimer;
+class CAknNavigationDecorator; 
+class DRMCommon;
+ 
+ 
+const TInt KNumberOfUnsupportedFiles = 1; 
+const TInt KPrintFinishValue = 100; 
+const TInt KMaxPrinterName = 64; 
+const TInt KRetryInterval = 1 * 1000 * 1000; // 1 s
+const TInt KRetryClose = 1 * 1000 * 1000; // 1 s
+const TInt KImageDefaultArray = 2;
+const TInt KRemoveValue = 5;
+const TInt KImageNumber = 1;
+
+// CONSTANTS
+_LIT( KConfigInfoFile, "config.DPS");
+_LIT( KParamFile, "system\\data\\T_AIW_PRINT.DAT");
+_LIT( KUnSuppFile, "system\\data\\T_AIW_UNSUPP.DAT");
+const TInt KResource = 40;
+const TInt KDriver = 3;
+const TInt KConfigLength = 16;
+
+ 
+/**
+ *  S60 application UI class
+ */
+class CImagePrintUiAppUi : public CAknViewAppUi                                           
+    {
+
+public:
+
+   /**
+    *   Destructor
+    */	 
+    virtual ~CImagePrintUiAppUi();
+
+
+   /**
+    *   Second phase constructor. Operations which might leave should 
+    *   be called here
+    */ 
+    void ConstructL();
+    
+    /**
+     * Returns instance of Capability Manager. 
+     * @return CCapabilityManager.
+     */
+    CCapabilityManager* CapabilityManager();
+    
+    
+    /**
+     * Returns instance of Notes
+     * @return CNotes.
+     */
+    CNotes* Notes();
+    
+
+public:	// Methods derived from CAknViewAppUi base class
+
+    void HandleCommandL( TInt aCommand );
+
+    
+public: //own methods
+
+
+    /**
+     * Starts printing process when user select print
+     * @return none
+     */
+    void StartPrinting();
+    
+    /**
+     * Cancel print when user select cancel
+     * @return none
+     */
+    void CancelPrinting();
+    
+    /**
+     * Returns print state to other instances
+     * @return print state
+     */
+    TBool PrintActive();
+	
+	/**
+     * Provide array of images to be printed
+     * @return CDesCArrayFlat
+     */
+    CDesCArrayFlat* ImagesToPrint();
+    
+    /**
+     * Tells if cable is connected or not
+     * @return TBool .
+     */
+    TBool IsCableConnected();
+    
+    /**
+     * Shows note if there is unsupported files
+     * @return none.
+     */
+    void ShowNoteL();
+    
+    /**
+     * Closes application after showing error  note
+     * @return none.
+     */
+    void CloseAfterNoteL();
+     
+
+    /**
+     * Request Manager notifies result of DoDps Request 
+     * @return none.
+     */ 
+    void NotifyRequestL( TInt aNotifyType);
+    
+    /**
+     * Request Manager informs about number of images to be printed
+     * @return none.
+     */ 
+    void NumberOfImages(TInt aNumberOfImages);
+    
+
+    /**
+     * Event Manager notifies DpsEvent 
+     * @return none.
+     */  
+    void NotifyEventL(TInt aEventNotifyType);
+    
+    /**
+     * Event Manager notifies about Print Progress 
+     * @return none.
+     */ 
+    void NotifyPrintProgress(TInt aNumberOfImages, TInt aProgress);
+    
+    /**
+     * Event Manager notifies about Print Status
+     * @return none.
+     */ 
+    void NotifyPrintStatus(TInt aStatus);
+
+
+    /**
+     * Connection Manager closes application if cable is disconnect
+     * or personaluty changes different as PTP
+     * @return none.
+     */ 
+    void CloseApplication(TBool aDisconnect);
+
+    /**
+     * Connection Manager informs PTP printer is found
+     * @return none.
+     */ 
+    void CableConnectedL(); 
+    
+    /**
+     * Connection Manager informs about cable disconnection
+     * @return none.
+     */ 
+    void CableDisConnected();
+
+
+    /**
+     * Capability Manager informs about capabilities has
+     * retrieved from printer
+     * @return none.
+     */ 
+    void CapabilitiesReady(); 
+    
+    /**
+     * Capability Manager informs about error when retrieving
+     * capabilities from printer
+     * @return none.
+     */ 
+    void NotifyError();
+    
+    /**
+     * Handles situation after timer timeout
+     * @return none.
+     */ 
+    void HandleTimeOutL();
+    
+    /**
+     * Handles requesting DPS request again
+     * @return none.
+     */ 
+    void HandleRequestTime(TInt aTime);
+    
+    /**
+     * Handles requsting capabilities again
+     * @return none.
+     */ 
+	void HandleCapabilityTime(TInt aTime);
+	
+	
+	/**
+     * Handles situation after RunError in timer
+     * @return none.
+     */ 
+	void HandleTimeErrorL(TInt aError);
+    
+
+private: //own methods
+
+
+    /**
+     * Set printer and vendor info to navipane
+     * @return none.
+     */
+    void SetNavipaneTextL();
+    
+    /**
+     * Read images to be printed to array
+     * @return none.
+     */
+    void LoadImagesL();
+    
+    /**
+     * Reads number of unsupported files
+     * @return none.
+     */
+    void ReadNumberOfUnSuppL();
+    
+public:
+
+	/**
+     * Show all notes
+     * Own this pointer
+     */
+    CNotes*  iNotes;   
+    
+
+private: // data
+
+
+    /** A singleton DPS engine object */
+    CDpsEngine* iEngine; 
+
+    /**
+     * Connection manager to check connection status
+     * Owns this pointer 
+     */
+    CConnectionManager* iConnectionManager;
+
+    /**
+     * Retrieve, restore and change capabilities if needed 
+     * Own this pointer
+     */
+    CCapabilityManager* iCapabilityManager;
+    
+        
+    /**
+     * Needed when creating navipane text
+     * Own this pointer
+     */
+    CAknNavigationDecorator* iNaviDecorator; 
+    
+    
+    /**
+     * Performs DPS request towards PictBridge engine
+     * Own this pointer
+     */
+    CRequestManager* iRequestManager;
+    
+    
+    /**
+     * Notifies Device- and JobEvent coming from PictBridge engine
+     * Own this pointer
+     */
+    CEventManager* iEventManager;
+    
+    
+    // images to be printed
+    CDesCArrayFlat* iImageFiles;
+    
+    // timer for unsupported file note
+    CNoteTimer* iNoteTimer;
+    
+    HBufC* iCongFileName;
+    
+    TBool iPrintActive;
+    TBool iCableConnected;
+    TBool iActiveNote;
+    TBool iCapabilityChanged;
+    TBool iUnsupportedFiles;
+    TBool iNoteShowed;
+    TInt  iNumberOfImages;
+    TInt  iNumberOfUnSuppFiles;
+    TBool iErrorState;
+    TBool iStartJobOK;
+    TBool iPaperEmpty;
+    TBool iNoteTimeOut;
+    TBool iCloseTimeOut;
+    TBool iCapabilityTimeOut;
+    TBool iRequestTimeOut;
+    
+    TFileName     iLogFilePath; 
+
+    };
+
+#endif // C_CIMAGEPRINTUIAPPUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/imageprintuidebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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:  Log file for Image Print UI
+*
+*/
+
+
+#ifndef IMAGEPRINTUIDEBUG_H
+#define IMAGEPRINTUIDEBUG_H
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"imageprintui.txt");
+_LIT(KLogDirFullName,"c:\\logs\\imageprint\\");
+_LIT(KLogDir,"imageprint");
+
+// 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);
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+inline void FPrint(const TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    TInt tmpInt = VA_ARG(list, TInt);
+    TInt tmpInt2 = VA_ARG(list, TInt);
+    TInt tmpInt3 = VA_ARG(list, TInt);
+    VA_END(list);
+    RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
+    }
+
+inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+    {
+
+	VA_LIST list;
+	VA_START(list, aFmt);
+    TBuf8<256> buf8;
+	buf8.AppendFormatList(aFmt, list);
+
+    TBuf16<256> buf16(buf8.Length());
+    buf16.Copy(buf8);
+
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    }
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // IMAGEPRINTDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/imageprintuidocument.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,93 @@
+/*
+* 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:  Header file for imageprintuidocument
+*
+*/
+
+
+
+#ifndef IMAGEPRINTUIDOCUMENT_H
+#define IMAGEPRINTUIDOCUMENT_H
+
+#include <AknDoc.h>
+#include <pictbridge.h>
+#include <e32cmn.h>
+#include <AiwGenericParam.h>
+#include <GenericParamConsumer.h>
+#include <badesca.h>
+
+
+
+// FORWARD DECLARATIONS
+class CEikAppUi; 
+class CImagePrintUiEngine; 
+/**
+ *   
+ *  S60 document class
+ */
+class CImagePrintUiDocument : public CAknDocument
+    {
+
+public:
+    
+    /**
+     * Factory method NewL
+     * @param aApp refernce to CEikApplication class   
+     * @return The new object. 
+     */
+    static CImagePrintUiDocument* NewL(CEikApplication& aApp);
+
+   /**
+    * Destructor.
+    */ 
+    virtual ~CImagePrintUiDocument();
+
+
+private:
+
+    /**
+     * Default contructor
+     */
+    CImagePrintUiDocument(CEikApplication& aApp);
+    
+    /**
+     * Default contructor that may leave. 
+     */
+    void ConstructL();
+
+
+private: //  From base class CAknDocument
+
+    /**
+      * Returns AppUi class
+      * @return Initialized instance of CEikAppUi
+      */
+    CEikAppUi* CreateAppUiL();
+
+
+public: // New methods
+
+    /**
+      * Returns Engine
+      * @Return PictBridge Engine
+      */
+	CDpsEngine* Engine();
+	
+private: // data
+    
+    // Instance to the engine of this application, own
+     CDpsEngine* iEngine;
+    };
+
+#endif //  C_IMAGEPRINTUIDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/notes.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Header file for notes
+*
+*/
+
+#ifndef CNOTES_H
+#define CNOTES_H
+
+
+#include <aknview.h>
+#include <AknProgressDialog.h>
+#include <AknWaitDialog.h>
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class MProgressDialogCallback; 
+class CEikProgressInfo;
+class CImagePrintUiAppUi;
+
+
+
+/**
+* Class for showing different notes
+*/
+class CNotes :  public CBase, public MProgressDialogCallback
+    {
+
+public:
+
+   
+    /**
+     * Factory method NewL
+     * @param aPrintUiAppUi the pointer to AppUi class
+     * @return   the new object 
+     */
+    static CNotes* NewL(CImagePrintUiAppUi* aPrintUiAppUi);
+
+   /**
+    * Destructor.
+    */ 
+    virtual ~CNotes();
+    
+    
+    /**
+     * Shows all string based info notes
+     * @return none
+     */  
+    void ShowInfoNoteL(TInt aResourceId );
+    /**
+     * Shows all string based wait notes
+     * @return none
+     */  
+    void ShowNoteL(TUint aNoteType);
+    
+    /**
+     * Shows print progress note
+     * @return none
+     */  
+    void ShowProgressNoteL();
+    
+    /**
+     * Informs printing progress
+     * @return none
+     */  
+    void PrintProgress(TUint aProgress );
+    
+    /**
+     * Informs printing progrees 
+     * @return none
+     */  
+    void PrintProgressL(TUint aProgress );
+    
+    /**
+     * Prepare print progress note
+     * @return none
+     */  
+    void PrepareShowProgressNoteL();
+    
+    /**
+     * Shows all string based error messages
+     * @return none
+     */  
+    void ShowErrorMsgL(TUint aErr );
+    
+    /**
+     * Stop shows all string based notes
+     * @return none
+     */  
+    void StopShowNote(TUint aNoteType);
+    
+    /**
+     * Start show printing note
+     * @return none
+     */  
+    void StartPrintingNotesL();
+    
+    /**
+     * Finish print progress note
+     * @return none
+     */  
+    void PrintFinished();
+    
+    /**
+     * Sat cancel state
+     * @return none
+     */  
+    void SetCancelState(TBool aCancel);
+    
+    /**
+     * Set disconnect state
+     * @return none
+     */  
+    void SetDisconnectState(TBool aDisconnect);
+	    
+  
+public: 
+
+    /**
+    * From MProgressDialogCallback 
+    * Get's called when a dialog is dismissed.        
+    * @param aButtonId Id of the pressed button.
+    * @return None.
+    */
+    void DialogDismissedL( TInt aButtonId );
+
+private:
+
+    /**
+     * C++ default constructor
+     * @param aPrintUiAppUi the pointer to AppUi class 
+     */     
+     CNotes(CImagePrintUiAppUi* aPrintUiAppUi );
+     
+private: // data
+
+    /**
+     * Wait dialog for telling the user to connect the cable
+     * Own
+     */    
+    CAknWaitDialog* iWaitNote;
+    
+    CAknProgressDialog* iProgressDialog;
+    CImagePrintUiAppUi* iPrintUiAppUi;
+    TBool iDisconnect;
+    TBool iCancelling;
+ 
+    };
+
+#endif // CNOTES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/notetimer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Header file for note timer
+*
+*/
+
+
+
+#ifndef C_NOTETIMER_H
+#define C_NOTETIMER_H
+
+#include <e32base.h>
+
+class CImagePrintUiAppUi;
+
+/**
+* Timer for showing notes in right time
+*/
+class CNoteTimer : public CTimer
+    {
+public:
+
+    /**
+    * Factory method NewL
+    * @param aAppUi the pointer to the appui class
+    * @return instance of notetimer        
+    */
+    static CNoteTimer* NewL( CImagePrintUiAppUi* aAppUi);
+    
+    /**
+    * Factory method NewLC
+    * @param aAppUi the pointer to the appui class
+    * @return instance of notetimer        
+    */
+    static CNoteTimer* NewLC( CImagePrintUiAppUi* aAppUi);
+    
+   /**
+    * Destructor.
+    */
+    ~CNoteTimer();
+
+   
+private:
+    
+   /**
+    *   @see CActive
+    */
+    virtual void RunL();
+    
+   /**
+    *   @see CActive
+    */
+    TInt RunError(TInt aError);
+
+   /**
+    * C++ default constructor
+    */
+    CNoteTimer();
+    
+   /**
+    *   Second phase constructor. Operations which might leave should 
+    *   be called here
+    * @param aAppUi the pointer to the appui class
+    */  
+    void ConstructL(CImagePrintUiAppUi* aAppUi);
+
+private:
+
+    CImagePrintUiAppUi* iAppUi;
+    };
+    
+#endif // C_NOTETIMER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/phonecapability.rh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* 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 resource header file for Phone capability configuration. 
+*
+*/
+
+
+
+STRUCT phonecapability_configuration 
+    {
+    BYTE QualityCount = 4;
+    BYTE PaperSizeCount = 6;
+    BYTE LayoutCount = 6;
+
+    WORD EDpsPrintQualityDefault = 0x5000; 
+    WORD EDpsPrintQualityNormal =  0x5001; 
+    WORD EDpsPrintQualityDraft =   0x5002; 
+    WORD EDpsPrintQualityFine =    0x5003; 
+
+    WORD EDpsPaperSizeDefault =    0x5100; 
+    WORD EDpsPaperSizeCard =       0x5104; 
+    WORD EDpsPaperSize4x6 =        0x5106; 
+    WORD EDpsPaperSizeLetter =     0x5108; 
+    WORD EDpsPaperSizeA4 =         0x5114; 
+    WORD EDpsPaperSizeA6 =         0x5116; 
+    
+    WORD EDpsLayoutDefault = 	   0x5700; 
+    WORD EDpsLayout1Up =         0x5701; 
+    WORD EDpsLayout2Up =         0x5702;
+    WORD EDpsLayout4Up =         0x5704;
+    WORD EDpsLayout6Up =         0x5706; 
+    WORD EDpsLayout9Up =         0x5709; 
+    } 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/requestmanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,237 @@
+/*
+* 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:  Header file for requestmanager  
+*
+*/
+
+
+#ifndef C_REQUESTMANAGER_H
+#define C_REQUESTMANAGER_H
+
+#include <dpsoperation.h>
+#include <dpsparam.h>
+#include <badesca.h>
+
+class CDpsEngine;
+class CCapabilityManager;
+class CImagePrintUiAppUi;
+
+const TInt KDefaultSize = 64;
+
+
+/**
+* Class for requesting DPS request
+*/
+class CRequestManager : public CActive
+    {
+
+public:
+
+     enum TRequestType
+    	{
+    	EConfigurePrintService = 0,
+    	EGetCapability,
+    	EGetJobStatus,
+    	EGetDeviceStatus,
+    	EStartJob,
+    	EAbortJob,
+    	EContinueJob,
+    	ESetPrintMode
+    	}; 
+    	
+    enum TNotifyType
+    	{
+    	EConfigurePrintServiceOK = 1,
+    	EConfigurePrintServiceNOK,
+    	EGetCapabilityOK,
+    	EGetJobStatusOK,
+    	EGetJobStatusNOK,
+    	EGetDeviceStatusOK,
+    	EGetDeviceStatusNOK,
+    	EStartJobOK,
+    	EStartJobNOK,
+    	EAbortJobOK,
+    	EAbortJobNOK,
+    	EContinueJobOK,
+    	EPicturesNotFound
+    	}; 	
+
+    /**
+     * Two-phase constructors
+     * @param aDpsEngine the pointer to the PictBridge engine
+     * @param aCapabilityManager the pointer to the Capability Manager
+     * @param aAppUi the pointer to the AppUi class
+     * @return  Initialized instance of CRequestManager
+     */
+    static CRequestManager* NewL( CDpsEngine* aDpsEngine, 
+                                  CCapabilityManager* aCapabilityManager, CImagePrintUiAppUi* aAppUi);
+    
+    /**
+     * Two-phase constructors
+     * @param aDpsEngine the pointer to the PictBridge engine
+     * @param aCapabilityManager the pointer to the Capability Manager
+     * @param aAppUi the pointer to the AppUi class
+     * @return  Initialized instance of CRequestManager
+     */
+    static CRequestManager* NewLC( CDpsEngine* aDpsEngine, 
+                                   CCapabilityManager* aCapabilityManager, CImagePrintUiAppUi* aAppUi);
+    
+    
+    /**
+     * Default destructor.
+     * @since S60 v3.2
+     */	
+    virtual ~CRequestManager();
+    
+    
+    /**
+     * Chooses DoDpsRequest type 
+     * @param aType type of request
+     * @return none
+     */
+   	 void ChooseDpsRequestTypeL( TRequestType aType );
+   	 
+   	/**
+     * Give printer and vendor names to UI 
+     * @param aVendorName the vendor name
+     * @param aProductName the product name
+     * @return none
+     */
+   	 void GetPrinterName(TDes8& aVendorName, TDes8& aProductName);
+   	 
+    /**
+     * Issues again DoDpsRequest if iStatus indicates timeout or PictBridge is in use 
+     */
+     void ReIssueDoDpsRequestL();
+    
+protected:
+    
+   /**
+    *   @see CActive
+    */
+    void RunL();
+    
+   /**
+    *   @see CActive
+    */ 
+    void DoCancel();
+    
+   /**
+    *   @see CActive
+    */
+    TInt RunError(TInt aError);
+    
+   /**
+    * Externalixe value when save those into config file
+    */
+    void ExternalizeL(RWriteStream& aStream) const;
+
+
+private:
+
+   /**
+    *  Default constructor
+    * @param aDpsEngine the pointer to the PictBridge engine
+    * @param aCapabilityManager the pointer to the Capability Manager
+    * @param aAppUi the pointer to the AppUi class
+    */
+    CRequestManager( CDpsEngine* aDpsEngine, 
+                     CCapabilityManager* aCapabilityManager, CImagePrintUiAppUi* aAppUi);
+    
+
+    /** 
+     * 2nd phase construction 
+     */
+    void ConstructL();
+    	
+	/**
+     * Handles return situation after requesting DPS request GetDeviceStatus  
+     */
+    void HandleDeviceStatusL();
+    
+    /**
+     * Handles return situation after requesting DPS request AbortJob
+     */
+    void HandleAbortL();
+    
+    
+    /**
+     * Handles return situation after requesting DPS request StartJob 
+     */
+    void HandleStartJobL();
+    
+    
+    /**
+     * Handles return situation after requesting DPS request GetJobStatus  
+     */
+
+     void HandleGetJobStatusL();
+     
+     /**
+     * Handles return situation after requesting DPS request GetConfigure
+     */ 
+     void HandleConfigureL();
+     
+     /**
+     * Saves configure info to file
+     */ 
+     void SaveConfigInfoL();
+     
+     
+    /**
+     * Read configure info from file
+     */ 
+     void ReadConfigInfoL();
+     
+    /**
+     * Performs start job request
+     */ 
+     void ExecuteStartJobRequestL();
+      
+     
+    
+private: 
+    
+    // owned by AppUi
+    CDpsEngine* iDpsEngine;
+    CCapabilityManager* iCapabilityManager;
+    CImagePrintUiAppUi* iAppUi;
+    
+    // types for DoDpsRequest
+    TDpsGetCapability      iCap;
+    TDpsStartJob           iStart;
+    TDpsAbortJob           iAbort;
+    TDpsContinueJob        iContinue;
+    TDpsGetPrinterStatus   iPrinter;
+    TDpsGetJobStatus       iJob;
+    TDpsConfigPrintService iConfig;
+        
+    TRequestType   iRequestType;
+    
+    TInt iNumberOfImages;
+    
+    TBool iJobFinished;
+    TBool iFileExist;
+    
+    CDesCArrayFlat* iImageArrayFlat;
+    
+    TBuf8<KDefaultSize> iVendorName;
+    TBuf8<KDefaultSize> iProductName;
+      
+    HBufC* iCongFileName;
+     
+    };
+
+
+#endif // C_REQUESTMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/settingscontainer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,136 @@
+/*
+* 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:  Header file for settingscontainer
+*
+*/
+
+#ifndef CSETTINGSCONTAINER_H
+#define CSETTINGSCONTAINER_H
+
+
+// INCLUDES
+#include <coecntrl.h>
+#include <aknview.h>    // AVKON components
+#include <aknlists.h>
+
+#include "settingsview.h"
+
+
+// FORWARD DECLARATIONS
+class CAknsBasicBackgroundControlContext;
+class CSettingsItems;
+class CImagePrintUiAppUi;
+class CCapabilityManager;
+
+
+/**
+*   Container class for setting items   
+*/
+class CSettingsContainer : public CCoeControl
+    {
+
+
+public:
+
+   /**
+    *   Two phase constructor
+    *   @param aRect  reference to container area
+    *   @param aAppUi the pointer to  the CImagePrintUiAppUi
+    *   @return a CSettingsContainer instance
+    */
+    static CSettingsContainer* NewL( const TRect& aRect, CImagePrintUiAppUi* aAppUi );
+
+   /**
+    *   Two phase constructor
+    *   
+    *   @param aRect  reference to container area
+    *   @param aAppUi the pointer to  the CImagePrintUiAppUi
+    *   @return a CSettingsContainer instance
+    */
+    static CSettingsContainer* NewLC( const TRect& aRect, CImagePrintUiAppUi* aAppUi );
+
+   /**
+    *   Destructor
+    */	
+    virtual ~CSettingsContainer();
+
+    /**
+     * Forward change event to container
+     * @param None
+     * @return None.
+     */
+    void HandleChange(); 
+    
+
+private: // Methods derived from CCoeControl
+
+   /**
+    * From CCoeControl Handles a chage of client area size.
+    */
+    void SizeChanged(); 	
+
+   /**
+    * From CCoeControl, Handles a change to the control's resources.
+    */
+    void HandleResourceChange( TInt aType ); 
+    	
+   /**
+    * From CCoeControl Returns the number of components.
+    */
+    TInt CountComponentControls() const;
+	
+   /**
+    * From CCoeControl Returns a pointer of component.
+    */
+	CCoeControl* ComponentControl(TInt aIndex) const;
+	
+   /**
+    * From CCoeControl indicate whether or not a key event was processed 
+    */
+    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
+
+    #ifdef __SERIES60_HELP
+    /**
+    * From CCoeControl read help 
+    */
+    void GetHelpContext( TCoeHelpContext& aContext ) const;
+    #endif
+   
+private:
+
+   /**
+    *   Default constructor
+    */
+    CSettingsContainer();
+
+   /**
+    *   Second phase constructor. Operations which might leave should 
+    *   be called here
+    *   @param aRect  reference to container area
+    *   @param aAppUi the pointer to  the CImagePrintUiAppUi
+    */ 
+    void ConstructL( const TRect& aRect, CImagePrintUiAppUi* aAppUi );
+
+
+
+private: // Data
+
+    CAknSettingStyleListBox*    iSettingsMainListBox;   // The setting items list (scrollable)
+    CSettingsItems*             iSettingsItems;         // Format strings for list items
+    CCapabilityManager*         iCapabilityManager;     // Contains capability needed by settings
+    CImagePrintUiAppUi*         iAppUi;
+    CAknsBasicBackgroundControlContext* iSkinContext;  // skin data
+    };
+
+#endif // CSETTINGSCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/settingsitems.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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:  Header file for settingsitems
+*
+*/
+
+
+
+
+#ifndef CSETTINGSITEMS_H
+#define CSETTINGSITEMS_H
+
+//  EXTERNAL INCLUDES
+#include <bamdesca.h>
+#include <eiklbo.h>
+#include "settingstables.h"
+#include "pictbridge.h"
+
+// FORWARD DECLARATIONS
+class CCapabilityManager;
+class CNotes; 
+
+// CONSTANTS
+_LIT( KTab, "\t" );
+const TInt KSettingsMaxSize = 256; 
+const TInt KDefaultArrayValue = 3;
+
+/**
+ *
+ *  List box model that handles the contents of the list box and launches
+ *  the pop-up dialogs that are used .
+ *
+ */
+class CSettingsItems :
+    public CBase,
+    public MEikListBoxObserver,
+    public MDesCArray
+    {
+
+public:     
+
+    /**
+     *  Two-phase constructor
+     *
+     *  @param aManager the pointer to the  CapabilityManager
+     *  @param aNotes the pointer to the  CNotes
+     *  @return Initialized instance of CSettingsItems
+     */
+    static CSettingsItems* NewL( CCapabilityManager* aManager, CNotes* aNotes); 
+
+   /**
+     *  Two-phase constructor
+     *
+     *  @param aManager the pointer to the  CapabilityManager
+     *  @param aNotes the pointer to the  CNotes
+     *  @return Initialized instance of CSettingsItems
+     */
+    static CSettingsItems* NewLC( CCapabilityManager* aManager, CNotes* aNotes); 
+
+
+    /**
+     *  Destructor
+     */
+    virtual ~CSettingsItems();
+
+private:        //  Constructors and destructors
+
+   /**
+    *  Constructor
+    *  @param aManager the pointer to the  CapabilityManager
+    *  @param aNotes the pointer to the  CNotes  
+    */
+    CSettingsItems( CCapabilityManager* aManager, CNotes* aNotes); 
+
+   /**
+    *  2nd phase constructor
+    */
+    void ConstructL();
+
+public:         //  Methods derived from MEikListBoxObserver
+
+
+   /**
+	*  Framework method to handle listbox event
+	*/
+    void HandleListBoxEventL( CEikListBox* aListBox,
+                              TListBoxEvent aEventType );
+
+public:        //  Methods derived from MDesCArray
+
+
+    
+   /**
+	*  Return number of items in listbox
+	*/
+    TInt MdcaCount() const;
+    
+   /**
+	*  Creates the text string for the list box item and returns it,
+	*  set sting to iBubber,  can leave
+	*/
+    TPtrC MdcaPointL( TInt aIndex ) const;
+    
+   /**
+	*  Creates the text string for the list box item and returns it,
+	*  set string to iBuffer
+	*/
+    TPtrC MdcaPoint( TInt aIndex ) const;
+
+
+private:    
+
+    /**
+     *  Opens the radio button page to change print settings
+     */
+     void HandleEvent( TInt aCapability, 
+                            const TConversionTable* aTable, 
+                            const TInt aTableSize, const HBufC* aTitle ); 
+    /**
+     *  Opens the radio button page to change print settings, can leave
+     */
+     void HandleEventL(TInt aCapability, 
+    					    const TConversionTable* aTable,
+    					    const TInt aTableSize, const HBufC* aTitle );
+    
+    /**
+     *  Retrieve current print setting string 
+     */
+    void GetCurrentStringL( TInt aCapability, 
+                            const TConversionTable* aTable, 
+                            const TInt aTableSize ) const;
+
+
+private:  // Data
+
+    CCapabilityManager* iCapabilityManager;
+    
+    CNotes* iNotes;
+
+    TInt iCount;
+    
+    HBufC* iBuffer;
+    
+    HBufC* iLayout; 
+    
+    HBufC* iPaperSize; 
+    
+    HBufC* iQuality; 
+    };
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/settingstables.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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:  Contain info about capabilities phone are supporting
+*
+*/
+
+
+
+
+#ifndef SETTINGSTABLES_H
+#define SETTINGSTABLES_H
+
+#include <dpsdefs.h>
+#include <imageprintui.rsg>
+
+/**
+* Definitions for phone supported capabilities
+*/
+
+const TInt KLayoutTableCount( 6 );
+const TInt KLayoutTableIndexCount( 2 );
+
+const TInt KPaperSizeTableCount( 6 );
+const TInt KPaperSizeTableIndexCount( 2 );
+
+const TInt KQualityTableCount( 4 );
+const TInt KQualityTableIndexCount( 2 );
+
+const TInt KTableCount( 16 ); 
+const TInt KTableIndexCount( 2 ); 
+
+struct TConversionTable
+    {
+    TInt iCapabilityID;
+    TInt iResourceID; 
+    };
+
+
+const TConversionTable KLayoutTable[] = 
+    { 
+    { EDpsLayoutDefault,    R_USB_PRINT_LAYOUT_DEFAULT },
+    { EDpsLayout1Up,        R_USB_PRINT_LAYOUT_1_UP },
+    { EDpsLayout2Up,        R_USB_PRINT_LAYOUT_2_UP }, 
+    { EDpsLayout4Up,        R_USB_PRINT_LAYOUT_4_UP }, 
+    { EDpsLayout6Up,        R_USB_PRINT_LAYOUT_6_UP },  
+    { EDpsLayout9Up,        R_USB_PRINT_LAYOUT_9_UP }
+    }; 
+
+
+const TConversionTable KPaperSizeTable[]=
+    { 
+    { EDpsPaperSizeDefault,    R_USB_PRINT_PAPER_SIZE_AUTOMATIC },
+    { EDpsPaperSizeCard,       R_USB_PRINT_PAPER_SIZE_CARD }, 
+    { EDpsPaperSize4x6,        R_USB_PRINT_PAPER_SIZE_INCH }, 
+    { EDpsPaperSizeLetter,     R_USB_PRINT_PAPER_SIZE_LETTER }, 
+    { EDpsPaperSizeA4,         R_USB_PRINT_PAPER_SIZE_A4 },
+    { EDpsPaperSizeA6,         R_USB_PRINT_PAPER_SIZE_A6 }
+    }; 
+
+
+const TConversionTable KQualityTable[] =
+    { 
+    { EDpsPrintQualityDefault,    R_USB_PRINT_QUALITY_DEFAULT },
+    { EDpsPrintQualityFine,       R_USB_PRINT_QUALITY_HIGH },
+    { EDpsPrintQualityNormal,     R_USB_PRINT_QUALITY_NORMAL }, 
+    { EDpsPrintQualityDraft,      R_USB_PRINT_QUALITY_DRAFT } 
+    }; 
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/inc/settingsview.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* 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:  Header file for settingsview
+*
+*/
+
+
+#ifndef CSETTINGSVIEW_H
+#define CSETTINGSVIEW_H
+
+
+#include <aknview.h>
+
+class CSettingsContainer;
+
+const TUid KImagePrintSettingsViewId = { 2 };
+
+
+/**
+*   View class to present application main view
+*/
+class CSettingsView : public CAknView
+    {
+
+public:
+
+   /**
+    *   Two phase constructor
+    *   @return a CSettingsView instance
+    */
+    static CSettingsView* NewL();
+    
+   /**
+    *   Two phase constructor
+    *   @return a CSettingsView instance
+    */
+    static CSettingsView* NewLC();
+
+   /**
+    *   Destructor
+    */
+    virtual ~CSettingsView();
+        
+       
+private: // from base class CAknView
+
+    /**
+     * From CAknView 
+     * Returns view id.
+     * @param None.
+     * @return View id.
+     */
+    TUid Id() const;
+
+    /**
+     * From CAknView 
+     * Handles user commands.
+     * @param aCommand A command id.        
+     * @return None.
+     */
+    void HandleCommandL(TInt aCommand);
+
+    /**
+     * From CAknView 
+     * Activates view.
+     * @param aPrevViewId Id of previous view.
+     * @param aCustomMessageId Custom message id.
+     * @param aCustomMessage Custom message.
+     * @return None.
+     */
+    void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+                     const TDesC8& aCustomMessage);
+
+    /**
+     * From CAknView 
+     * Deactivates view.        
+     * @param None.
+     * @return None.
+     */
+    void DoDeactivate();
+    
+    /**
+     *   Default constructor
+     */    
+    CSettingsView();
+
+    /**
+     * Symbian 2nd phase constructor.
+     * @param None
+     * @return None
+     */
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Container control of this view
+     * Own
+     */
+    CSettingsContainer* iContainer; 
+ 
+    };
+
+#endif // CSETTINGSVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/loc/imageprintui.loc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,311 @@
+/*
+* 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:  Localization strings for project Image Print UI
+*
+*/
+
+
+
+// LOCALISATION STRINGS
+
+// d: Text on the status pane on empty view
+// l: title_pane_t2/opt9
+// r: 3.2
+// 
+#define qtn_usb_title_image_print "Image print"
+
+
+// d: Text on the status pane on print preview view
+// l: title_pane_t2/opt9
+// r: 3.2
+// 
+#define qtn_usb_image_print_preview "Print preview"
+
+
+// d: Text on the navi pane which shows the printer name and the vendor name
+// l: navi_navi_text_pane_t1
+// r: 3.2
+// 
+#define qtn_usb_navi_printer_name "%U"
+
+// d: Print command in the "Options" menu of the print preview view
+// l: list_single_pane_t1_cp2
+// r: 3.2
+#define qtn_usb_option_print "Print"
+
+// d: Print settings command in the "Options" menu of the print preview view
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_usb_print_settings "Print settings"
+
+// d: Text on the status pane on print settings
+// l: title_pane_t2/opt9
+// r: 3.2
+//
+#define qtn_print_title_print_settings "Print settings"
+
+// d: Print settings command in the "Options" menu of the print preview view
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_usb_opt_change "Change"
+
+// d: Print layout capability presented in the list box in print settings view
+// l: list_setting_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout "Layout"
+
+// d: Paper size capability presented in the list box in print settings view
+// l: list_setting_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size "Paper size"
+
+// d: Print quality capability presented in the list box in print settings view
+// l: list_setting_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_quality "Print quality"
+
+// *** PAPER SIZES ***
+
+// d: Paper size "Automatic" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_automatic "Default"
+
+// d: Paper size "A4" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_a4 "A4"
+
+// d: Paper size "A6" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_a6 "A6"
+
+// d: Paper size "4*6 (inch)" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_inch "4*6 (inch)"
+
+// d: Paper size "Card size" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_card "Card size"
+
+// d: Paper size "Letter" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_paper_size_letter "Letter"
+
+
+// *** PRINT QUALITIES *** 
+
+
+// d: Print quality "Default" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+// 
+#define qtn_usb_print_quality_default "Default"
+
+// d: Print quality "High" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+// 
+#define qtn_usb_print_quality_high "High"
+
+// d: Print quality "Normal" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+// 
+#define qtn_usb_print_quality_normal "Normal"
+
+// d: Print quality "Draft" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+// 
+#define qtn_usb_print_quality_draft "Draft"
+
+
+// *** LAYOUTS ***
+
+// d: Print layout "Default" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_default "Default"
+
+// d: Print layout "1-up" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_1_up "1 per page"
+
+// d: Print layout "2-up" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_2_up "Up to 2 per page"
+
+
+// d: Print layout "4-up" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_4_up "Up to 4 per page"
+
+
+// d: Print layout "6-up" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_6_up "Up to 6 per page"
+
+
+// d: Print layout "9-up" in the print settings view list box / pop-up window
+// l: list_set_graphic_pane_t1
+// r: 3.2
+//
+#define qtn_usb_print_layout_9_up "Up to 9 per page"
+
+
+// *** NOTES ***
+
+// d: Progress note
+// d: Text on the print progress dialog
+// l: popup_note_wait_window
+// r: 3.2
+//
+#define qtn_usb_wait_printing "Printing"
+
+// d: Printing error note
+// d: Error note is displayed, when connection over the chosen transmission technology fails
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_unable_to_connect "Unable to connect printer"
+
+// d: Printing error note
+// d: Shown when there is already printing process ongoing
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_printer_busy "Unable to send image to printer. Printer may be busy."
+
+// d: Printing error note
+// d: Error note is displayed when the connection is unexpectedly terminated while the
+// d: printer is printing or somehow connected to a printer (for example when USB cable is disconnected)
+// d: or then a software error happens, data is not transmitted and 
+// d: system timeout causes transmission to terminate.
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_connection_lost "Connection to printer lost"
+
+// d: Printing error note
+// d: This is a generic error note that is displayed, when no specific error message is available.
+//    It tells to user that there has been problem during printing and (most probably) the printer
+//    will cancel its current print job.
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_in_printing "Printing error"
+
+// d: Printing error note
+// d: Shown when something is wrong in the status of printer
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_check_status "Check status of printer"
+
+// d: Printing error note
+// d: Notifies user that the printer has run out of paper
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_out_of_paper "Out of paper"
+
+// d: Printing error note
+// d: Notifies user that the printer is running out of ink
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_ink_low "Ink low"
+
+// d: Printing error note
+// d: Notifies user that the printer has run out of ink
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_out_of_ink "Out of ink"
+
+
+// d: Printing error note
+// d: Shown when there is a paper jam in the printer
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_paper_jam "Paper jam"
+
+// d: Printing error note
+// d: Notifies that the file type is not supported
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_file_not_supported "A file that is not supported will be removed from the selection."
+
+// d: Printing error note.
+// d: This note is used to inform the user that one or many files of unsupported type(other than .jpeg) has been 
+//    selected and the application will discard them and continue with the images that are of the supported filetype(.jpeg).
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_unsupported_files_removed "Files that are not supported will be removed from the selection."
+
+// d: Printing error note
+// d: Shown if the selected file could not be found from device/MMC for 
+//    some reason
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_error_file_not_found "File not found"
+
+// d: Printing information note.
+// d: The purpose of the note is to inform the user that printing is already ongoing 
+//    and it may therefore not be initiated again elsewhere.
+// l: popup_note_window
+// r: 3.2
+//
+#define qtn_usb_info_app_in_use "Application already in use"
+
+// d: Info note displayed to user  connect the cable to PictBridge Printer if connected to 
+//    other printer or PC
+// l: popup_note_wait_window
+// r: 3.2
+#define qtn_usb_wait_connect_cable_compatible "Connect cable to PictBridge printer"
+
+// d: Info note displayed to user  connect the cable if cable is not connected
+//    and user has select print from menu option
+// l: popup_note_wait_window
+// r: 3.2
+#define qtn_usb_wait_connect_cable "Connect USB cable"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/rom/imageprintui.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Image description file for project imageprintui
+*
+*/
+
+#ifndef IMAGEPRINTUI_IBY
+#define IMAGEPRINTUI_IBY
+#ifdef __USB_PICTBRIDGE_UI
+
+#include <data_caging_paths_for_iby.hrh>
+data=DATAZ_\Private\10003A3F\Apps\imageprintui_reg.rsc  Private\10003A3F\Apps\imageprintui_reg.rsc
+data=DATAZ_\Private\1020e470\phonecapability.RSC    Private\1020e470\phonecapability.rsc
+S60_APP_EXE( imageprintui )
+
+                    
+#endif // __USB_PICTBRIDGE_UI
+#endif // IMAGEPRINTUI_IBY
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/rom/imageprintuiresources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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:  Language  description file for project imageprintui
+*
+*/
+
+
+
+#ifndef __IMAGEPRINTUIRESOURCES_IBY__
+#define __IMAGEPRINTUIRESOURCES_IBY__
+
+#ifdef __USB_PICTBRIDGE_UI
+#include <data_caging_paths_for_iby.hrh>
+
+data=DATAZ_\APP_RESOURCE_DIR\imageprintui.RSC    APP_RESOURCE_DIR\imageprintui.rsc
+
+
+
+#endif // __USB_PICTBRIDGE_UI
+#endif // __IMAGEPRINTUIRESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/capabilitymanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,750 @@
+/*
+* 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:  Retrieve printing capabilites from printer 
+*
+*/
+
+
+#include "capabilitymanager.h"
+#include "imageprintuidebug.h"
+#include "imageprintuiappui.h"
+#include <dpsdefs.h>
+#include <dpsparam.h>
+#include <barsc.h>
+#include <barsread.h>
+#include <bautils.h>
+#include <f32file.h>
+#include <pathinfo.h> 
+#include <phonecapability.rsg>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CCapabilityManager* CCapabilityManager::NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager:NewL"));
+    CCapabilityManager* self 
+        = new (ELeave) CCapabilityManager(aAppUi, aEngine);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::~CCapabilityManager
+// C++ default destructor
+// -----------------------------------------------------------------------------
+//    
+CCapabilityManager::~CCapabilityManager()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager: desctructor"));
+    Cancel(); // cancels any existing active object orders for iStatus
+    
+    iReturnArray.Close();
+    iCurrentLayouts.Close();
+    iCurrentPaperSizes.Close();
+    iCurrentQualities.Close();
+       
+    iPhoneSuppQuality.Close();
+    iPhoneSuppPaperSize.Close();   
+    iPhoneSuppLayout.Close();
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager: desctructor complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::CCapabilityManager
+// C++ default constructor 
+// -----------------------------------------------------------------------------
+//
+CCapabilityManager::CCapabilityManager(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine)
+    : CActive(EPriorityStandard), 
+    iAppUi(aAppUi), iDpsEngine(aEngine),
+    iUserSelectedQuality(EDpsPrintQualityDefault),
+    iUserSelectedPaperSize(EDpsPaperSizeDefault),
+    iUserSelectedLayout(EDpsLayoutDefault)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::RunError
+// Standard active object error function.
+// -----------------------------------------------------------------------------
+//
+
+TInt CCapabilityManager::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]CCapabilityManager RunError is %d ."), aError));
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::RunL
+// This function will be called upon a change in the watched key.
+// -----------------------------------------------------------------------------
+//
+void CCapabilityManager::RunL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL"));
+    if(iStatus.Int() == KErrNone && iLayoutForPaperSize)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL layout for papersize asked"));
+    	HandleLayoutForPaperSize();
+    	return;
+    	}
+    
+    if ( iStatus.Int() == KErrNone )
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL, no error in iStatus"));
+        HandleCapabilitiesL(iCapabilityType); 
+    	}
+    
+    else 
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL, there is error in iStatus"));
+    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL: ERROR is %d  ."), iStatus.Int()));
+    	iAppUi->HandleCapabilityTime(KRetryAsk);
+    	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::Timer called"));
+    	}
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL complete."));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::ConstructL
+// Construct member variable iPersonalityRepository that is to access the
+// repository. Then start listening of the changes in the repository.
+// -----------------------------------------------------------------------------
+//
+void CCapabilityManager::ConstructL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager: ConstructL"));
+    iCapabilityNotChanged = EFalse;
+    iIsCapabilityEmpty = EFalse;
+    iLayoutForPaperSize = EFalse;
+    
+    iPhoneSuppLayout = RArray<TUint>(KDefaultArray);  
+    iPhoneSuppPaperSize = RArray<TUint>(KDefaultArray);
+    iPhoneSuppQuality = RArray<TUint>(KDefaultArray);  
+    iCurrentQualities = RArray<TUint>(KDefaultArray);
+    iCurrentPaperSizes = RArray<TUint>(KDefaultArray);
+    iCurrentLayouts = RArray<TUint>(KDefaultArray);
+    
+    iReturnArray = RArray<TUint>(KDefaultArray);
+    
+    GetPhoneConfigL();
+    FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager: ConstructL complete"));        
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::AskCapabilitiesL(TBool aChanged)
+	{
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::AskCapabilitiesL iStatus   is %d"), iStatus.Int() ));  
+    
+	if(aChanged)
+		{
+		if(iStatus.Int() == KErrNotReady) // this is collision situation, have asked earlier and event capability
+			{                             // change requires asking again when AO is already active
+		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilitiesL not ready when capability change")); 
+		    return;	
+			}
+		else
+			{
+		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilities cancel pending"));
+			Cancel();
+			}
+		
+		}
+	if(!IsActive())
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::start ask paper size "));
+	    AskPaperSizeL();	
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::cannot ask quality, already active "));
+		}
+	
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilities"));
+    
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::AskQualityL()
+	{
+	iCap.iRepParam.Reset();
+	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskQualityL "));
+	iCap.iReqParam.iCap = EDpsArgQualities;
+    iCapabilityType = EQualities;
+    iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
+	SetActive();
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskQualityL "));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CCapabilityManager::AskPaperSizeL()
+	{
+	iCap.iRepParam.Reset();
+	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskPaperSizeL "));
+	iCap.iReqParam.iCap = EDpsArgPaperSizes;
+    iCapabilityType = EPaperSize;
+    iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
+	SetActive();
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskPaperSizeL "));
+	}	
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CCapabilityManager::AskLayoutL()
+	{
+	iCap.iRepParam.Reset();
+	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskLayoutL "));
+    
+    iCap.iReqParam.iCap = EDpsArgLayouts;
+    iCap.iReqParam.iAttribute = EDpsPaperSizeDefault;
+    iCapabilityType = ELayouts;
+    iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
+	SetActive();
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskLayoutL "));
+	}	
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::AskLayoutForPaperSizeL(TUint aPaperSize)
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskLayoutForPaperSizeL "));
+	iCap.iRepParam.Reset();
+	iCap.iReqParam.iCap = EDpsArgLayouts;
+    iCap.iReqParam.iAttribute = aPaperSize;
+   	iDpsEngine->DoDpsRequestL(&iCap, iStatus);
+   	
+	if(!IsActive())
+		{
+		iLayoutForPaperSize = ETrue;
+	    SetActive(); 	
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CCapabilityManager::DoCancel
+// Standard active object cancellation function.
+// -----------------------------------------------------------------------------
+//
+void CCapabilityManager::DoCancel()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::DoCancel"));
+    iDpsEngine->CancelDpsRequest();
+    FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::DoCancel complete"));
+    }
+
+// ---------------------------------------------------------------------------
+//  
+// ---------------------------------------------------------------------------
+//	
+RArray<TUint>& CCapabilityManager::GetCapabilities(TInt aCapabilities)
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.GetCapabilities"));
+    iReturnArray.Reset();
+    
+    switch ( aCapabilities )
+	    {        
+	    case EDpsArgQualities:
+	    	for(int i = 0; i < iCurrentQualities.Count(); i++ )
+	    		{
+	    		iReturnArray.Append(iCurrentQualities.operator[](i));
+	    		}
+	        break;
+	  
+	    case EDpsArgPaperSizes:
+	        for(int i = 0; i < iCurrentPaperSizes.Count(); i++ )
+	    		{
+	    		iReturnArray.Append(iCurrentPaperSizes.operator[](i));
+	    		}	
+	        break;
+	        
+	    case EDpsArgLayouts:
+	    	for(int i = 0; i < iCurrentLayouts.Count(); i++ )
+	    		{
+	    		iReturnArray.Append(iCurrentLayouts.operator[](i));
+	    		}
+			break;		
+	    default:
+	        FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.GetCapabilities default brach"));
+	        break;  
+	    }     
+    FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.GetCapabilities")); 
+    return iReturnArray;
+    }  
+
+// ---------------------------------------------------------------------------
+// User has choosed value for saving
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::SetValue(TInt aCapability, TUint aValue)
+    { 
+    FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.SetValue"));
+    switch ( aCapability )
+	    {        
+	    case EDpsArgQualities:
+	        FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in quality is %x"), aValue ));
+	        iUserSelectedQuality = aValue;	
+	        break;
+	            
+	    case EDpsArgPaperSizes:
+	        FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in papersize is %x"), aValue ));
+	        iUserSelectedPaperSize = aValue;
+	        // now user has select papersize, retrive layout for certain papersize
+	        TRAPD(err,AskLayoutForPaperSizeL(aValue));
+	        if(err)
+	        	{
+	        	FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.AskLayoutForPaperSizeL was unsuccessfull"));
+	        	}
+	        break;
+	            
+	    case EDpsArgLayouts:
+	    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in layouts is %x"), aValue ));
+	        iUserSelectedLayout = aValue; 	
+	        break;
+	    default:
+	     	break;  
+	    } 		
+	FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.SetValue"));    
+    }     
+
+// ---------------------------------------------------------------------------
+//  UI requires current value
+// ---------------------------------------------------------------------------
+//	
+TUint CCapabilityManager::CurrentPrintSettings(TInt aDpsArg)
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager::CurrentPrintSettings"));
+	TUint retValue;
+	if(aDpsArg == EDpsArgQualities)
+		{
+        retValue = iUserSelectedQuality;		
+		}
+    else if(aDpsArg == EDpsArgPaperSizes)
+    	{
+    	retValue = iUserSelectedPaperSize;
+    	}
+    else if(aDpsArg == EDpsArgLayouts)
+    	{
+    	retValue = iUserSelectedLayout;
+    	}
+    else if(aDpsArg != EDpsArgQualities &&  
+            aDpsArg != EDpsArgPaperSizes && aDpsArg != EDpsArgLayouts)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CCapabilityManager: Wrong value asked"));
+    	retValue = (TUint)KErrArgument;
+    	}
+    FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager CurrentPrintSettings"));
+    return retValue;		
+	}   
+	
+// ---------------------------------------------------------------------------
+// Gives paper size value for DoDpsRequest
+// ---------------------------------------------------------------------------
+//	
+TUint CCapabilityManager::PaperSize()
+	{
+	return iUserSelectedPaperSize;
+	}   
+	
+// ---------------------------------------------------------------------------
+// Gives layout value for DoDpsRequest
+// ---------------------------------------------------------------------------
+//
+TUint CCapabilityManager::Layout()
+	{
+	return iUserSelectedLayout;
+	}   
+	
+// ---------------------------------------------------------------------------
+// Gives quality value for DoDpsRequest
+// ---------------------------------------------------------------------------
+//
+TUint CCapabilityManager::Quality()
+	{
+	return iUserSelectedQuality;
+	}   
+	
+// ---------------------------------------------------------------------------
+//  Goes through phone supported quality values and compare with printer supported,
+//  if both supported save value 
+// ---------------------------------------------------------------------------
+
+void CCapabilityManager::StoreQualitiesL(RArray<TUint>& aPrinterQualities)
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store qualities"));
+	TInt countPrinter, countPhone;
+	TUint compareValue;
+	countPrinter = aPrinterQualities.Count();
+	countPhone = iPhoneSuppQuality.Count();
+	iIsCapabilityEmpty = EFalse;
+	iCurrentQualities.Reset();
+	
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterQualities count is %d"), aPrinterQualities.Count() ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppQuality count is %d"), iPhoneSuppQuality.Count() ));
+  
+	
+	for(int r=0; r < countPrinter; r++)
+		{
+		compareValue = aPrinterQualities[r];
+		for(int d=0; d < countPhone; d++)
+			{
+		    if(compareValue == iPhoneSuppQuality[d])
+		    	{
+		    	iIsCapabilityEmpty = ETrue;
+		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save quality is %x"), compareValue ));
+		    	iCurrentQualities.Append(compareValue);
+		    	}
+			}
+		}
+	if(!iIsCapabilityEmpty)	
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: qualities add default value"));
+		iCurrentQualities.Append(EDpsPrintQualityDefault);
+		}
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: qualities stored, ask layout"));	
+    iCurrentQualities.Sort();
+	AskLayoutL();	
+	}
+	
+		
+// ---------------------------------------------------------------------------
+//  Goes through phone supported paper size values and compare with printer supported,
+//  if both supported save value 
+// ---------------------------------------------------------------------------
+void CCapabilityManager::StorePaperSizeL(RArray<TUint>& aPrinterPaperSize)
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store paper size"));
+    TInt countPrinter, countPhone;
+    TUint compareValue;
+	countPrinter = aPrinterPaperSize.Count();
+	countPhone = iPhoneSuppPaperSize.Count();
+	iIsCapabilityEmpty = EFalse;
+	iCurrentPaperSizes.Reset();
+	
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterPaperSize count is %d"), aPrinterPaperSize.Count() ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppPaperSize count is %d"), iPhoneSuppPaperSize.Count() ));
+  
+	
+	for(int r=0; r < countPrinter; r++)
+		{
+		compareValue = aPrinterPaperSize[r];
+		for(int f=0; f < countPhone; f++)
+			{
+		    if(compareValue == iPhoneSuppPaperSize[f])
+		    	{
+		    	iIsCapabilityEmpty = ETrue;
+		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save paper size is %x"), compareValue ));
+		    	iCurrentPaperSizes.Append(compareValue);
+		    	}
+			}	
+		}
+	if(!iIsCapabilityEmpty)	
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: paper size add default value"));
+		iCurrentPaperSizes.Append(EDpsPaperSizeDefault);
+		}
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: paper sizes stored, ask quality"));
+	iCurrentPaperSizes.Sort();
+	AskQualityL();	
+    }
+      
+// ---------------------------------------------------------------------------
+//  Goes through phone supported layout values and compare with printer supported,
+//  if both supported save value 
+// ---------------------------------------------------------------------------
+void CCapabilityManager::StoreLayouts(RArray<TUint>& aPrinterLayouts)
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store layouts"));
+	TInt countPrinter, countPhone;
+	TUint compareValue;
+	countPrinter = aPrinterLayouts.Count();
+	countPhone = iPhoneSuppLayout.Count();	
+	iIsCapabilityEmpty = EFalse;
+	iCurrentLayouts.Reset();
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterLayouts count is %d"), aPrinterLayouts.Count() ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppLayout count is %d"), iPhoneSuppLayout.Count() ));
+  
+	for(int r=0; r < countPrinter; r++)
+		{
+		compareValue = aPrinterLayouts[r];
+		for(int e=0; e < countPhone; e++)
+			{
+		    if(compareValue == iPhoneSuppLayout[e])
+		    	{
+		    	iIsCapabilityEmpty = ETrue;
+		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save layout is %x"), compareValue ));
+		    	iCurrentLayouts.Append(compareValue);
+		    	}
+			}	
+		}
+		
+	if(!iIsCapabilityEmpty)	
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: layout add default value"));
+		iCurrentLayouts.Append(EDpsLayoutDefault);
+		}
+	
+	iCurrentLayouts.Sort();	
+	if(iCapabilityAskFailed)
+		{
+        // all capabilities has asked
+        // asking one of the tree capabilities was unsuccessfull
+	    FLOG(_L("[IMAGEPRINTUI]<<< :CCapabilityManager, Capabilities NOT ready "));	
+	    iAppUi->CapabilitiesReady(); 
+	 	}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< :CCapabilityManager, Capabilities are ready "));
+		iAppUi->CapabilitiesReady(); 
+		}		
+	}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::HandleLayoutForPaperSize()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::HandleLayoutForPaperSize"));
+	StoreLayouts(iCap.iRepParam.iContent); 
+	}
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::HandleCapabilitiesL(TCapabilityType aType)
+	{
+		
+	if(aType == EQualities)
+		{
+		if(iCap.iResult.iMajorCode == EDpsResultOk)
+			{					
+			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request qualities capability OK"));
+			FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL qualities amount is %d"), iCap.iRepParam.iContent.Count() ));	
+			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
+				{
+				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL qualities is %x"), iCap.iRepParam.iContent[r] ));	
+				}
+	        StoreQualitiesL(iCap.iRepParam.iContent);
+			}
+		else
+			{
+			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request qualities capability NOK"));
+			iCapabilityAskFailed = ETrue;
+			// if fails add default value
+			iAppUi->NotifyError();
+			iCurrentQualities.Reset();
+			iCurrentQualities.Append(EDpsPrintQualityDefault);
+			AskLayoutL();
+			}
+		
+		}
+ 	else if(aType == EPaperSize)
+ 		{
+ 		if(iCap.iResult.iMajorCode == EDpsResultOk)
+ 			{
+ 		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request paper size capability OK"));
+ 		    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL papersize amount is %d"), iCap.iRepParam.iContent.Count() ));
+			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
+				{
+				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL paper size is %x"), iCap.iRepParam.iContent[r] ));
+				}
+	        
+ 		    StorePaperSizeL(iCap.iRepParam.iContent);
+ 			}
+ 		else
+ 			{
+ 			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request paper size capability NOK"));
+ 			iCapabilityAskFailed = ETrue;
+ 			// if fails add default value;
+ 			iAppUi->NotifyError();
+ 			iCurrentPaperSizes.Reset();
+ 			iCurrentPaperSizes.Append(EDpsPaperSizeDefault);
+ 			AskQualityL();
+ 			}
+ 		
+ 		}
+ 	else if(aType == ELayouts)
+ 		{
+ 		if(iCap.iResult.iMajorCode == EDpsResultOk)
+ 			{
+ 			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request layout capability OK"));
+ 			FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL layout amount is %d"), iCap.iRepParam.iContent.Count() ));	
+			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
+				{
+				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL layout is %x"), iCap.iRepParam.iContent[r] ));	
+				}
+ 		    StoreLayouts(iCap.iRepParam.iContent); 	
+ 			}
+ 		else
+ 			{
+ 			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request layout capability NOK"));
+ 			iCapabilityAskFailed = ETrue;
+ 			//if fails add default value
+ 			iAppUi->NotifyError();
+ 			iCurrentLayouts.Reset();
+ 			iCurrentLayouts.Append(EDpsLayoutDefault);
+ 			// complete even if not succesfull, UI must activate
+ 			iAppUi->CapabilitiesReady();
+ 			}
+ 		
+ 		}
+    
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::GetPhoneConfigL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> :CCapabilityManager, GetPhoneConfigL BEGIN"));
+    
+        
+    TBuf<KResource> resourceFile(PathInfo::RomRootPath());
+    TBuf<KResource> length(KPhoneCapability);    
+    resourceFile.SetLength(KDriver + length.Length());
+    resourceFile.Replace(KDriver, length.Length(), KPhoneCapability);
+    
+    RResourceFile resource;
+    resource.OpenL(CCoeEnv::Static()->FsSession(),  resourceFile);
+    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, Resource open"));
+    
+    CleanupClosePushL(resource);
+    resource.ConfirmSignatureL(KPhoneCapabilityVersion);
+    
+    HBufC8* id = resource.AllocReadLC(PHONECAPABILITY_CONFIG);
+    
+    TResourceReader reader;
+    reader.SetBuffer(id);   
+    
+    TInt qualityCount = reader.ReadUint8();
+    TInt papersizeCount = reader.ReadUint8();
+    TInt layoutCount  = reader.ReadUint8();
+      
+       
+    for (TInt i = 0; i < qualityCount; i++)
+    	{
+    	iPhoneSuppQuality.Append(reader.ReadUint16());
+    	}
+    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, quality readed"));
+    	
+    for (TInt i = 0; i < papersizeCount; i++)
+    	{
+       	iPhoneSuppPaperSize.Append(reader.ReadUint16());
+    	}		
+    
+    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, papersize readed"));
+    for (TInt i = 0; i < layoutCount; i++)
+    	{
+    	iPhoneSuppLayout.Append(reader.ReadUint16());
+    	}
+    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, layout readed"));
+    	
+    CleanupStack::PopAndDestroy(id);
+    CleanupStack::PopAndDestroy(&resource);
+    FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:CCapabilityManager GetPhoneConfigL END "));
+    }
+   
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CCapabilityManager::CheckIfNewCapabilityDiffer()
+	{
+	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager:: CheckIfNewCapabilityDiffer"));
+	TBool compareValue = EFalse;
+	
+	
+	for(TInt i = 0; i  < iCurrentLayouts.Count(); i++)
+		{
+		if(iCurrentLayouts.operator[](i) == iUserSelectedLayout )
+			{
+			compareValue = ETrue;
+			}
+		
+		}
+		
+	if(!compareValue)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected layout not supported"));
+		iUserSelectedLayout = EDpsLayoutDefault;
+		}
+		
+    compareValue = EFalse;		
+	
+	for(TInt i = 0; i  < iCurrentQualities.Count(); i++)
+		{
+		if(iCurrentQualities.operator[](i) == iUserSelectedQuality )
+			{
+			compareValue = ETrue;
+			}
+			 
+		}
+		
+	if(!compareValue)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected quality not supported"));
+		iUserSelectedQuality = EDpsPrintQualityDefault;
+		}
+    	
+	compareValue = EFalse;
+
+    for(TInt i = 0; i  < iCurrentPaperSizes.Count(); i++)
+		{
+		if(iCurrentPaperSizes.operator[](i) == iUserSelectedPaperSize )
+			{
+			compareValue = ETrue;
+			}
+		} 
+
+	if(!compareValue)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected paper size not supported"));
+		iUserSelectedPaperSize = EDpsPaperSizeDefault;
+		}
+	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager:: CheckIfNewCapabilityDiffer"));	
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/connectionmanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,220 @@
+/*
+* 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:  Informs about USB connection 
+*
+*/
+
+
+#include <pictbridge.h>
+#include <imageprintui.rsg>
+
+#include "connectionmanager.h"
+#include "imageprintuidebug.h"
+#include "settingsview.h"
+#include "notes.h"
+#include "imageprintuiappui.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CConnectionManager* CConnectionManager::NewL( CImagePrintUiAppUi* aAppUi, 
+											  CDpsEngine* aEngine, CNotes* aNotes)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager:NewL"));
+    CConnectionManager* self 
+        = new (ELeave) CConnectionManager(aAppUi, aEngine, aNotes);
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::~CConnectionManager
+// C++ default destructor
+// -----------------------------------------------------------------------------
+//    
+CConnectionManager::~CConnectionManager()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: desctructor"));
+    Cancel(); // cancels any existing active object orders for iStatus
+    
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: desctructor complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::CConnectionManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CConnectionManager::CConnectionManager( CImagePrintUiAppUi* aAppUi, 
+									    CDpsEngine* aEngine, CNotes* aNotes)
+    : CActive(EPriorityStandard), iAppUi(aAppUi), 
+      iDpsEngine(aEngine), iActiveNote(EFalse),iSetPrintCall(EFalse),
+      iNotes(aNotes), iPreviousStatus(CDpsEngine::ENotConnected)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::RunError
+// Standard active object error function.
+// -----------------------------------------------------------------------------
+//
+
+TInt CConnectionManager::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\tCConnectionManager::RunError: ERROR %d from RunL."), aError));
+    if ( aError == KErrTimedOut)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI] CConnectionManager: Time out, start listen again"));
+    	StartListening();
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUI] CConnectionManager RunError close application"));
+        iAppUi->CloseApplication(ETrue);	
+    	}
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// Starts search printer
+// -----------------------------------------------------------------------------
+//
+void CConnectionManager::StartSearchPrinter()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: StartSerchPrinter"));
+    iDpsEngine->SetPrintMode(iStatus);
+    iSetPrintCall = ETrue;
+    SetActive(); 
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: StartSerchPrinter complete")); 
+	}
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+//
+void CConnectionManager::RunL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::RunL"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CConnectionManager iStatus  is %d"), iStatus.Int() ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CConnectionManager iPreviousStatus  is %d"), iPreviousStatus ))
+    
+    if ( iStatus.Int() == CDpsEngine::ENotConnected  )
+        {
+        FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::ENotConnected "));
+        if(iPreviousStatus == CDpsEngine::EOtherConnected)
+        	{
+        	FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager:: Previous was EOtherConnected, close earlier note")); 
+        	iNotes->StopShowNote(R_NOT_CONNECT_PRINTER);
+        	}
+        iNotes->ShowNoteL(R_CONNECT_USB);
+    	iActiveNote = ETrue; 
+    	iPreviousStatus = CDpsEngine::ENotConnected;
+    	StartListening();	
+    	
+        }
+    else if ( iStatus.Int() == CDpsEngine::EOtherConnected )
+        {
+        FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::EOtherConnected "));
+        if(iPreviousStatus == CDpsEngine::ENotConnected)
+        	{
+        	FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager:: Previous was ENotConnected, close earlier note")); 
+        	iNotes->StopShowNote(R_CONNECT_USB);
+        	}
+        iNotes->ShowNoteL(R_NOT_CONNECT_PRINTER);
+        iActiveNote = ETrue; 
+        iPreviousStatus = CDpsEngine::EOtherConnected;
+        StartListening();
+        
+        }
+    else if (iStatus.Int() == CDpsEngine::EPrinterConnected)
+        {
+        FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::EPrinterConnected"));
+        iSetPrintCall = EFalse;
+        if(iActiveNote)
+        	{
+        	FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::Stop show note"));
+            iNotes->StopShowNote(R_CONNECT_USB);
+            iActiveNote = EFalse; 	
+       		}	
+        iPreviousStatus = CDpsEngine::EPrinterConnected;	
+        StartListening(); 
+        TRAPD(err, iAppUi->CableConnectedL());
+        if(err)
+        	{
+        	// creation of some manager instance was unsuccessfull, close application
+        	iNotes->ShowErrorMsgL(R_ERROR_GENERAL);
+        	iAppUi->CloseApplication(EFalse); 
+        	}
+        }
+    else if ( iStatus.Int() == CDpsEngine::EPrinterDisconnected || 
+              iStatus.Int() == CDpsEngine::EWrongPrintModeConnected )
+        {
+        FLOG(_L("[IMAGEPRINTUI]>>>CConnectionManager::EPrinterDisconnected or EWrongPrintModeConnected"));
+        iAppUi->CloseApplication(ETrue); 
+        }
+
+    FLOG(_L("[IMAGEPRINTUI]<<<CConnectionManager::RunL complete."));
+    }
+	
+
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::StartListening
+// Orders notifications and sets the object active.
+// -----------------------------------------------------------------------------
+//
+void CConnectionManager::StartListening()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: StartListeningL"));
+    if(IsActive())
+        {
+        return;   
+        }
+    iDpsEngine->ConnectStateNotify( iStatus );
+    SetActive();
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager: StartListeningL complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CConnectionManager::DoCancel
+// Standard active object cancellation function.
+// -----------------------------------------------------------------------------
+//
+void CConnectionManager::DoCancel()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager::DoCancel"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t tCConnectionManager iDpsEngine  is %x"), iDpsEngine ));
+    if(!iDpsEngine)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager::DpsEngine allredy destroyed, panic"));
+    	}
+	else
+		{
+    iDpsEngine->CancelPrintMode();
+		}
+    FLOG(_L("[IMAGEPRINTUI]\tCConnectionManager::DoCancel complete"));
+    }
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/emptycontainer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,169 @@
+/*
+* 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:  Empty container for UI
+*
+*/
+
+
+
+//INCLUDES
+#include <AknsDrawUtils.h> 
+#include <AknsBasicBackgroundControlContext.h>
+#include <AknsConstants.h>
+#include <AknUtils.h>
+#include <eikenv.h>
+
+#include "emptycontainer.h"
+#include "imageprintuidebug.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEmptyContainer::CEmptyContainer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEmptyContainer::ConstructL( const TRect& aRect  )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::ConstructL"));
+    CreateWindowL();
+	SetRect( aRect );
+    
+    // Temporary rect is passed. Correct rect is set in SizeChanged.
+    iSkinContext = CAknsBasicBackgroundControlContext::NewL(
+        KAknsIIDQsnBgAreaMain, Rect(), EFalse);
+
+    ActivateL();
+
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::ConstructL complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEmptyContainer* CEmptyContainer::NewL( 
+    const TRect& aRect )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::NewL"));
+    CEmptyContainer* self = CEmptyContainer::NewLC( aRect );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEmptyContainer* CEmptyContainer::NewLC( 
+    const TRect& aRect )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::NewLC"));
+    
+    CEmptyContainer* self = new( ELeave ) CEmptyContainer;
+    CleanupStack::PushL( self );
+    self->ConstructL( aRect );
+    return self;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEmptyContainer::~CEmptyContainer()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Destructor"));
+    delete iSkinContext; 
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEmptyContainer::Draw( const TRect& aRect ) const
+    {
+
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Draw"));
+    CWindowGc& gc = SystemGc();
+
+    // Drawing skin
+    if (iSkinContext)
+        {
+        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+        AknsDrawUtils::Background( skin, iSkinContext, this, gc, aRect );
+        }
+    else
+        {//  clear the area
+        gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
+        gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+        gc.Clear( aRect );
+        }
+
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Draw complete"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEmptyContainer::SizeChanged()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::SizeChanged()"));
+
+    TRect parentRect(Rect());
+	if (iSkinContext)
+        {
+        iSkinContext->SetRect(parentRect);
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::SizeChanged() complete"));
+	}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+ void CEmptyContainer::HandleResourceChange(TInt aType)
+ {
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {		
+		TRect rect;
+		// ask where container's rectangle should be
+		// EMainPane equals to area returned by CEikAppUi::ClientRect()
+		
+ 		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
+        SetRect(rect); 
+		DrawNow();
+        }
+    else
+        {
+        CCoeControl::HandleResourceChange(aType);
+        }  
+ }
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/emptyview.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,154 @@
+/*
+* 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:  Empty view for UI
+*
+*/
+
+
+#include <aknViewAppUi.h>
+#include <imageprintui.rsg>
+
+#include "emptyview.h"
+#include "emptycontainer.h"
+#include "imageprintuidebug.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+//  constructor
+// ---------------------------------------------------------------------------
+//
+CEmptyView::CEmptyView()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+//  ConstructL
+// ---------------------------------------------------------------------------
+//
+void CEmptyView::ConstructL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::ConstructL()"));
+    BaseConstructL( R_EMPTY_VIEW );
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::ConstructL() complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+//  NewL
+// ---------------------------------------------------------------------------
+//
+CEmptyView* CEmptyView::NewL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::NewL()"));
+    CEmptyView* self = CEmptyView::NewLC();
+    CleanupStack::Pop( self );
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::NewL() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+//  NewLC
+// ---------------------------------------------------------------------------
+//
+CEmptyView* CEmptyView::NewLC()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::NewLC()"));
+    CEmptyView* self = new( ELeave ) CEmptyView;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::NewLC() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+//  destructor
+// ---------------------------------------------------------------------------
+//
+CEmptyView::~CEmptyView()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::Destructor"));
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::Destructor complete"));
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// Returns the id of the view
+// ---------------------------------------------------------------------------
+//
+TUid CEmptyView::Id() const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::Id"));
+    return KImagePrintEmptyViewId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Forwards all the commands to appUi
+// ---------------------------------------------------------------------------
+//
+void CEmptyView::HandleCommandL(
+    TInt aCommand )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::HandleCommandL"));
+    AppUi()->HandleCommandL( aCommand );
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::HandleCommandL complete"));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates a container and puts it to stack
+// ---------------------------------------------------------------------------
+//
+void CEmptyView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,
+   TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {       
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::DoActivateL"));
+
+	iContainer = CEmptyContainer::NewL( ClientRect() );
+	iContainer->SetMopParent( this );
+	AppUi()->AddToStackL( *this, iContainer );
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::DoActivateL complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// Deletes container 
+// ---------------------------------------------------------------------------
+//
+void CEmptyView::DoDeactivate()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::DoDeactivate()"));
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+	    iContainer = NULL;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CEmptyView::DoDeactivate() complete"));
+
+    }
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/eventmanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,395 @@
+/*
+* 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:  Handles DpeEventNotify call with AO
+*
+*/
+
+
+
+#include <e32base.h>
+#include <dpsdefs.h>
+#include <dpsparam.h>
+#include <s32file.h>
+#include <f32file.h>
+#include <e32std.h>
+#include <coemain.h>
+#include <d32usbc.h>
+
+#include "eventmanager.h"
+#include "imageprintuidebug.h"
+#include "pictbridge.h"
+#include "imageprintuiappui.h"
+ 
+ 
+// ---------------------------------------------------------------------------
+//  constructor
+// ---------------------------------------------------------------------------
+//
+CEventManager::CEventManager(CImagePrintUiAppUi* aAppUi, CDpsEngine* aDpsEngine)
+    : CActive(CActive::EPriorityStandard), iAppUi(aAppUi),iDpsEngine(aDpsEngine),
+      iErrorState(EFalse)
+    {
+    CActiveScheduler::Add(this);
+    StartListening();
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEventManager* CEventManager::NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aDpsEngine)
+    {
+    CEventManager* self = new( ELeave ) CEventManager(aAppUi, aDpsEngine);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CEventManager::~CEventManager()
+    {
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// Start listening events
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::StartListening()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CEventManager::Start listening"));
+	iDpsEngine->DpsEventNotify(iEventRequest, iStatus);
+	SetActive();
+	}
+ 	
+// ---------------------------------------------------------------------------
+// Handles situation depends on result after calling DpsEventNotify 
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleReturnStatusL()
+	{
+    FLOG(_L("[IMAGEPRINTUI]>>> CEventManager; HandleReturnStatus"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager event value is %d"), iEventRequest.iEvent ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iPrintStatus is %x"), iEventRequest.iPrinterEvent.iRepParam.iPrintStatus ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iJobStatus is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobStatus ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iErrorStatus hex is %x"), iEventRequest.iPrinterEvent.iRepParam.iErrorStatus ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iJobEndReason is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iPaperMinor is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iPaperMinor ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iInkMinor is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iInkMinor ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iHardMinor is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iHardMinor ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iFileMinor is %x"), iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iFileMinor ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iDisconnectEnable is %d"), iEventRequest.iPrinterEvent.iRepParam.iDisconnectEnable ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iCapabilityChange is %d"), iEventRequest.iPrinterEvent.iRepParam.iCapabilityChange ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager iNewJobOk is is %d"), iEventRequest.iPrinterEvent.iRepParam.iNewJobOk ));
+    
+    
+	if(iEventRequest.iEvent == EDpsEvtNotifyJobStatus)	
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CEventManager; NotifyPrintProgress"));
+		FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager  iImagesPrinted is %d"), iEventRequest.iJobEvent.iRepParam.iImagesPrinted ));
+		FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager  iProgress is %d"), iEventRequest.iJobEvent.iRepParam.iProgress ));
+	    iAppUi->NotifyPrintProgress(iEventRequest.iJobEvent.iRepParam.iImagesPrinted, 
+	                                 iEventRequest.iJobEvent.iRepParam.iProgress);
+		}
+		
+	else if(iEventRequest.iEvent == EDpsEvtNotifyDeviceStatus)
+		    {		    		    
+		    FLOG(_L("[IMAGEPRINTUI]<<< CEventManager; HandleReturnStatus, EDpsEvtNotifyDeviceStatus"));
+		    iAppUi->NotifyPrintStatus(iEventRequest.iPrinterEvent.iRepParam.iPrintStatus);
+		    
+		    HandleJobStatusL(iEventRequest.iPrinterEvent.iRepParam.iJobStatus);
+		    
+		    HandleErrorStatusL(iEventRequest.iPrinterEvent.iRepParam.iErrorStatus);
+		    
+		    if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorPaper)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::EDpsJobErrorPaper"));
+				HandlePaperErrorL(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iPaperMinor);
+				}
+			else if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorInk)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::EDpsJobErrorInk"));
+				HandleInkErrorL(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iInkMinor);
+				}
+			else if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorFile)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::EDpsJobErrorFile"));
+				HandleFileErrorL(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iFileMinor);
+				}
+			else if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorHardware)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::EDpsJobErrorHardware"));
+				HandleHardwareErrorL(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iHardMinor);
+				}			
+		    
+		    if(iEventRequest.iPrinterEvent.iRepParam.iNewJobOk)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, NewJob is OK"));
+				iAppUi->NotifyEventL(CEventManager::ENewJobOK );
+		    	}
+	        //capability change	
+			else if(iEventRequest.iPrinterEvent.iRepParam.iCapabilityChange)
+				{
+				FLOG(_L("[IMAGEPRINTUI] CEventManager::capability change"));
+				iAppUi->NotifyEventL(CEventManager::ECapabilityChange);
+				}
+		    }
+    FLOG(_L("[IMAGEPRINTUI]<<< CEventManager; HandleReturnStatus, next call StartListening"));		    
+	StartListening();
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleErrorStatusL(TInt aStatus)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleErrorStatusL"));
+	if(aStatus  == EDpsErrorStatusOk)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, EDpsErrorStatusOk"));
+	    iAppUi->NotifyEventL(CEventManager::ENotErrorState);
+		}	
+	else if(aStatus == EDpsErrorStatusFatal)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, Fatal error"));
+		iAppUi->NotifyEventL(CEventManager::EErrorState);
+		
+		if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iInkMinor == EDpsInkEmpty ||
+		   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iInkMinor == EDpsInkLow ||
+		   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iPaperMinor == EDpsPaperJam )
+			{
+			FLOG(_L("[IMAGEPRINTUI] CEventManager Fatal error, don't show note"));
+			}
+		else if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorPaper ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorInk ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorHardware ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorFile )
+			{
+			FLOG(_L("[IMAGEPRINTUI] CEventManager error major, don't show note"));
+			}
+		 	
+		else 
+			{
+			FLOG(_L("[IMAGEPRINTUI] CEventManager Fatal error, show note"));
+		    iAppUi->NotifyEventL(EDpsErrorStatusFatal);	
+			}		
+		}
+	else if(aStatus == EDpsErrorStatusWarning)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, Warning"));
+		iAppUi->NotifyEventL(CEventManager::EErrorState);
+				
+	    if(iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorPaper ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorInk ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorHardware ||
+    	   iEventRequest.iPrinterEvent.iRepParam.iJobEndReason.iMajor == EDpsJobErrorFile )
+			{
+			FLOG(_L("[IMAGEPRINTUI] CEventManager warning major, don't show note"));
+			}
+		else
+			{
+			FLOG(_L("[IMAGEPRINTUI] CEventManager warning,  show note"));
+			iAppUi->NotifyEventL(CEventManager::EWarning);	
+			}
+		}	
+	}
+	
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleJobStatusL(TInt aStatus)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleJobStatusL"));
+	if( aStatus == EDpsJobStatusEndedOther)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, User cancel from printer"));
+		iAppUi->NotifyEventL(EDpsJobStatusEndedOther);
+		}
+		
+	else if( aStatus  == EDpsJobStatusEndedOk)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, Job ended normally"));
+		iAppUi->NotifyEventL(EDpsJobStatusEndedOk );
+		}	
+	else if( aStatus  == EDpsJobStatusEndedAbortImmediately)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleDeviceStatusL, User has abort job"));
+		iAppUi->NotifyEventL(EDpsJobStatusEndedAbortImmediately);
+		}	
+	
+	}
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleHardwareErrorL(TInt aError)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleHardwareErrorL"));
+	 if( aError ==  EDpsHardFatal || aError ==  EDpsHardServiceCall ||
+         aError ==  EDpsHardNotAvailable || aError ==  EDpsHardBusy || 
+         aError ==  EDpsHardLever || aError ==  EDpsHardCoverOpen ||
+         aError ==  EDpsHardNoMarkingHead || aError ==  EDpsHardInkCoverOpen ||
+         aError ==  EDpsHardNoInkCartridge  )
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CEventManager::harware  minor"));
+		iAppUi->NotifyEventL(CEventManager::EWarning);
+		}	
+	else 
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::Hardware major"));
+		iAppUi->NotifyEventL(CEventManager::EShowError);
+		} 		
+	
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleInkErrorL(TInt aError)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleInkErrorL"));
+	if(aError == EDpsInkEmpty)
+	    {
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::ink empty"));
+		iAppUi->NotifyEventL(CEventManager::EInkEmpty); 
+		}
+	else if(aError == EDpsInkLow )
+	    {
+	    FLOG(_L("[IMAGEPRINTUI] CEventManager::ink low"));
+	    iAppUi->NotifyEventL(EDpsInkLow);	
+	    }
+	else if( aError== EDpsInkWaste)	
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::ink general"));
+		iAppUi->NotifyEventL(CEventManager::EWarning);
+		}
+	else 
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager ink major,  show note"));
+	    iAppUi->NotifyEventL(CEventManager::EShowError);	
+		}
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandlePaperErrorL(TInt aError)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandlePaperErrorL"));
+	
+	if( aError == EDpsPaperLoad  || aError == EDpsPaperEject ||
+	    aError == EDpsPaperMedia || aError == EDpsPaperNearlyEmpty ||
+	    aError == EDpsPaperTypeSizeNoMatch ) 
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CEventManager::paperMinor, show warning"));
+		iAppUi->NotifyEventL(CEventManager::EWarning);
+		}
+	else if( aError == EDpsPaperJam)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::Paper jam"));
+		iAppUi->NotifyEventL(EDpsPaperJam);
+		}
+	else if( aError == EDpsPaperEmpty)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::Paper empty"));
+		iAppUi->NotifyEventL(EDpsPaperEmpty);
+		}	
+    else
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager paper major, show note"));
+	    iAppUi->NotifyEventL(CEventManager::EShowError);	
+		}		
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::HandleFileErrorL(TInt aError)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CEventManager::HandleFileErrorL"));
+	
+	if(aError ==  EDpsFilePrintInfo ||
+       aError ==  EDpsFileDecode  )
+	    {
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::file minor"));
+		iAppUi->NotifyEventL(CEventManager::EWarning);
+		}	
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::file major"));
+		iAppUi->NotifyEventL(CEventManager::EShowError);
+		}
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CEventManager::RunError()
+    {
+    FLOG(_L("[IMAGEPRINTUI] CEventManager::RunError"));
+    
+    StartListening();
+    if(iStatus.Int() == KErrTimedOut)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]<<< CEventManager; RunError, timed out"));	
+    	}
+    else if( iStatus.Int() == KErrUsbInterfaceNotReady)	
+		{
+		FLOG(_L("[IMAGEPRINTUI] CEventManager::KErrUsbInterfaceNotReady"));
+		// iAppUi->NotifyEventL(KErrUsbInterfaceNotReady);
+		}		
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager::RunError iStatus is is %d"), iStatus.Int() ));
+    // iAppUi->NotifyEventL(CEventManager::ESeriousError);
+    }
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CEventManager::RunL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CEventManager::RunL"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CEventManager::RunL iStatus   is %d"), iStatus.Int() ));
+    if (iStatus.Int() == KErrNone)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CEventManager::RunL no error"));
+	    HandleReturnStatusL();
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CEventManager::RunL there is error in iStatus"));
+		User::LeaveIfError(iStatus.Int());
+		}
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEventManager::DoCancel()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> CEventManager  DoCancel"));
+    iDpsEngine->CancelDpsEventNotify();
+    FLOG(_L("[IMAGEPRINTUI]>>> CEventManager  DoCancel complete"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/imageprintuiapp.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* 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:  S60 UI class
+*
+*/
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+#include "imageprintuiapp.h"
+#include "imageprintuidocument.h"
+ 
+// ================= MEMBER FUNCTIONS =========================================
+
+// ---------------------------------------------------------------------------
+// CImagePrintUiApp::AppDllUid()
+// return the Uid of the application
+// ---------------------------------------------------------------------------
+//
+TUid CImagePrintUiApp::AppDllUid() const
+    {
+    return KUidImagePrint;
+    }
+
+// ---------------------------------------------------------------------------
+// CImagePrintUiApp::CreateDocumentL()
+// Creates CImagePrintUiDocument object
+// ---------------------------------------------------------------------------
+//
+CApaDocument* CImagePrintUiApp::CreateDocumentL()
+    {
+    return CImagePrintUiDocument::NewL( *this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Constructs and returns an application object.
+// ---------------------------------------------------------------------------
+//
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CImagePrintUiApp;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Main function of the application executable.
+// ---------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/imageprintuiappui.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,883 @@
+/*
+* 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:  S60 AppUi class
+*
+*/
+
+
+#include <avkon.hrh>
+#include <avkon.rsg> 
+#include <AiwGenericParam.h>
+#include <GenericParamConsumer.h>
+#include <aknnavide.h>
+#include <imageprintui.rsg>
+#include <AknWaitDialog.h>
+#include <f32file.h>
+#include <s32file.h>
+// #include <d32usbc.h>
+
+#include <badesca.h>
+#include <bautils.h>
+#include <e32std.h>
+#include <pathinfo.h> 
+
+#include "imageprintui.hrh"
+#include "imageprintuiappui.h"
+#include "imageprintuidocument.h"
+#include "emptyview.h"
+#include "settingsview.h"
+#include "imageprintuidebug.h"
+#include "connectionmanager.h"
+#include "capabilitymanager.h"
+#include "requestmanager.h"
+#include "eventmanager.h"
+#include "notes.h"
+#include "notetimer.h"
+
+ 
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+//  ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::ConstructL()
+    {
+    
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ConstructL()"));
+    
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK );
+    iEngine = static_cast<CImagePrintUiDocument*>(Document())->Engine();
+    
+    iImageFiles = new (ELeave) CDesCArrayFlat(KImageDefaultArray);
+    iNotes = CNotes::NewL(this);
+    iNoteShowed = EFalse;
+    LoadImagesL();
+    
+    CAknView* emptyview = CEmptyView::NewLC();
+    AddViewL(emptyview);
+    CleanupStack::Pop(emptyview); 
+
+    CAknView* settingsview = CSettingsView::NewLC();
+    AddViewL(settingsview);
+    CleanupStack::Pop(settingsview);
+    ActivateLocalViewL( emptyview->Id() ); 
+ 
+    iCableConnected = EFalse;
+    iActiveNote = EFalse;
+    iNumberOfUnSuppFiles = 0;
+    iCapabilityChanged = EFalse;
+    iPrintActive = EFalse;
+    iErrorState = EFalse;
+    iStartJobOK = EFalse;
+    iPaperEmpty = EFalse;
+    iNoteTimeOut = EFalse;
+    iCloseTimeOut = EFalse;
+    iCapabilityTimeOut = EFalse;
+    iRequestTimeOut = EFalse;
+    iNoteTimer = CNoteTimer::NewL(this);
+    ReadNumberOfUnSuppL();
+   
+    iConnectionManager = CConnectionManager::NewL(this, iEngine, iNotes);
+    iConnectionManager->StartSearchPrinter();
+      
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ConstructL() complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CImagePrintUiAppUi::~CImagePrintUiAppUi()
+    {
+    delete iNaviDecorator;
+    delete iCapabilityManager; 
+    delete iRequestManager; 
+    
+    delete iEventManager;
+    delete iConnectionManager; 
+       
+    delete iNoteTimer;    	
+    delete iNotes;
+    delete iImageFiles;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Handle global commands
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::HandleCommandL(TInt aCommand)
+    {
+
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::HandleCommandL()"));
+
+    // Handle global events
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit: 
+        case EAknSoftkeyBack:
+        case EAknCmdExit:
+        case EEikCmdExit:
+            {
+            Exit(); 
+            break;
+            }
+        default:
+            break;
+        }
+
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::HandleCommandL() complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// Closes the application when the cable is disconnected or when some other
+// mode is selected. 
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::CloseApplication(TBool aDisconnect)
+	{
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::CloseApplication"));
+    iNotes->SetDisconnectState(aDisconnect);
+    if(iPrintActive)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::CloseApplication show note"));
+    	TRAP_IGNORE(iNotes->ShowErrorMsgL(R_ERROR_CONNECTION_LOST));
+    	if(!iNoteTimer->IsActive())
+    		iCloseTimeOut = ETrue;
+    		iNoteTimer->After(KRetryClose);
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::CloseApplication just now"));
+    	TRAPD(err, ProcessCommandL(EAknCmdExit));  
+    	if(err)
+    		{
+    		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::error when CloseApplication"));
+    		}
+    	}
+    
+	}
+
+// ---------------------------------------------------------------------------
+// Closes the application after showing note
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::CloseAfterNoteL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::CloseAfterNoteL "));
+	ProcessCommandL(EAknCmdExit);  
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CImagePrintUiAppUi::NotifyPrintStatus(TInt aStatus)
+	{
+	FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUiAppUi::NotifyPrintStatus "));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI] CImagePrintUiAppUi  aStatus is %x"), aStatus ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI] CImagePrintUiAppUi  aStatus is %d"), aStatus ));
+	if(aStatus == EDpsPrintServiceStatusPrinting || aStatus == EDpsPrintServiceStatusIdle)
+		{
+		FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUiAppUi::NotifyPrintStatus set flag false "));
+		iPaperEmpty = EFalse;
+		}
+	if(aStatus == EDpsPrintServiceStatusPrinting)
+		{
+		FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUiAppUi::Print status active "));
+	    iPrintActive = ETrue;	
+		}
+	if(aStatus == EDpsPrintServiceStatusIdle)
+		{
+		FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUiAppUi::Print status idle"));
+		iNotes->PrintProgress(KPrintFinishValue);   
+	    iPrintActive = EFalse;	
+		}
+	FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUiAppUi::NotifyPrintStatus "));
+	}
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::NotifyPrintProgress(TInt aImagesPrinted, TInt aProgress)
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress"));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi aImagesPrinted value is %d"), aImagesPrinted ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi aProgress value is %d"), aProgress ));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi iNumberOfImages value is %d"), iNumberOfImages ));
+    TInt realProgress;
+    TUint currentlayout;
+    
+    currentlayout = iCapabilityManager->Layout();
+	
+	if(currentlayout == EDpsLayoutDefault || currentlayout == EDpsLayout1Up)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress progress print"));
+		if(iNumberOfImages == KImageNumber)
+			{
+			FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress layout case 1 image"));
+			aImagesPrinted = aImagesPrinted*KPrintFinishValue;
+			realProgress = aImagesPrinted/iNumberOfImages;
+			realProgress = (realProgress <= KPrintFinishValue) ? realProgress : KPrintFinishValue;
+		    
+			if(!iErrorState)	
+				{
+				FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress no error "));
+			    iNotes->PrintProgress(realProgress);	
+				}
+			}
+		
+		if(iNumberOfImages > KImageNumber)
+			{
+			FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress one print image several images"));
+			if(aProgress < KPrintFinishValue)
+				{
+				FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress one print image several images update"));
+			    if(!iErrorState)
+			    	{
+			    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress no error state "));
+			        iNotes->PrintProgress(aProgress); 	
+			    	}
+				}
+		
+			}
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress NumberOfImages print"));
+		aImagesPrinted = aImagesPrinted*KPrintFinishValue;
+		realProgress = aImagesPrinted/iNumberOfImages;
+		realProgress = (realProgress <= KPrintFinishValue) ? realProgress : KPrintFinishValue;
+		if(realProgress == KPrintFinishValue)
+			{
+			FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress printing done layout big"));
+			}
+	    
+		if(realProgress < KPrintFinishValue)
+			{
+			FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress show progress layout big"));
+			if(!iErrorState)
+				{
+				FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress no error state"));
+			    iNotes->PrintProgress(realProgress); 	
+				}
+		    else
+		    	{
+		    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyPrintProgress error state"));
+		    	}
+			}
+		
+		}
+	}
+
+// ---------------------------------------------------------------------------
+// To inform about info from eventmanager
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::NotifyEventL( TInt aEventNotifyType)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CImagePrintUiAppUi NotifyEvent start"));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi aEventNotifyType is  %d"), aEventNotifyType ));
+	switch(aEventNotifyType)
+		{
+        case CEventManager::ENewJobOK:
+            FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> New job OK"));
+            break;
+            
+        case CEventManager::ENewJobNOK: 
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> New job NOK"));
+             iNotes->ShowErrorMsgL(R_ERROR_PRINTER_BUSY);
+             break;    
+             
+        case CEventManager::ECapabilityChange:
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> Capability change"));
+             TRAPD(err, iCapabilityManager->AskCapabilitiesL(ETrue));
+             if(err)
+             	{
+             	iNotes->ShowErrorMsgL(R_ERROR_GENERAL);
+             	}
+             break; 
+             
+        case EDpsPaperJam: 
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi Paper Jam"));	 	
+        	 iNotes->ShowErrorMsgL(R_ERROR_PAPER_JAM);
+             break;  
+             
+        case EDpsPaperEmpty: 
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi Paper empty"));
+        	 iPaperEmpty = ETrue;
+        	 iNotes->ShowErrorMsgL(R_ERROR_OUT_OF_PAPER);
+             break;       
+             
+        case CEventManager::EInkEmpty:
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi Ink empty"));
+        	 iNotes->PrintFinished();	
+        	 iNotes->ShowErrorMsgL(R_ERROR_OUT_OF_INK); 
+             break;
+             
+        case EDpsInkLow: 
+        	 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi Ink low"));	
+        	 iNotes->ShowErrorMsgL(R_ERROR_INK_LOW);  
+             break;   
+                 
+		case EDpsJobStatusEndedOther: 
+			 FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> User cancel from printer"));	
+			 if(iPrintActive )
+			 	{
+			 	iNotes->PrintFinished();
+				FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> User cancel print active"));
+				iPrintActive = EFalse;
+			 	}
+			 break;	
+        case EDpsJobStatusEndedOk: 
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> Job eneded normally"));
+        	break;
+        	
+		case EDpsJobStatusEndedAbortImmediately: 
+			FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  User aborted"));
+			break;
+			
+		case EDpsErrorStatusFatal: 
+		    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  Fatal error in printer side"));
+		    if(iPrintActive)
+		    	{
+		    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  Fatal error in printer side, stop progress note"));
+		    	iNotes->PrintFinished();
+		    	iPrintActive = EFalse;
+		    	}
+		    iNotes->ShowErrorMsgL(R_ERROR_CHECK_STATUS);
+            break;
+            
+        case CEventManager::EWarning:
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  Warning in printer side"));
+        	if(!iPaperEmpty)
+        		{
+        		if(iPrintActive)
+			    	{
+			    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  Warning in printer side, stop progress note"));
+			    	iNotes->PrintFinished();
+			    	iPrintActive = EFalse;
+			    	}
+			    	iNotes->ShowErrorMsgL(R_ERROR_CHECK_STATUS);
+        		}
+            break;
+            
+        case CEventManager::ENotErrorState:
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi,  Not Error State"));
+        	iErrorState = EFalse;
+        	break;
+        
+        case CEventManager::EErrorState:  
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi,  Error State"));
+        	iErrorState = ETrue;
+        	break;
+        
+        case CEventManager::EShowError:
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi, EShowError"));
+        	if(iPrintActive)
+		    	{
+		    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  EShowError in printer side, stop progress note"));
+		    	iNotes->PrintFinished();
+		    	iPrintActive = EFalse;
+		    	}
+        	iNotes->ShowErrorMsgL(R_ERROR_GENERAL);
+        	break;
+        
+	// 	case KErrUsbInterfaceNotReady:
+		// 	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi, KErrUsbInterfaceNotReady"));
+			// break;
+        
+        default:
+        	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi  NotifyEvent::Default branch"));  		
+            break;   
+		}
+	}
+// ---------------------------------------------------------------------------
+// To inform about info from requestmanager
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::NotifyRequestL(TInt aNotifyType)
+	{
+	FLOG(_L("[IMAGEPRINTUI] CImagePrintUiAppUi NotifyRequest start"));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi aNotifyType is  %d"), aNotifyType ));
+	switch(aNotifyType)
+		{
+        case CRequestManager::EConfigurePrintServiceOK:
+            FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EConfigurePrintServiceOK "));
+            TRAPD(err, iCapabilityManager->AskCapabilitiesL(EFalse));
+            if(err)
+            	{
+            	iNotes->ShowErrorMsgL(R_ERROR_GENERAL);
+            	}
+            break;
+            
+                 
+        case CRequestManager::EConfigurePrintServiceNOK:
+             //printer does not support
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EConfigurePrintServiceNOK "));
+             iNotes->ShowErrorMsgL(R_ERROR_UNABLE_TO_CONNECT); 
+             break;    
+             
+        case CRequestManager::EGetJobStatusOK:
+        	 FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EGetJobStatusOK "));	
+             break; 
+             
+        case CRequestManager::EGetJobStatusNOK:
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EGetJobStatusNOK "));
+             iNotes->ShowErrorMsgL(R_ERROR_GENERAL);  
+             break;      
+             
+        case CRequestManager::EGetDeviceStatusOK:
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EGetDeviceStatusOK, start print "));
+             break;
+             
+        case CRequestManager::EGetDeviceStatusNOK:
+             // printer is busy
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EGetDeviceStatusNOK "));
+             iNotes->ShowErrorMsgL(R_ERROR_PRINTER_BUSY); 
+             break;  
+             
+        case CRequestManager::EStartJobOK:	
+             //printing start ok
+             FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::EStartJobOK"));
+             iPrintActive = ETrue;
+             iStartJobOK = ETrue;
+             FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi EStartJobOK  iPrintActiveis  %d"), iPrintActive ));
+             break;
+             
+        case CRequestManager::EStartJobNOK:
+             //printing start nok
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EStartJobNOK "));
+             iNotes->ShowErrorMsgL(R_ERROR_GENERAL); 
+             break;     
+             
+        case CRequestManager::EAbortJobOK:
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EAbortJobOK ")); 
+             break; 
+             
+        case CRequestManager::EAbortJobNOK:
+             iNotes->ShowErrorMsgL(R_ERROR_GENERAL); 
+             CloseApplication(EFalse);
+             FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EAbortJobNOK ")); 
+             break;
+             
+        case CRequestManager::EPicturesNotFound:  
+        	FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; EPicturesNotFound ")); 
+        	iNotes->ShowErrorMsgL(R_ERROR_FILE_NOT_FOUND); 
+        	break;
+        		  
+        default:
+            FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUiAppUi NotifyRequest; Default branch")); 
+            break;   
+		
+		}
+	
+	FLOG(_L("[IMAGEPRINTUI] CImagePrintUiAppUi NotifyRequest; END "));
+	}
+
+
+// ---------------------------------------------------------------------------
+// To inform number of images
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::NumberOfImages(TInt aNumberOfImages)
+	{
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t NumberOfImages iNumberOfImages  is %d"), iNumberOfImages));
+	iNumberOfImages = aNumberOfImages;
+	}
+	
+// ---------------------------------------------------------------------------
+// To handle timer timeout
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::HandleTimeOutL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeOutL"));
+	if(iNoteTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeOutL, note"));
+		iNoteTimeOut = EFalse;
+		ShowNoteL(); 		
+		}
+	else if(iCloseTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeOutL, close"));
+		iCloseTimeOut = EFalse;
+		CloseAfterNoteL();
+		}
+	else if(iCapabilityTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeOutL, capability"));
+		iCapabilityTimeOut = EFalse;
+		iCapabilityManager->AskCapabilitiesL(EFalse);
+    	}
+	else if(iRequestTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeOutL, request"));
+		iRequestTimeOut = EFalse;
+		iRequestManager->ReIssueDoDpsRequestL();
+		}
+	
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> HandleTimeOutL"));
+	}
+	
+// ---------------------------------------------------------------------------
+// To handle timer error
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::HandleTimeErrorL(TInt aError)
+	{
+	if(iNoteTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeErrorL, note"));
+		if(aError == KErrTimedOut)
+			{
+			iNoteTimeOut = EFalse;
+			ShowNoteL();
+			}
+		}
+	else if(iCloseTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeErrorL, close"));
+		if(aError == KErrTimedOut)
+			{
+		    iCloseTimeOut = EFalse;
+			CloseAfterNoteL(); 	
+			}
+		}
+	else if(iCapabilityTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeErrorL, capability"));
+		if(aError == KErrTimedOut)
+			{
+			iCapabilityTimeOut = EFalse;
+			iCapabilityManager->AskCapabilitiesL(EFalse);
+			}
+		}
+	else if(iRequestTimeOut)
+		{
+		FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleTimeErrorL, request"));
+		if(aError == KErrTimedOut)
+    		{
+			iRequestTimeOut = EFalse;
+			iRequestManager->ReIssueDoDpsRequestL();
+    		}
+		
+		}
+	
+	
+	}
+// ---------------------------------------------------------------------------
+// To handle request timeout
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::HandleRequestTime(TInt aTime)
+	{	
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleRequestTimeL"));
+	iRequestTimeOut = ETrue;
+	if(!iNoteTimer->IsActive())
+		{
+	    iNoteTimer->After(aTime); 	
+		}
+	}
+	
+// ---------------------------------------------------------------------------
+// To handle capability timeout
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::HandleCapabilityTime(TInt aTime)
+	{	
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< HandleCapabilityTimeL"));
+	iCapabilityTimeOut = ETrue;
+	if(!iNoteTimer->IsActive())
+		{
+	    iNoteTimer->After(aTime);	
+		}
+	}
+		
+// ---------------------------------------------------------------------------
+// To inform when the cable is connected
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::CableConnectedL()
+	{
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi <<< CableConnected"));
+      
+    iCableConnected = ETrue;
+    iEventManager = CEventManager::NewL(this, iEngine);
+    iCapabilityManager = CCapabilityManager::NewL(this, iEngine);
+    iRequestManager    = CRequestManager::NewL(iEngine, iCapabilityManager, this);
+    
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> CableConnected"));
+	}
+
+
+// ---------------------------------------------------------------------------
+// To inform when the cable is disconnected
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::NotifyError()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::NotifyError"));
+	TRAP_IGNORE(iNotes->ShowErrorMsgL(R_ERROR_GENERAL));
+	}
+// ---------------------------------------------------------------------------
+// To inform when the cable is disconnected
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::CableDisConnected()
+	{
+	iCableConnected = EFalse;
+	}
+// ---------------------------------------------------------------------------
+// CapabilityManager informs here when capabilities are fetched from dps engine
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::CapabilitiesReady()
+{
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::CapabilitiesReady, activate local view"));
+    TRAPD(err,ActivateLocalViewL(KImagePrintSettingsViewId));
+    if(err)
+    	{
+    	TRAP_IGNORE(iNotes->ShowErrorMsgL(R_ERROR_GENERAL));
+    	}
+    	
+    TRAPD(err2, SetNavipaneTextL()); 
+    if(err2)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI] CImagePrintUiAppUi::Unable to show printer name"));
+    	}
+} 
+
+
+// ---------------------------------------------------------------------------
+// This is called when the user presses Options->Print
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::StartPrinting()
+	{
+    // get first device status, then if OK  dps type start job
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> StartPrinting called")); 
+    iCapabilityManager->CheckIfNewCapabilityDiffer();
+    if(iCableConnected)
+    	{
+        iNotes->SetCancelState(EFalse);
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> StartPrinting, cable connected")); 
+        TRAPD(err, iRequestManager->ChooseDpsRequestTypeL(CRequestManager::EGetDeviceStatus )); 
+        if(err)
+        	{
+        	TRAP_IGNORE(iNotes->ShowErrorMsgL(R_ERROR_GENERAL));
+        	}
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> StartPrinting, cable NOT connected")); 
+    	TRAP_IGNORE(iNotes->ShowNoteL(R_CONNECT_USB));
+    	iActiveNote = ETrue;
+    	}                                          
+    
+	}
+
+
+// ---------------------------------------------------------------------------
+// This is called when the user presses Options->Cancel Print
+// ---------------------------------------------------------------------------
+//
+
+void CImagePrintUiAppUi::CancelPrinting()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> CancelPrinting BEGIN"));
+	TBool cancel = ETrue;
+    iNotes->SetCancelState(cancel);
+	TRAPD(err, iRequestManager->ChooseDpsRequestTypeL(CRequestManager::EAbortJob ));
+	if(err)
+    	{
+        TRAP_IGNORE(iNotes->ShowErrorMsgL(R_ERROR_GENERAL));
+        }
+
+	
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi >>> CancelPrinting END"));
+	}
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDesCArrayFlat* CImagePrintUiAppUi::ImagesToPrint()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ImagesToPrint()"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] ImagesToPrint; iImageFiles  is %x"), iImageFiles ));
+    return iImageFiles;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+
+void CImagePrintUiAppUi::ReadNumberOfUnSuppL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ReadNumberOfUnSuppL start()"));
+    
+    TFileName unSuppFile( KResource ); 
+    unSuppFile = PathInfo::PhoneMemoryRootPath(); 
+    TBuf<KResource> lengthUn(KUnSuppFile);
+    unSuppFile.SetLength(KDriver + lengthUn.Length());
+    unSuppFile.Replace(KDriver, lengthUn.Length(), KUnSuppFile);
+    
+    
+    RFileReadStream readStream;
+    User::LeaveIfError( readStream.Open(CCoeEnv::Static()->FsSession(), unSuppFile, EFileRead) );
+    readStream.PushL();
+    iNumberOfUnSuppFiles = readStream.ReadInt16L();	
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CImagePrintUiAppUi iNumberOfUnSuppFiles  is %d"), iNumberOfUnSuppFiles ));
+    CleanupStack::PopAndDestroy(&readStream); 
+    
+    
+    if(iNumberOfUnSuppFiles < KNumberOfUnsupportedFiles)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ReadNumberOfUnSuppL none"));
+    	}
+    else if(iNumberOfUnSuppFiles == KNumberOfUnsupportedFiles ||
+            iNumberOfUnSuppFiles > KNumberOfUnsupportedFiles)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::ReadNumberOfUnSuppL one or more"));
+    	if(!iNoteTimer->IsActive())
+    	    iNoteTimeOut = ETrue;
+    		iNoteTimer->After(KRetryInterval);
+    	} 
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::LoadImagesL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::LoadImagesL()"));
+    
+    TFileName printNameFile( KResource ); 
+    printNameFile = PathInfo::PhoneMemoryRootPath();  
+    TBuf<KResource> length(KParamFile);
+    printNameFile.SetLength(KDriver + length.Length());
+    printNameFile.Replace(KDriver, length.Length(), KParamFile);
+    
+  
+    RFileReadStream readStream;
+    CleanupClosePushL(readStream); //1
+    User::LeaveIfError( readStream.Open(CCoeEnv::Static()->FsSession(),
+                        printNameFile, EFileRead) );
+    CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(readStream); //2
+
+    TInt index( 0 ); 
+    const TAiwGenericParam* param = paramList->FindFirst(index,
+            EGenericParamFile,
+            EVariantTypeDesC);
+    while ( index != KErrNotFound )
+		{
+        TFileName filename( param->Value().AsDes() );
+        FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::LoadImagesL; append picture")); 
+        iImageFiles->AppendL( filename ); 	
+        	
+        param = paramList->FindNext(index,
+            EGenericParamFile,
+            EVariantTypeDesC);
+        }
+
+    CleanupStack::PopAndDestroy(paramList);
+    CleanupStack::PopAndDestroy(&readStream);
+  
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::LoadImagesL() complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// Set navi pane text
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::SetNavipaneTextL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::SetNavipaneTextL Start"));
+    CEikStatusPane* sp =
+        iEikonEnv->AppUiFactory()->StatusPane();
+       
+    CAknNavigationControlContainer* np =
+        static_cast<CAknNavigationControlContainer*>(
+            sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
+           
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    
+    TInt blank(1);
+    TBuf8<KMaxPrinterName> printername;
+    TBuf8<KMaxPrinterName> productname;
+    
+    iRequestManager->GetPrinterName(printername, productname); 
+    // convert to HBuf16 because CreateNavigationLabel needs TDesC16, not TDesC8
+    HBufC* temp = HBufC::NewLC(printername.Length() + productname.Length() + blank); 
+    HBufC* temp2 = HBufC::NewLC(productname.Length()); 
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CImagePrintUiAppUi printername  is %S"), &printername ));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CImagePrintUiAppUi productname  is %S"), &productname ));
+    temp->Des().Copy(printername); 
+    temp->Des().Append(_L(" "));
+    temp2->Des().Copy(productname);
+    temp->Des().Append(temp2->Des());
+    
+    iNaviDecorator = np->CreateNavigationLabelL( *temp );
+    CleanupStack::PopAndDestroy(temp2);
+    CleanupStack::PopAndDestroy(temp);
+    np->PushL( *iNaviDecorator );
+    sp->DrawNow(); 
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiAppUi::SetNavipaneText END"));
+    }
+
+CCapabilityManager* CImagePrintUiAppUi::CapabilityManager()
+	{
+	return iCapabilityManager;
+	}
+	
+CNotes* CImagePrintUiAppUi::Notes()
+	{
+	return iNotes;
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CImagePrintUiAppUi::PrintActive()
+	{
+	return iPrintActive;
+	}
+	
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiAppUi::ShowNoteL()
+	{
+    iNoteShowed = ETrue;
+    if(iNumberOfUnSuppFiles == KNumberOfUnsupportedFiles)
+    	{
+        iNotes->ShowInfoNoteL(R_ERROR_FILE_NOT_SUPPORTED);	
+    	}
+    else if(iNumberOfUnSuppFiles > KNumberOfUnsupportedFiles)
+    	{
+    	iNotes->ShowInfoNoteL(R_ERROR_UNSUPPORTED_FILES_REMOVED);
+    	}	
+	}
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/imageprintuidocument.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* 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:  S60 Document class
+*
+*/
+
+
+#include "imageprintuidocument.h"
+#include "imageprintuiappui.h"
+#include "imageprintuidebug.h"
+
+#include <e32cmn.h>
+#include <badesca.h>
+#include <bautils.h>
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CImagePrintUiDocument::CImagePrintUiDocument(CEikApplication& aApp)
+    : CAknDocument(aApp)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CImagePrintUiDocument::ConstructL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiDocument::ConstructL START"));
+   
+    TRAPD(err, iEngine = CDpsEngine::GetEngineL());
+    if(err == KErrInUse)
+    	{
+        FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiDocument::ConstructL, already in use"));	
+    	}
+	
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiDocument::ConstructL END"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CImagePrintUiDocument* CImagePrintUiDocument::NewL( CEikApplication& aApp)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiDocument::NewL()"));
+    CImagePrintUiDocument* self = new (ELeave) CImagePrintUiDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG(_L("[IMAGEPRINTUI]\t CImagePrintUiDocument::NewL() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Constructs CImagePrintUiAppUi
+// ---------------------------------------------------------------------------
+//
+CEikAppUi* CImagePrintUiDocument::CreateAppUiL()
+    {
+    return new (ELeave) CImagePrintUiAppUi;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Returns an instance of Image Print UI engine
+// ---------------------------------------------------------------------------
+//
+CDpsEngine* CImagePrintUiDocument::Engine()
+    {
+    return iEngine; 
+    }
+
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+//
+CImagePrintUiDocument::~CImagePrintUiDocument()
+    {
+    if(iEngine)
+    	{
+        iEngine->Delete();	
+    	}	
+    }
+
+    
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/notes.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,314 @@
+/*
+* 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:  Show all notes on the screen
+*
+*/
+
+
+#include <aknViewAppUi.h>
+#include <imageprintui.rsg>
+
+#include "imageprintui.hrh"
+#include "settingsview.h"
+#include <AknWaitDialog.h>
+#include <aknnotedialog.h>
+#include <aknprogresstimer.h>
+
+
+#include <e32std.h>
+#include <AknProgressDialog.h>
+#include <AknInfoPopupNoteController.h>
+
+#include <aknstaticnotedialog.h>
+#include <eikprogi.h>
+#include <aknnotewrappers.h>
+#include <StringLoader.h>
+#include <eikenv.h>
+
+#include "settingscontainer.h"
+#include "imageprintuidebug.h"
+#include "imageprintuiappui.h"
+#include "notes.h"
+
+const TUint KProgressFinishValue = 100;
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CNotes* CNotes::NewL(CImagePrintUiAppUi* aPrintUiAppUi)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::NewL()"));
+    CNotes* self = new( ELeave ) CNotes(aPrintUiAppUi);
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::NewL() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CNotes::~CNotes()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::Destructor"));
+    if(iWaitNote)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Delete iWaitNote"));
+        delete iWaitNote;
+        iWaitNote = NULL;
+    	}
+    if ( iProgressDialog )
+        {
+        FLOG(_L("[IMAGEPRINTUI]\t CNotes::Delete iProgressDialog"));
+        delete iProgressDialog;
+        iProgressDialog = NULL;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::Destructor complete"));
+
+    }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CNotes::CNotes(CImagePrintUiAppUi* aPrintUiAppUi): iPrintUiAppUi(aPrintUiAppUi),
+    iDisconnect(EFalse ),
+    iCancelling(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CNotes::DialogDismissedL(TInt aButtonId )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogDismissedL BEGIN"));	
+	
+    // If user pressed cancel, cancel printing
+    if(iProgressDialog)
+    	{
+        if(!iDisconnect)
+        	{
+        	FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL, not disconnect case"));
+		    if ( aButtonId == EAknSoftkeyCancel )
+		        {
+		        FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL ,sotfkey cancel iProgressDialog"));	
+		        iCancelling = ETrue;
+		        iPrintUiAppUi->CancelPrinting();
+		        }
+        	}
+    	}
+	if(iWaitNote)
+		{
+	 	if(!iDisconnect)
+        	{
+		 	if ( aButtonId == EAknSoftkeyCancel )
+		        {
+		        FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL ,sotfkey cancel iWaitNote"));
+		        iPrintUiAppUi->CloseApplication(EFalse);
+		        }
+        	}
+	  	}
+    
+    FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogDismissedL END"));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CNotes::ShowNoteL(TUint aNoteType)
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNote Start"));
+	if(!iWaitNote)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Create note"));
+		iWaitNote = new (ELeave) CAknWaitDialog(
+	              (REINTERPRET_CAST(CEikDialog**,&iWaitNote)), ETrue);
+	    FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; Note created"));          
+        iWaitNote->SetCallback( this ); 
+        FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; Callback set"));   
+        iWaitNote->ExecuteLD(aNoteType);
+        FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; ExecuteLD passed")); 
+    	} 	
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNotes::StopShowNote(TUint /*aNoteType*/)
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Stop note"));
+	delete iWaitNote;
+	iWaitNote = NULL;
+	}
+	
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CNotes::StartPrintingNotesL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> CNotes::StartPrintingNotesL")); 
+	PrepareShowProgressNoteL();
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::StartPrintingNotesL")); 
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNotes::PrepareShowProgressNoteL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]>>> CNotes::PrepareShowProgressNoteL")); 
+	HBufC* txt;
+	txt = StringLoader::LoadLC( R_QTN_PRINT_PROGRESS_NOTE_TITLE );
+            
+	if(!iProgressDialog)
+    	{
+    	iProgressDialog = new (ELeave) CAknProgressDialog(
+						(reinterpret_cast<CEikDialog**> (&iProgressDialog)));				
+    	}
+    	
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; PrepareLC next"));	
+   	iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
+	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
+	progressBar = iProgressDialog->GetProgressInfoL();
+	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; progressinfo got"));	
+	
+    progressBar->SetFinalValue( KProgressFinishValue );
+    iProgressDialog->SetTextL( *txt );
+    iProgressDialog->SetCallback( this );
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; RunLD next"));  
+    iProgressDialog->RunLD();
+    CleanupStack::PopAndDestroy( txt );  
+	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL")); 
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNotes::PrintProgress(TUint aProgress )
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgress start "));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CNotes PrintProgress aProgress value  is %d"), aProgress ));	
+    TInt err = KErrNone;
+    TRAP( err, PrintProgressL( aProgress ) );
+    if ( err != KErrNone )
+        {
+        FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CNotes PrintProgress err value  is %d"), err ));	
+        TRAP_IGNORE( CNotes::ShowErrorMsgL( err ) );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CNotes::SetCancelState(TBool aCancel)
+	{
+	iCancelling = aCancel;
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNotes::SetDisconnectState(TBool aDisconnect)
+	{
+	iDisconnect = aDisconnect;
+	}
+
+
+// ---------------------------------------------------------------------------
+// Called to update the print progress 
+// ---------------------------------------------------------------------------
+//
+void CNotes::PrintProgressL(TUint aProgress )
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL start; "));
+	if( !iCancelling )
+		{
+		if ( !iProgressDialog )
+        	{
+        	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL call PrepareShowProgressNoteL "));
+			PrepareShowProgressNoteL();
+        	}
+    	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
+    	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL; Update progress"));
+    	progressBar->SetAndDraw( aProgress );
+    	if(aProgress == KProgressFinishValue )
+    		{
+    		FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL; normal printing finish"));
+    		PrintFinished();
+    		}
+		}
+    FLOG(_L("[IMAGEPRINTUI]>>> CNotes::PrintProgressL END "));
+    }	
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	    
+void CNotes::ShowErrorMsgL(TUint aErrCode )
+	{
+	if ( aErrCode != KErrNone )
+        {
+        FLOG(_L("[IMAGEPRINTUI]>>> CNotes:Show err note "));
+        HBufC* str = StringLoader::LoadLC( aErrCode  );
+        CAknErrorNote* note = new ( ELeave ) CAknErrorNote;
+        note->ExecuteLD( *str );
+        CleanupStack::PopAndDestroy( str );  // str
+        }
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNotes::ShowInfoNoteL(TInt aResourceId )
+    {
+    HBufC* str = StringLoader::LoadLC( aResourceId );
+    CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
+    note->ExecuteLD( *str );
+    CleanupStack::PopAndDestroy( str);  // str
+    }
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//			
+void CNotes::PrintFinished()
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintFinished; START"));
+    if ( iProgressDialog )
+        {
+        FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintFinished, delete progress note"));
+        delete iProgressDialog;
+        iProgressDialog = NULL;
+        iCancelling = EFalse;
+        }
+    }
+
+//End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/notetimer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Handles situation after timer expired
+*
+*/
+
+
+#include "notetimer.h"
+#include "imageprintuiappui.h"
+#include "imageprintuidebug.h"
+
+CNoteTimer* CNoteTimer::NewL( CImagePrintUiAppUi* aAppUi)
+    {
+    CNoteTimer* self = CNoteTimer::NewLC( aAppUi);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//		
+CNoteTimer* CNoteTimer::NewLC( CImagePrintUiAppUi* aAppUi)
+    {
+    FLOG(_L("[IMAGEPRINTUI] CNoteTimer: NewLC"));
+    CNoteTimer* self = new (ELeave) CNoteTimer();
+    CleanupStack::PushL(self);
+    self->ConstructL(aAppUi);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CNoteTimer::CNoteTimer()
+    : CTimer(EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CNoteTimer::~CNoteTimer()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CNoteTimer::Destructor start")); 
+    Cancel();
+    FLOG(_L("[IMAGEPRINTUI]\t CNoteTimer::Destructor end"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//		
+void CNoteTimer::ConstructL(CImagePrintUiAppUi* aAppUi)
+    {
+    iAppUi = aAppUi;
+    CTimer::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CNoteTimer::RunL()
+    {
+    FLOG(_L("[IMAGEPRINTUI] CNoteTimer : RunL"));
+    iAppUi->HandleTimeOutL();
+    }
+
+// -----------------------------------------------------------------------------
+// CNoteTimer::RunError
+// Standard active object error function.
+// -----------------------------------------------------------------------------
+//
+
+TInt CNoteTimer::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CNoteTimer::RunError: err %d from RunL"), aError));
+    
+    TRAPD(err,iAppUi->HandleTimeErrorL(aError));
+    if(err)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI] CNoteTimer ::  err when call HandleTimeError"));
+    	}
+    
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/requestmanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,519 @@
+/*
+* 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:  Handles Dps Request call with AO
+*
+*/
+
+
+#include <e32base.h>
+#include <dpsdefs.h>
+#include <s32file.h>
+#include <f32file.h>
+#include <coeutils.h>
+#include <imageprintui.rsg>
+
+#include "requestmanager.h"
+#include "imageprintuiappui.h"
+#include "pictbridge.h"
+#include "notes.h"
+#include "capabilitymanager.h"
+#include "imageprintuidebug.h"
+
+// ---------------------------------------------------------------------------
+// constructor
+// ---------------------------------------------------------------------------
+//
+CRequestManager::CRequestManager(CDpsEngine* aDpsEngine,
+								 CCapabilityManager* aCapabilityManager, CImagePrintUiAppUi* aAppUi)
+    : CActive(CActive::EPriorityStandard),  iDpsEngine(aDpsEngine), 
+      iCapabilityManager(aCapabilityManager), iAppUi(aAppUi), iNumberOfImages(0)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+// 2nd phase construction
+// ---------------------------------------------------------------------------
+//
+
+void CRequestManager::ConstructL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager  ConstructL"));
+    iFileExist = EFalse;
+    iCongFileName = HBufC::NewL(iDpsEngine->DpsFolder().Length() + KConfigLength);
+    iCongFileName->Des().Copy(iDpsEngine->DpsFolder());
+    iCongFileName->Des().Append(KConfigInfoFile);
+    
+    // always start with configure, this is part of the DPS protocol
+    ChooseDpsRequestTypeL(EConfigurePrintService); 
+    
+    FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager  ConstructL"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CRequestManager* CRequestManager::NewL( CDpsEngine* aDpsEngine,
+									    CCapabilityManager* aCapabilityManager,CImagePrintUiAppUi* aAppUi)
+    {
+    CRequestManager* self = CRequestManager::NewLC( aDpsEngine, aCapabilityManager, aAppUi);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CRequestManager* CRequestManager::NewLC(CDpsEngine* aDpsEngine, 
+                                        CCapabilityManager* aCapabilityManager, 
+                                        CImagePrintUiAppUi* aAppUi)
+    {
+    CRequestManager* self = new( ELeave ) CRequestManager(aDpsEngine, 
+    													  aCapabilityManager, aAppUi);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CRequestManager::~CRequestManager()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager  Destructor called"));
+    delete iCongFileName;
+    Cancel();         
+    FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager  Destructor END"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::ReIssueDoDpsRequestL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager  ReIssueDoDpsRequestL"));
+	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CRequestManager::reissue request is %d"), iRequestType ));
+	ChooseDpsRequestTypeL(iRequestType);
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void	 CRequestManager::RunL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager  RunL"));
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CRequestManager::RunL iStatus   is %d"), iStatus.Int() ));
+    if(iStatus.Int() == KErrNone)
+    	{
+	    switch ( iRequestType )
+	        {
+	        case EConfigurePrintService:
+	            FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, Handle configure"));
+	            HandleConfigureL();
+	            break;
+	           
+	        case EGetJobStatus:
+	            FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, HandleGetJobStatusL"));
+	            HandleGetJobStatusL();
+	            break;
+	            
+	        case EGetDeviceStatus:
+	            FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, Handle Device Status"));
+	        	HandleDeviceStatusL();
+	        	break;
+	        	
+	        case EStartJob:
+	        	FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, Handle Start Job"));
+	        	HandleStartJobL();
+	        	break;
+	        	
+	        case EAbortJob:
+	            FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, HandleAbortL")); 
+	        	HandleAbortL();
+	        	break;
+	        	
+	        case EContinueJob:
+	            FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, EContinueJob")); 
+	        	break;
+	        	
+	        default:
+	        	FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, default branch")); 
+	            break;
+	        }
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUIENGINE]\t CRequestManager: RunL, call leave, it call RunError")); 
+    	User::LeaveIfError(iStatus.Int());
+    	}
+	FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager  RunL"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRequestManager::RunError
+// Standard active object error function.
+// -----------------------------------------------------------------------------
+//
+
+TInt CRequestManager::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CRequestManager::RunError: err %d from RunL"), aError));
+    if(aError == KErrNotFound)
+		{
+		FLOG(_L("[IMAGEPRINTUI] CRequestManager  Pictures not found when printing"));
+		TRAPD(err,iAppUi->NotifyRequestL(EPicturesNotFound));
+		if(err)
+			{
+			FLOG(_L("[IMAGEPRINTUI] CRequestManager  err calling notify"));
+			}
+		}
+	else if(aError == KErrTimedOut || aError == KErrInUse)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager; RunError, timed out or in use"));
+    	iAppUi->HandleRequestTime(KRetryClose);
+    	}		
+    	
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::DoCancel()
+    {
+    FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager  DoCancel"));
+    iDpsEngine->CancelDpsRequest(); 	
+    FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager  DoCancel complete"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::ExecuteStartJobRequestL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ExecuteStartJobRequestL "));
+	iStart.iReqParam.Reset();
+	            
+    TUint layout = iCapabilityManager->Layout();
+	TUint quality = iCapabilityManager->Quality();
+	TUint paperSize = iCapabilityManager->PaperSize();
+    
+    //fill request parameter by retrieved values
+    TDpsArgsInt req_quality,req_papersize, req_layout;
+    
+    req_quality.iElement = EDpsArgQuality;
+    req_quality.iContent = quality;
+    iStart.iReqParam.iJobConfig.Append(req_quality);
+    
+    req_papersize.iElement = EDpsArgPaperSize;
+    req_papersize.iContent = paperSize;
+    iStart.iReqParam.iJobConfig.Append(req_papersize);
+
+    req_layout.iElement = EDpsArgLayout;
+    req_layout.iContent = layout;
+    iStart.iReqParam.iJobConfig.Append(req_layout);
+              
+   
+    // retrieve  images
+    FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, Get Images"));
+    iImageArrayFlat = iAppUi->ImagesToPrint(); 	// not taking ownership
+    
+   
+    iNumberOfImages = iImageArrayFlat->Count();
+	TDpsPrintInfo* helpTDpsPrintInfo = new (ELeave) TDpsPrintInfo[iNumberOfImages];
+	CleanupStack::PushL(helpTDpsPrintInfo);          
+    // go through the list of images and add info for start job request 
+    
+    for(int i=0; i<iNumberOfImages; i++)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, Start job, append image"));
+    	// check if file really exist, use may have delete it after choose print
+    	// that will set printer unstable state
+    	iFileExist = ConeUtils::FileExists(iImageArrayFlat->operator[](i));
+    	if(iFileExist)
+    		{
+    		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, Start job, file exist"));
+    		helpTDpsPrintInfo[i].iFile.Copy(iImageArrayFlat->operator[](i));
+        	iStart.iReqParam.iPrintInfo.Append(helpTDpsPrintInfo[i]);
+    		}
+    	}
+    
+    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CRequestManager iNumberOfImages  is %d"), iNumberOfImages));	        
+    iAppUi->NumberOfImages(iNumberOfImages); 
+    if(!iFileExist)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager, ExecuteStartJobRequestL, file not exist "));
+        iAppUi->Notes()->ShowErrorMsgL(R_ERROR_FILE_NOT_FOUND); 
+    	}
+    else
+    	{
+    	iDpsEngine->DoDpsRequestL(&iStart, iStatus);
+    	}
+    
+	CleanupStack::PopAndDestroy(helpTDpsPrintInfo);
+
+	
+	FLOG(_L("[IMAGEPRINTUI]>>> CRequestManager, ExecuteStartJobRequestL "));
+	}
+// ---------------------------------------------------------------------------
+// Choose DoDpsRequest type
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::ChooseDpsRequestTypeL(const TRequestType aType)
+	{
+	iRequestType = aType;
+	switch ( aType )	
+	        {
+	      		        
+	        case EConfigurePrintService:
+	            FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType Configure"));
+	            iConfig.iReqParam.Reset();
+	            // retrieve current phone settings from DpsEngine and fill req param
+	            iDpsEngine->GetDpsConfigL(iConfig.iReqParam);
+	            iDpsEngine->DoDpsRequestL(&iConfig, iStatus);
+	            break;
+	        
+	        
+	        case EGetJobStatus:
+	        	// no need to fill parameter for this Dps request
+	        	iJobFinished = EFalse;
+	        	iDpsEngine->DoDpsRequestL(&iJob, iStatus);
+	            break;
+	            
+	        case EGetDeviceStatus:
+	            FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType Get Device status"));
+	        	// no need to fill parameter for this Dps request
+	        	iDpsEngine->DoDpsRequestL(&iPrinter, iStatus);
+	        	break;
+	        	
+	        case EStartJob:
+	         	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType Start Job"));
+	            ExecuteStartJobRequestL();
+	        	break;
+	        
+	        case EAbortJob:
+	        	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType Abort Job"));
+	            // fill only abort style ref. PictBridge Spec. CIPA DC-001-2003 page 68. 
+	            iAbort.iReqParam.iAbortStyle = EDpsAbortStyleImmediately;
+   				iDpsEngine->DoDpsRequestL(&iAbort, iStatus);
+	        	break;
+	        	
+	        case EContinueJob:
+	        FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType Continue Job"));
+	            // no need to fill parameter for this Dps request
+	        	iDpsEngine->DoDpsRequestL(&iContinue, iStatus);
+	        	break;
+	        	
+	        default:
+	        	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType default branch"));
+	            break;
+	        }
+	        
+	    if(!IsActive()) // check if active, user might try to print twice which is causing collision
+	    	{
+	    	if(!iFileExist && iRequestType == EStartJob)
+	    		{
+	    		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager, ChooseDpsRequestType, file not exist"));
+	    		}
+	    	else	
+	    		{
+	    		SetActive();
+	    		}
+	        
+	    	}
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CRequestManager::HandleDeviceStatusL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleDeviceStatus Start"));
+	
+	if(!iPrinter.iRepParam.iNewJobOk)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleDeviceStatus NOK "));
+		iAppUi->NotifyRequestL(EGetDeviceStatusNOK);
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleDeviceStatus OK "));
+		iAppUi->NotifyRequestL(EGetDeviceStatusOK);
+		ChooseDpsRequestTypeL(EStartJob);
+		}
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleDeviceStatus End"));
+	}
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CRequestManager::HandleAbortL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleAbort Start"));
+	if(iAbort.iResult.iMajorCode != EDpsResultOk)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleAbort EAbortJobNOK"));
+		iAppUi->NotifyRequestL(EAbortJobNOK);
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleAbort EAbortJobOK"));
+		iAppUi->NotifyRequestL(EAbortJobOK);
+		}
+	
+	}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::HandleStartJobL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleStartJob Start"));
+		
+	if(iStart.iResult.iMajorCode == EDpsResultOk)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleStartJob OK "));
+		iAppUi->NotifyRequestL(EStartJobOK);
+		}
+	else
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleStartJob NOK "));
+		iAppUi->NotifyRequestL(EStartJobNOK);
+		}	
+		
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleStartJob End"));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::HandleGetJobStatusL()
+	{ 
+	if(iJob.iResult.iMajorCode == EDpsResultOk)
+		{
+		iAppUi->NotifyRequestL(EGetJobStatusOK);
+		}
+	else
+		{
+		iAppUi->NotifyRequestL(EGetJobStatusNOK);
+		} 
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::HandleConfigureL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleConfigure Start"));
+	if(iConfig.iRepParam.iPrintAvailable == EDpsPrintServiceAvailableTrue) 
+		{
+		// save name for AppUi
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleConfigure OK "));
+		iVendorName = iConfig.iRepParam.iVendorName;
+		iProductName = iConfig.iRepParam.iProductName;
+		SaveConfigInfoL();
+		iAppUi->NotifyRequestL(EConfigurePrintServiceOK);
+	    
+		}
+	
+	else if(iConfig.iResult.iMajorCode == EDpsResultNotExecuted) 
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleConfigure OK old session"));
+		ReadConfigInfoL();
+		iAppUi->NotifyRequestL(EConfigurePrintServiceOK);
+		}
+	else if(iConfig.iRepParam.iPrintAvailable == EDpsPrintServiceAvailableFalse)
+		{
+		FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager,HandleConfigure NOK "));
+		iAppUi->NotifyRequestL(EConfigurePrintServiceNOK);
+		}
+		    
+	iConfig.iRepParam.Reset();	
+	FLOG(_L("[IMAGEPRINTUI]<<< CRequestManager HandleConfigure End"));
+	}
+	
+void CRequestManager::GetPrinterName(TDes8& aVendorName, TDes8& aProductName)
+	{
+	FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::GetPrinterName BEGIN"));
+	aVendorName = iVendorName.Ptr();
+	aProductName = iProductName.Ptr();
+	FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::GetPrinterName END"));
+	}
+	
+	
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+
+void CRequestManager::SaveConfigInfoL()
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CEventManager;SaveConfigInfoL "));
+	RFileWriteStream stream;
+  	CleanupClosePushL(stream);
+	if((stream.Replace(CCoeEnv::Static()->FsSession(),iCongFileName->Des() ,EFileWrite)) == KErrNone)
+		{
+		ExternalizeL(stream);
+		}
+	CleanupStack::PopAndDestroy(&stream);
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::ExternalizeL(RWriteStream& aStream) const
+	{
+	FLOG(_L("[IMAGEPRINTUI]<<< CEventManager;ExternalizeL "));	
+	aStream << iVendorName;
+	aStream << iProductName;
+	aStream.CommitL();
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CRequestManager::ReadConfigInfoL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::ReadConfogInfoL Sstart"));
+    RFileReadStream readStream;
+    User::LeaveIfError( readStream.Open(CCoeEnv::Static()->FsSession(), 
+    					iCongFileName->Des(), EFileRead) );
+    readStream.PushL();
+    readStream >> iVendorName; 
+	readStream >> iProductName;
+	
+    CleanupStack::PopAndDestroy(&readStream);
+    
+    FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::ReadConfogInfoL end"));
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/settingscontainer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,267 @@
+/*
+* 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:  Container class for UI
+*
+*/
+
+
+
+//INCLUDES
+#include <AknsDrawUtils.h> 
+#include <AknsBasicBackgroundControlContext.h>
+#include <AknsConstants.h>
+#include <AknUtils.h>
+#include <eikenv.h>
+#include <eiklbo.h>
+
+
+#include "imageprintuidocument.h"
+#include "imageprintuiappui.h"
+#include "imageprintuiapp.h"
+#include "capabilitymanager.h"
+#include "imageprintui.hrh"
+#include "settingscontainer.h"
+#include "imageprintuidebug.h"
+#include "settingsitems.h"
+#include "settingstables.h"
+#ifdef __SERIES60_HELP
+#include <csxhelp/usb.hlp.hrh>   // Help id
+#endif
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsContainer::CSettingsContainer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsContainer::ConstructL( const TRect& aRect, CImagePrintUiAppUi* aAppUi)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::ConstructL"));
+
+    CreateWindowL();
+
+	
+    // Create main itemlist
+    iSettingsMainListBox = new (ELeave) CAknSettingStyleListBox;
+    iSettingsMainListBox->SetContainerWindowL( *this );
+    iSettingsMainListBox->ConstructL( this, EAknListBoxMarkableList );
+    iAppUi = aAppUi;  
+ 
+    iSettingsItems = CSettingsItems::NewL( aAppUi->CapabilityManager(), aAppUi->Notes() );
+
+    // Set up/down arrows at bottom of the screen (scrollbar)
+    iSettingsMainListBox->CreateScrollBarFrameL( ETrue );
+    iSettingsMainListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
+        CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
+
+    // Set up the observer (events listener)
+    iSettingsMainListBox->SetListBoxObserver( iSettingsItems );
+    // Set text labels for list items
+    iSettingsMainListBox->Model()->SetItemTextArray( iSettingsItems );
+    iSettingsMainListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );   // Does not delete items array
+
+    SetRect(aRect);
+    ActivateL();    
+
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::ConstructL complete"));
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsContainer* CSettingsContainer::NewL( 
+    const TRect& aRect, CImagePrintUiAppUi* aAppUi )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::NewL"));
+    CSettingsContainer* self = CSettingsContainer::NewLC( aRect, aAppUi );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsContainer* CSettingsContainer::NewLC( 
+    const TRect& aRect, CImagePrintUiAppUi* aAppUi)
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::NewLC"));
+    
+    CSettingsContainer* self = new( ELeave ) CSettingsContainer;
+    CleanupStack::PushL( self );
+    self->ConstructL( aRect, aAppUi );
+    return self;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsContainer::~CSettingsContainer()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::Destructor"));
+    delete iSettingsMainListBox; 
+    delete iSettingsItems;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class CCoeControl
+// ---------------------------------------------------------------------------
+//
+void CSettingsContainer::SizeChanged()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::SizeChanged()"));
+    
+    iSettingsMainListBox->SetRect( Rect() ); 
+    iSettingsMainListBox->SetFocus( ETrue );
+    
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::SizeChanged() complete"));
+	}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+ void CSettingsContainer::HandleResourceChange(TInt aType)
+ {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::HandleResourceChange"));
+    CCoeControl::HandleResourceChange( aType ); 
+    if( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+
+        DrawNow(); 
+        }
+    else if ( aType == KAknsMessageSkinChange )
+        {
+        iSettingsMainListBox->HandleResourceChange(aType); 
+        }
+       
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::HandleResourceChange complete"));
+}
+
+
+
+// ---------------------------------------------------------------------------
+// Returns the number of controls inside this container
+// ----------------------------------------------------------------------------
+//
+TInt CSettingsContainer::CountComponentControls() const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::CountComponentControls"));
+    
+    return KImagePrintComponentCount; 
+    }
+
+
+// ---------------------------------------------------------------------------
+// Returns the control inside this container
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CSettingsContainer::ComponentControl( TInt aIndex ) const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::ComponentControl"));
+    
+    switch ( aIndex )
+        {
+        case 0:
+            {
+            return iSettingsMainListBox;
+            }
+        default:
+            {
+            return NULL;
+            }            
+        }
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// Redirects keypresses to the listbox
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CSettingsContainer::OfferKeyEventL(
+    const TKeyEvent& aKeyEvent,TEventCode aType )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::OfferKeyEventL()"));
+    
+    if( ( iSettingsMainListBox ) && ( aKeyEvent.iCode != EKeyLeftArrow )
+         && ( aKeyEvent.iCode != EKeyRightArrow ) )
+        {
+        TKeyResponse res = iSettingsMainListBox->OfferKeyEventL( aKeyEvent, aType );
+        // Store current item index for options list usage later
+        return res;
+        }
+        
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::OfferKeyEventL complete"));
+    
+    return EKeyWasNotConsumed;
+    
+    }
+
+// ---------------------------------------------------------------------------
+// This is called by view class when user has selected Change from Options menu 
+// ----------------------------------------------------------------------------
+void CSettingsContainer::HandleChange()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::HandleChange"));
+    TRAPD(err, iSettingsItems->HandleListBoxEventL( iSettingsMainListBox, 
+        MEikListBoxObserver::EEventEnterKeyPressed ));
+    if(err)
+    	{
+        FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::error at HandleChange")); 	
+    	}
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::HandleChange complete"));
+    }
+
+
+#ifdef __SERIES60_HELP
+// -----------------------------------------------------------------------------
+// From class CCoeControl
+// For getting help context
+// -----------------------------------------------------------------------------
+//
+void CSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+	{
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::GetHelpContext"));
+	aContext.iMajor = KUidUSB; 
+	aContext.iContext = KUSB_HLP_PRINT_SETTINGS;
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsContainer::GetHelpContext complete"));
+	}
+
+
+#endif //__SERIES60_HELP
+
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/settingsitems.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,316 @@
+/*
+* 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:  Show capabilities on the screen
+*
+*/
+
+
+#include <StringLoader.h>
+#include <eiklbx.h>
+#include <aknradiobuttonsettingpage.h>
+
+
+#include "imageprintui.hrh"
+#include "settingsitems.h"
+#include "settingstables.h"
+#include "imageprintuidebug.h"
+#include "capabilitymanager.h"
+#include "notes.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsItems* CSettingsItems::NewL(
+    CCapabilityManager* aManager, CNotes* aNotes )
+    {
+    CSettingsItems* self =
+        CSettingsItems::NewLC( aManager, aNotes );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsItems* CSettingsItems::NewLC(
+    CCapabilityManager* aManager, CNotes* aNotes
+    )
+    {
+    CSettingsItems* self =
+        new ( ELeave ) CSettingsItems( aManager, aNotes );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsItems::CSettingsItems(
+    CCapabilityManager* aManager, CNotes* aNotes):
+    iCapabilityManager( aManager ), iNotes( aNotes)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsItems::~CSettingsItems()
+    {
+    delete iBuffer; 
+    delete iLayout; 
+    delete iPaperSize; 
+    delete iQuality; 
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsItems::ConstructL()
+    {
+    iBuffer = HBufC::NewL(KSettingsMaxSize); 
+    iLayout = StringLoader::LoadL(R_USB_PRINT_LAYOUT);
+    iPaperSize = StringLoader::LoadL(R_USB_PRINT_PAPER_SIZE);
+    iQuality = StringLoader::LoadL(R_USB_PRINT_QUALITY);
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDesCArray.
+// Return number of items in listbox
+// ----------------------------------------------------------------------------
+//
+TInt CSettingsItems::MdcaCount() const
+    {
+    return KNumberOfSettingsViewItems;
+    }
+
+// ---------------------------------------------------------------------------
+// Creates the text string for the list box item and returns it
+// ----------------------------------------------------------------------------
+//
+TPtrC CSettingsItems::MdcaPointL(
+    TInt aIndex ) const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint"));
+    _LIT(KImagePrintUiEmptyFormatString, " \t \t\t "); 
+    TPtr ptr = iBuffer->Des();
+    ptr.Zero();  
+    HBufC* temp; 
+    ptr.Append(KTab);
+    switch ( aIndex )
+        {
+        case ESettingsListItemLayout:
+            temp = StringLoader::LoadLC( R_USB_PRINT_LAYOUT );
+            ptr.Append(temp->Des());
+            CleanupStack::PopAndDestroy(temp);
+            GetCurrentStringL( EDpsArgLayouts, KLayoutTable, KLayoutTableCount );
+            break;     
+            
+        case ESettingsListItemPaperSize:
+            temp = StringLoader::LoadLC( R_USB_PRINT_PAPER_SIZE ); 
+            ptr.Append(temp->Des());
+            CleanupStack::PopAndDestroy(temp); 
+            GetCurrentStringL( EDpsArgPaperSizes, KPaperSizeTable, KPaperSizeTableCount );
+            break;
+            
+        case ESettingsListItemPrintQuality:
+            temp = StringLoader::LoadLC( R_USB_PRINT_QUALITY ); 
+            ptr.Append(temp->Des());
+            CleanupStack::PopAndDestroy(temp); 
+            GetCurrentStringL( EDpsArgQualities, KQualityTable, KQualityTableCount );
+            break;    
+                  
+        default:
+            ptr.Append(KImagePrintUiEmptyFormatString); 
+            break;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint complete"));
+
+    return iBuffer->Des(); 
+    }
+    
+// ---------------------------------------------------------------------------
+// Creates the text string for the list box item and returns it
+// ----------------------------------------------------------------------------
+//
+TPtrC CSettingsItems::MdcaPoint(
+    TInt aIndex ) const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint"));
+    
+    TRAPD(err, *iBuffer = MdcaPointL(aIndex));
+    if(err)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPointL error"));
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPointL no  error"));
+    	}
+    return iBuffer->Des();	
+    }
+
+
+// ---------------------------------------------------------------------------
+// Creates the text string for the list box item and returns it
+// ----------------------------------------------------------------------------
+//
+
+void CSettingsItems::GetCurrentStringL( TInt aCapability, 
+    const TConversionTable* aTable, const TInt aTableSize ) const
+{
+	FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::GetCurrentStringL START"));
+    TPtr ptr = iBuffer->Des(); 
+    ptr.Append(KTab);
+    ptr.Append(KTab);  
+    
+    TInt value = iCapabilityManager->CurrentPrintSettings( aCapability ); 
+    
+    HBufC* temp; 
+    for ( TInt i = 0; i < aTableSize; i++ )
+        {
+        if ( value == aTable[i].iCapabilityID )
+            {
+            temp = StringLoader::LoadLC( aTable[i].iResourceID );
+            ptr.Append(temp->Des()); 
+            CleanupStack::PopAndDestroy(temp); 
+            break;
+            }
+        }
+  FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::GetCurrentString END"));      
+   
+}
+    
+// ---------------------------------------------------------------------------
+// From class MEikListBoxObserver.
+// Handles the list box (enter) events by launching the pop-up list
+// ----------------------------------------------------------------------------
+//
+void CSettingsItems::HandleListBoxEventL(
+    CEikListBox* aListBox,
+    TListBoxEvent aEventType )
+    {
+    if (( aEventType == EEventEnterKeyPressed ) || 
+        ( aEventType == EEventItemDoubleClicked )) //for touch support
+        {
+        switch( aListBox->CurrentItemIndex() )
+            {
+            case ESettingsListItemLayout:
+                HandleEvent(EDpsArgLayouts, KLayoutTable, 
+                    KLayoutTableCount, iLayout); 
+                break; 
+            case ESettingsListItemPaperSize:
+                HandleEvent(EDpsArgPaperSizes, KPaperSizeTable, 
+                    KPaperSizeTableCount, iPaperSize); 
+                break; 
+            case ESettingsListItemPrintQuality: 
+                HandleEvent(EDpsArgQualities, KQualityTable, 
+                    KQualityTableCount, iQuality); 
+                break;             
+            default: 
+                FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleListBoxEventL default switch"));    
+            	break;
+            }    
+
+        // Redraw item to the screen
+        //    
+        aListBox->DrawItem( aListBox->CurrentItemIndex() );   
+
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ----------------------------------------------------------------------------
+//
+void CSettingsItems::HandleEventL(TInt aCapability, 
+    const TConversionTable* aTable, const TInt aTableSize, const HBufC* aTitle  )
+    {
+    HBufC* item; 
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent START"));
+    RArray<TUint> capabilityArray = iCapabilityManager->GetCapabilities(aCapability); 
+    TInt currentItemIndex(0);
+    CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KDefaultArrayValue );
+    CleanupStack::PushL(items); 
+    TInt j(0); 
+    TInt helpValue(0);
+    TInt currentItem = iCapabilityManager->CurrentPrintSettings(aCapability); 
+
+    for(TInt i= 0; i < capabilityArray.Count(); i++ )
+        {
+        if ( capabilityArray[i] == currentItem )
+        	{
+            currentItemIndex = i; 
+        	}
+        for (j=0; j< aTableSize; j++ )
+            {
+            if ( capabilityArray[i] == aTable[j].iCapabilityID)
+                {
+                helpValue++;
+                item = StringLoader::LoadL(aTable[j].iResourceID);
+                CleanupStack::PushL(item); 
+                items->AppendL(*item);
+                CleanupStack::PopAndDestroy(item);
+                break;    
+                }
+            }
+        }    
+    FTRACE(FPrint(_L("[IMAGEPRINTUI] CSettingsItems::HandleEventL helpValue is %x"), helpValue ));
+    // Show the setting page
+    
+    CAknRadioButtonSettingPage* dlg = 
+       new ( ELeave ) CAknRadioButtonSettingPage(
+       R_USB_PRINT_MODE_SETTING_PAGE, currentItemIndex, items );
+     CleanupStack::PushL(dlg);
+     dlg->SetSettingTextL(*aTitle);
+     CleanupStack::Pop(dlg); 
+     
+     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
+        {
+        // User has made the selection. Now we need to save it to 
+        // capabilityManager
+        iCapabilityManager->SetValue( aCapability,  capabilityArray[currentItemIndex]); 
+        }
+    CleanupStack::PopAndDestroy(items); 
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent END"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsItems::HandleEvent(TInt aCapability, 
+    const TConversionTable* aTable, const TInt aTableSize, const HBufC* aTitle  )
+    {
+    
+    TRAPD(err, HandleEventL(aCapability,  aTable,  aTableSize, aTitle));
+    if(err)
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::error in HandleEvenL"));
+    	}
+    else
+    	{
+    	FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent successfull"));
+    	}
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent END"));
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintui/src/settingsview.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,205 @@
+/*
+* 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:  Settings view for UI
+*
+*/
+
+
+#include <aknViewAppUi.h>
+#include <imageprintui.rsg>
+#include <coecntrl.h>
+
+#include "imageprintui.hrh"
+#include "settingsview.h"
+#include "settingscontainer.h"
+#include "imageprintuidebug.h"
+#include "imageprintuiappui.h"
+
+#ifdef __SERIES60_HELP
+#include <hlplch.h>         // Help launcher
+#endif
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsView* CSettingsView::NewL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::NewL()"));
+    CSettingsView* self = CSettingsView::NewLC();
+    CleanupStack::Pop( self );
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::NewL() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsView* CSettingsView::NewLC()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::NewLC()"));
+    CSettingsView* self = new( ELeave ) CSettingsView;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::NewLC() complete"));
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsView::~CSettingsView()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::Destructor"));
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::Destructor complete"));
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CSettingsView::CSettingsView()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsView::ConstructL()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::ConstructL()"));
+    BaseConstructL( R_SETTINGS_VIEW );
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::ConstructL() complete"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TUid CSettingsView::Id() const
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::Id"));
+    return KImagePrintSettingsViewId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsView::HandleCommandL(
+    TInt aCommand )
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::HandleCommandL"));
+
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+             {
+             FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::Softkey exit"));
+             AppUi()->Exit();
+             break;
+             }
+                
+        case EEikCmdExit:
+            {
+            FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::cmd exit"));
+            AppUi()->Exit();
+            break;
+            }
+        
+        #ifdef __SERIES60_HELP
+        case ECmdSettingsHelp:
+            {
+            HlpLauncher::LaunchHelpApplicationL( 
+                iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
+            break;
+            }
+        #endif //__SERIES60_HELP    
+        
+        case ECmdSettingsPrint:
+            {
+            static_cast<CImagePrintUiAppUi*>(AppUi() )->StartPrinting();
+            break;  
+            }
+             
+        case ECmdSettingsChange:
+            {
+            iContainer->HandleChange(); 
+            break; 
+            }
+         default:
+            {
+            FLOG( _L("[IMAGEPRINTUI]\t CSettingsView::HandleCommandL default switch"));    
+            break;
+            }
+            
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::HandleCommandL complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,
+   TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {       
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::DoActivateL"));
+
+	iContainer = CSettingsContainer::NewL( ClientRect(), static_cast<CImagePrintUiAppUi*>(AppUi() ));
+	iContainer->SetMopParent( this );
+	AppUi()->AddToStackL( *this, iContainer );
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::DoActivateL complete"));
+    }
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CSettingsView::DoDeactivate()
+    {
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::DoDeactivate()"));
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+	    iContainer = NULL;
+        }
+    FLOG(_L("[IMAGEPRINTUI]\t CSettingsView::DoDeactivate() complete"));
+
+    }
+
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/data/1020E471.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* 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:  ECOM plugin resource
+*
+*/
+
+
+#include <registryinfov2.rh>
+#include <AiwCommon.hrh>
+#include "aiwprintingprovideruid.h"
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    resource_format_version = RESOURCE_FORMAT_VERSION_2; 
+    dll_uid = KAiwPrintingProviderDllUid;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KAiwClassMenu;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KAiwPrintingProviderImplUid;
+                    version_no = 1;
+                    display_name = "Image Print";
+                    default_data = "image/jpeg";
+                    opaque_data = KAiwCmdPrintStr;
+                    }
+                };
+            }
+        };
+    }       
+        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/data/imageprintuiprovider.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:  Resource definitions for project Image Print UI Provider
+*
+*/
+
+
+NAME    AWPP  // Image Print UI Provider
+
+// INCLUDES
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+
+#include <AiwCommon.hrh>
+#include <imageprintuiprovider.loc>
+
+/**
+ * Standard resource signature
+ */
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE MENU_PANE r_aiw_printing_provider_menu
+    {
+    items=
+        {
+        MENU_ITEM
+            {
+            command = KAiwCmdPrint;
+            txt = qtn_usb_option_printing;
+            }        
+        };
+    }
+
+RESOURCE TBUF r_usb_info_app_in_use 
+    {
+    buf = qtn_usb_info_app_in_use;    
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../loc/imageprintuiprovider.loc             MW_LAYER_LOC_EXPORT_PATH(imageprintuiprovider.loc)
+../rom/imageprintuiprovider.iby             CORE_MW_LAYER_IBY_EXPORT_PATH(imageprintuiprovider.iby)
+../rom/imageprintuiproviderresources.iby    LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(imageprintuiproviderresources.iby)
+
+PRJ_MMPFILES
+imageprintuiprovider.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/group/imageprintuiprovider.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -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 is the project file for Image Print UI Provider
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET	imageprintuiprovider.dll
+
+TARGETTYPE      PLUGIN
+CAPABILITY 	    CAP_GENERAL_DLL
+UID			0x10009D8D 0x1020E471 
+VENDORID VID_DEFAULT
+
+
+SOURCEPATH			../src
+SOURCE				dllmain.cpp
+SOURCE          	caiwprintingprovider.cpp
+SOURCE				caiwimageprintIf.cpp
+
+
+USERINCLUDE 	../inc 
+USERINCLUDE		../data
+
+SYSTEMINCLUDE	 /epoc32/include/ecom 
+
+MW_LAYER_SYSTEMINCLUDE
+
+
+START RESOURCE  ../data/1020E471.rss
+TARGET imageprintuiprovider.rsc
+END
+
+
+START RESOURCE ../data/imageprintuiprovider.rss
+HEADER
+TARGETPATH  RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+LIBRARY	euser.lib cone.lib 
+LIBRARY ECom.lib
+LIBRARY ServiceHandler.lib 
+LIBRARY estor.lib
+LIBRARY apgrfx.lib 
+LIBRARY apparc.lib 
+LIBRARY ws32.lib 
+LIBRARY efsrv.lib 
+LIBRARY bafl.lib 
+LIBRARY avkon.lib 
+LIBRARY DRMCommon.lib
+LIBRARY ImageConversion.lib
+LIBRARY eikcdlg.lib 
+LIBRARY eikctl.lib
+LIBRARY PlatformEnv.lib 
+LIBRARY commonengine.lib  
+
+
+DEBUGLIBRARY       flogger.lib
+
+
+#ifdef ENABLE_LOGGING
+#ifdef LOG_TO_FILE
+LIBRARY	flogger.lib		// Only in debug builds
+#endif // ENABLE_LOGGING
+#endif // LOG_TO_FILE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/inc/aiwprintingprovideruid.h	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  List of UIDs
+*
+*/
+
+
+#ifndef __AIFPRINTINGPROVIDERUID_H__
+#define __AIFPRINTINGPROVIDERUID_H__
+
+
+#define KAiwPrintingProviderDllUid  0x1020E471
+#define KAiwPrintingProviderImplUid 0x10274790
+
+#endif // __AIFPRINTINGPROVIDERUID_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/inc/caiwimageprintif.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* 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:  Header file for caiwprintingif
+*
+*/
+
+
+
+#ifndef __CAIWIMAGEPRINTIF_H__
+#define __CAIWIMAGEPRINTIF_H__
+
+#include <AiwServiceIfMenu.h>
+#include <badesca.h>
+#include <eikenv.h>
+
+_LIT( KResourceFile, "resource\\imageprintuiprovider.rsc" );
+
+_LIT( KParamFile, "system\\data\\T_AIW_PRINT.DAT");
+_LIT( KUnSuppFile, "system\\data\\T_AIW_UNSUPP.DAT");
+_LIT(KImagePrintUiSearchPatternBySID, "*1020e470*");
+const TInt KImagePrintUID = 0x1020E470;
+const TInt KRetryInterval = 5000000; // 500 ms
+const TInt KResource = 40;
+const TInt KDriver = 3;
+
+class DRMCommon;
+class CNoteTimer;
+
+
+class CAiwImagePrintIf : public CAiwServiceIfMenu
+{
+    public:
+
+        ~CAiwImagePrintIf();
+        
+    public:
+    
+    	TInt   iNumberOfUnSuppFiles;
+    	TBool  iUnsupportedFiles;   
+    	CNoteTimer* iNoteTimer;
+    	HBufC* iPrintFileName;
+        HBufC* iUnsuppFileName;
+
+
+    protected:
+
+        CAiwImagePrintIf();
+
+    protected: // From CAiwServiceIfMenu
+
+        TBool IsPrintingSupported( const CAiwGenericParamList& aInParamList );
+        
+        TBool IsPrintingSupportedL( const TDesC& aFileName );
+        
+        TBool IsProtected( const TDesC& aFileName );
+
+        TBool CheckMIMETypeL( const TDesC8& aMimeType, const TDesC& aFileName );
+        
+    protected: // Implementation
+        void ConstructL();
+
+    protected: // data
+    
+        CEikonEnv& iEikEnv; //Allow CAiwPrintingProvider and CAiwPreviewProvider
+                            //to use Eikon Environment without CEikonEnv::Static()
+
+    private: //data
+    
+        TInt iResourceOffset;
+
+        // Provides common DRM functions
+        DRMCommon* iDRM;
+        
+        
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/inc/caiwprintingprovider.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* 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:  Header file for caiwprintingprovider
+*
+*/
+
+
+
+#ifndef __CAIWPRINTINGPROVIDER_H__
+#define  __CAIWPRINTINGPROVIDER_H__
+
+#include <AiwServiceIfMenu.h>
+#include <AknLaunchAppService.h>
+#include <badesca.h>
+
+#include "caiwimageprintif.h"
+
+
+/**
+* AIW provider plugin that handles print scenario.
+*/
+class CAiwPrintingProvider :
+    public CAiwImagePrintIf,
+    public MAknServerAppExitObserver
+    {
+    public: //Constructors and destructors
+        static CAiwPrintingProvider* NewL();
+        ~CAiwPrintingProvider();
+        
+    public: // from MAknServerAppExitObserver
+		void HandleServerAppExit( TInt aReason );
+		void StartApplicationL();
+
+    
+    private: // From CAiwServiceIfMenu
+        void InitialiseL(MAiwNotifyCallback& aFrameworkCallback,
+                         const RCriteriaArray& aInterest);
+
+        void InitializeMenuPaneL(CAiwMenuPane& aMenuPane,
+                                 TInt aIndex,
+                                 TInt aCascadeId,
+                                 const CAiwGenericParamList& aInParamList);
+
+        void HandleServiceCmdL(const TInt& aCmdId,
+                               const CAiwGenericParamList& aInParamList,
+                               CAiwGenericParamList& aOutParamList,
+                               TUint aCmdOptions = 0,
+                               const MAiwNotifyCallback* aCallback = NULL);
+
+        void HandleMenuCmdL(TInt aMenuCmdId,
+                            const CAiwGenericParamList& aInParamList,
+                            CAiwGenericParamList& aOutParamList,
+                            TUint aCmdOptions = 0,
+                            const MAiwNotifyCallback* aCallback = NULL);
+    private:
+        void DoHandleCmdL(TInt aMenuCmdId,
+                            const CAiwGenericParamList& aInParamList,
+                            CAiwGenericParamList& aOutParamList,
+                            TUint aCmdOptions = 0,
+                            const MAiwNotifyCallback* aCallback = NULL);
+                            
+        void LaunchImagePrintApplicationL();  
+        TBool IsImagePrintUiRunning();
+        void ShowNoteL();
+        
+        
+          
+    private: // Data
+        TInt iResourceOffset;
+        const RCriteriaArray* iInterest;
+        TInt iAiwCall;
+        MAiwNotifyCallback* iNotifyCallback;
+        CAknLaunchAppService* iService;
+        
+        const CAiwGenericParamList *iConsumerInParamList;
+        CAiwGenericParamList *iConsumerOutParamList;
+        const MAiwNotifyCallback *iConsumerCallback;
+    };
+
+#endif // __CAIWPRINTINGPROVIDER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/inc/imageprintuidebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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 file
+*
+*/
+
+
+#ifndef IMAGEPRINTUIDEBUG_H
+#define IMAGEPRINTUIDEBUG_H
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"imageprintui.txt");
+_LIT(KLogDirFullName,"c:\\logs\\imageprint\\");
+_LIT(KLogDir,"imageprint");
+
+// 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);
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+inline void FPrint(const TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    TInt tmpInt = VA_ARG(list, TInt);
+    TInt tmpInt2 = VA_ARG(list, TInt);
+    TInt tmpInt3 = VA_ARG(list, TInt);
+    VA_END(list);
+    RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
+    }
+
+inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+    {
+
+	VA_LIST list;
+	VA_START(list, aFmt);
+    TBuf8<256> buf8;
+	buf8.AppendFormatList(aFmt, list);
+
+    TBuf16<256> buf16(buf8.Length());
+    buf16.Copy(buf8);
+
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    }
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // IMAGEPRINTDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/loc/imageprintuiprovider.loc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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:  The localization file for user interface in Image Print UI provider
+*
+*/
+
+
+//Release 3 Localisation
+//Localisation strings
+
+// d:Options menu item to launch Image Print UI application from the AIW 
+// d:consumer application e.g. from Media Gallery.
+// l:list_single_pane_t1_cp2
+// r: 5.0
+#define qtn_usb_option_printing "Printing"
+
+// d:Application launch problem
+//l:popup_note_window
+#define qtn_usb_info_app_in_use "Application already in use"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/rom/imageprintuiprovider.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  Image description file for project imageprintuiprovider
+*
+*/
+
+
+
+#ifndef IMAGEPRINTUIPROVIDER_IBY
+#define IMAGEPRINTUIPROVIDER_IBY
+#ifdef __USB_PICTBRIDGE_UI
+#include <data_caging_paths_for_iby.hrh>
+
+ECOM_PLUGIN(imageprintuiprovider.dll, 1020E471.rsc)
+
+#endif // __USB_PICTBRIDGE_UI
+#endif // IMAGEPRINTUI_IBY
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/rom/imageprintuiproviderresources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  Language  description file for project imageprintuiprovider
+*
+*/
+
+
+#ifndef __IMAGEPRINTUIPROVIDERRESOURCES_IBY__
+#define __IMAGEPRINTUIPROVIDERRESOURCES_IBY__
+#ifdef __USB_PICTBRIDGE_UI
+#include <data_caging_paths_for_iby.hrh>
+
+DATA=DATAZ_\RESOURCE_FILES_DIR\imageprintuiprovider.rsc		RESOURCE_FILES_DIR\imageprintuiprovider.rsc
+
+#endif // #ifdef __USB_PICTBRIDGE_UI
+#endif // __IMAGEPRINTUIPROVIDERRESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/src/caiwimageprintIf.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,197 @@
+/*
+* 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:  Check if file is OK for printing
+*
+*/
+
+
+
+//External includes
+#include <badesca.h>
+#include <bautils.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <DRMCommon.h>
+#include <imageconversion.h>
+#include <pathinfo.h> 
+
+//Internal includes
+#include "caiwimageprintif.h"
+#include "imageprintuidebug.h"
+
+
+_LIT8( KJpegFileType, "image/jpeg" );
+_LIT( KJpegFileType16, "image/jpeg" );
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CAiwImagePrintIf::~CAiwImagePrintIf()
+    {
+    iEikEnv.FsSession().Delete(*iPrintFileName);
+    iEikEnv.FsSession().Delete(*iUnsuppFileName);
+    iEikEnv.DeleteResourceFile( iResourceOffset );
+    delete iDRM;
+    delete iPrintFileName;
+    delete iUnsuppFileName;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CAiwImagePrintIf::CAiwImagePrintIf():iEikEnv( *CEikonEnv::Static() )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwImagePrintIf::ConstructL()
+    {
+    
+    TFileName file( KResource );
+    file = PathInfo::RomRootPath();
+    TBuf<KResource> length2(KResourceFile);    
+    file.SetLength(KDriver + length2.Length());
+    file.Replace(KDriver, length2.Length(), KResourceFile);
+    
+    BaflUtils::NearestLanguageFile( iEikEnv.FsSession(), file );
+    iResourceOffset = iEikEnv.AddResourceFileL( file );
+    iDRM = DRMCommon::NewL();
+    User::LeaveIfError( iDRM->Connect() );
+    iNumberOfUnSuppFiles = 0;
+    
+    
+    TFileName printNameFile( KResource ); 
+    printNameFile = PathInfo::PhoneMemoryRootPath(); 
+    TBuf<KResource> length3(KParamFile);
+    printNameFile.SetLength(KDriver + length3.Length());
+    printNameFile.Replace(KDriver, length3.Length(), KParamFile); 
+    
+    iPrintFileName = HBufC::NewL(printNameFile.Length() );
+    iPrintFileName->Des().Copy(printNameFile);
+    
+    TFileName unSuppFile( KResource ); 
+    unSuppFile = PathInfo::PhoneMemoryRootPath(); 
+    TBuf<KResource> lengthUn(KUnSuppFile);
+    unSuppFile.SetLength(KDriver + lengthUn.Length());
+    unSuppFile.Replace(KDriver, lengthUn.Length(), KUnSuppFile);
+    
+    iUnsuppFileName = HBufC::NewL(unSuppFile.Length() );
+    iUnsuppFileName->Des().Copy(unSuppFile);
+    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CAiwImagePrintIf::IsPrintingSupported( const CAiwGenericParamList& aInParamList )
+    {  
+    TInt index(0);
+    FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported "));
+    const TAiwGenericParam* param = aInParamList.FindFirst( index, EGenericParamMIMEType );
+	TBool printable( EFalse );
+	
+    if ( index == KErrNotFound )	
+        {    
+        index = 0;
+   	    const TAiwGenericParam* param = aInParamList.FindFirst(index, EGenericParamFile, EVariantTypeDesC);
+
+        //Check if there is any printable images available. At least image must be
+        //JPEG and it also must be unprotected to be printable.
+        while ( index != KErrNotFound && !printable)
+            {
+            FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported 3"));
+            TRAP_IGNORE( printable = IsPrintingSupportedL( param->Value().AsDes() ));
+   	        param = aInParamList.FindNext(index, EGenericParamFile, EVariantTypeDesC);        
+            }
+        FTRACE(FPrint(_L("[CAiwImagePrintIf] IsPrintingSupported  printable is  %d"), printable ));     
+        return printable;    
+        }
+	
+	while ( index != KErrNotFound && !printable )
+		{
+	   	if ( param->Value().TypeId() == EVariantTypeDesC &&
+			 param->Value().AsDes() == KJpegFileType16 )
+	    	{
+	    	// MIME-type parameter follows filename parameter in parameter list.
+	    	// Because of that previous item in list is used.
+	    	if (index > 0)
+	    	    {   
+	    	    FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported 5")); 	    
+    	      	printable = !IsProtected( aInParamList[index-1].Value().AsDes() );
+	    	    }
+	    	}
+
+	    if ( !printable )
+	        {        
+    	   	param = aInParamList.FindNext(index, EGenericParamMIMEType);
+	        }
+       	}    
+	FTRACE(FPrint(_L("[CAiwImagePrintIf] IsPrintingSupported 2 printable is  %d"), printable ));     
+    return printable;	 
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CAiwImagePrintIf::IsPrintingSupportedL( const TDesC& aFileName )
+    {       
+    //1. check: Mimetype should be correct (JPEG)
+    FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported TBool 1"));
+    TBool printable = CheckMIMETypeL( KJpegFileType, aFileName ); 
+       
+    if (printable)
+        {
+        //2. check: file should not be protected
+        printable = !IsProtected( aFileName ); 
+        }     
+    FTRACE(FPrint(_L("[CAiwImagePrintIf] IsPrintingSupportedL  TBool printable is  %d"), printable ));    
+    return printable;                                      
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CAiwImagePrintIf::IsProtected( const TDesC& aFileName )
+    {
+    TBool fileProtect;
+    TInt err = iDRM->IsProtectedFile( aFileName, fileProtect );
+    FTRACE(FPrint(_L("[CAiwImagePrintIf] IsProtected   retVal is  %d"), err ? ETrue : fileProtect )); 
+    return err ? ETrue : fileProtect;  
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TBool CAiwImagePrintIf::CheckMIMETypeL( const TDesC8& aMimeType,
+											   const TDesC& aFileName )
+    {
+    TBuf8<128> mimeType(0);
+    CImageDecoder::GetMimeTypeFileL(iEikEnv.FsSession(), aFileName, mimeType);
+
+    // Check that MIME-type matches (compare returns 0), otherwise return EFalse
+    FTRACE(FPrint(_L("[CAiwImagePrintIf] CheckMIMETypeL   retVal is  %d"), mimeType.CompareF( aMimeType ) ? EFalse : ETrue )); 
+    return mimeType.CompareF( aMimeType ) ? EFalse : ETrue;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/src/caiwprintingprovider.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,314 @@
+/*
+* 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:  Launch Image Print App when file is marked or open MG
+*
+*/
+
+
+
+#include "caiwprintingprovider.h"
+
+#include <AiwMenu.h>
+#include <AiwCommon.h>
+#include <AiwCommon.hrh>
+#include <coemain.h>
+#include <barsread.h>
+#include <imageprintuiprovider.rsg>
+
+#include <e32property.h>
+#include <s32strm.h>
+#include <s32file.h>
+#include <f32file.h>
+
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <apaid.h>
+#include <apgcli.h>
+#include <w32std.h>
+#include <imageconversion.h>
+
+#include <aknViewAppUi.h>
+#include <aknnotedialog.h>
+#include <aknstaticnotedialog.h>
+#include <eikprogi.h>
+#include <aknnotewrappers.h>
+#include <StringLoader.h>
+#include <pathinfo.h> 
+
+#include "caiwimageprintif.h"
+#include "imageprintuidebug.h"
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CAiwPrintingProvider* CAiwPrintingProvider::NewL()
+    {
+
+    CAiwPrintingProvider* self = new( ELeave ) CAiwPrintingProvider;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CAiwPrintingProvider::~CAiwPrintingProvider()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::InitialiseL( MAiwNotifyCallback& aFrameworkCallback,
+                                       const RCriteriaArray& /*aInterest*/ )
+    {
+    iNotifyCallback = &aFrameworkCallback;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::HandleServiceCmdL( const TInt& aCmdId,
+                               const CAiwGenericParamList& aInParamList,
+                               CAiwGenericParamList& aOutParamList,
+                               TUint aCmdOptions,
+                               const MAiwNotifyCallback* aCallback )
+
+    {
+    FLOG(_L("[CAiwPrintingProvider]<<<  HandleServiceCmdL BEGIN"));
+    DoHandleCmdL( aCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback );
+    FLOG(_L("[CAiwPrintingProvider]<<<  HandleServiceCmdL END"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::InitializeMenuPaneL
+        ( CAiwMenuPane& aMenuPane, TInt aIndex,
+         TInt /*aCascadeId*/, const CAiwGenericParamList& aInParamList )
+    {
+    FLOG(_L("[CAiwPrintingProvider]<<<  InitializeMenuPaneL BEGIN"));
+    if ( IsPrintingSupported( aInParamList ) )
+        {
+        TResourceReader reader;
+        iEikEnv.CreateResourceReaderLC
+                ( reader, R_AIW_PRINTING_PROVIDER_MENU );
+        aMenuPane.AddMenuItemsL( reader, KAiwCmdPrint, aIndex );
+        CleanupStack::PopAndDestroy(); // aResourceId 
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::HandleMenuCmdL
+        ( TInt aMenuCmdId, const CAiwGenericParamList& aInParamList,
+         CAiwGenericParamList& aOutParamList, TUint aCmdOptions,
+         const MAiwNotifyCallback* aCallback)
+    {
+    FLOG(_L("[CAiwPrintingProvider]<<<  HandleMenuCmdL BEGIN"));
+    DoHandleCmdL( aMenuCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback );
+    FLOG(_L("[CAiwPrintingProvider]<<<  HandleMenuCmdL END"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::DoHandleCmdL(TInt aMenuCmdId,
+                            const CAiwGenericParamList& aInParamList,
+                            CAiwGenericParamList& aOutParamList,
+                            TUint /*aCmdOptions*/,
+                            const MAiwNotifyCallback* aCallback)
+    {
+    if ( aMenuCmdId == KAiwCmdPrint || aMenuCmdId == KAiwCmdPrintPreview  )
+        {
+        FLOG(_L("[CAiwPrintingProvider]<<<  DoHandleCmdL"));
+        
+        CAiwGenericParamList* checkedParams = CAiwGenericParamList::NewL();
+        
+        iConsumerInParamList = &aInParamList;
+        iConsumerOutParamList = &aOutParamList;
+        iConsumerCallback = aCallback;
+        
+        TInt index( 0 );
+	    const TAiwGenericParam* param = aInParamList.FindFirst(index,
+	            EGenericParamFile,
+	            EVariantTypeDesC);
+	    while ( index != KErrNotFound )
+			{
+	        TFileName filename( param->Value().AsDes() );
+ 	        TInt err = KErrNone;
+	        TBool result = EFalse;
+	        TRAP( err, result = IsPrintingSupportedL( filename ) );
+	        if ( err == KErrNone && result )
+	        	{
+	            FLOG(_L("[CAiwPrintingProvider] DoHandleCmdL; supported file"));
+	        	checkedParams->AppendL(*param);
+	        	}
+	        else
+	        	{
+	        	FLOG(_L("[CAiwPrintingProvider] DoHandleCmdL; not supported"));
+	        	++iNumberOfUnSuppFiles;
+	        	iUnsupportedFiles = ETrue;
+	        	}	
+	        param = aInParamList.FindNext(index,
+	            EGenericParamFile,
+	            EVariantTypeDesC);
+	        }
+   
+                
+		FTRACE(FPrint(_L("[CAiwPrintingProvider] UnSuppFiles is %d"), iNumberOfUnSuppFiles )); 
+
+		RFileWriteStream stream;
+	  	CleanupClosePushL(stream);
+		if((stream.Replace(iEikEnv.FsSession(), *iUnsuppFileName ,EFileWrite)) == KErrNone)
+			{
+			stream.WriteInt16L(iNumberOfUnSuppFiles);
+			stream.CommitL();
+			}
+		CleanupStack::PopAndDestroy(&stream); 
+		
+        FLOG(_L("[IMAGEPRINTUI]<<< CAiwPrintingProvider;Save iUnsupportedFiles  is done"));
+	
+        
+        RFileWriteStream writeStream;
+        User::LeaveIfError( writeStream.Replace(iEikEnv.FsSession(),
+        										*iPrintFileName , EFileWrite) );
+        writeStream.PushL();
+        checkedParams->ExternalizeL(writeStream);
+        writeStream.CommitL();
+        CleanupStack::PopAndDestroy( &writeStream );
+        
+        iNumberOfUnSuppFiles = 0;
+        delete checkedParams;
+        checkedParams = NULL;
+        
+        LaunchImagePrintApplicationL();
+        FLOG(_L("[CAiwPrintingProvider]>>> DoHandleCmdL "));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::StartApplicationL()
+	{
+	FLOG(_L("[CAiwPrintingProvider] StartApplicationL"));
+	LaunchImagePrintApplicationL();
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+
+TBool CAiwPrintingProvider::IsImagePrintUiRunning()
+    {
+    TFindThread findt(KImagePrintUiSearchPatternBySID);
+    TFullName result;
+    TBool running(EFalse);
+    if (!findt.Next(result))
+        {
+        FTRACE(FPrint(_L("[CAiwPrintingProvider] Thread '%S'is found"), &result));
+        running = ETrue;
+        }
+     return running;
+    }
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::ShowNoteL()
+    {
+    FLOG(_L("[CAiwPrintingProvider]>>> App launch error "));
+    HBufC* str = StringLoader::LoadLC( R_USB_INFO_APP_IN_USE  );
+    CAknErrorNote* note = new ( ELeave ) CAknErrorNote;
+    note->ExecuteLD( *str );
+    CleanupStack::PopAndDestroy( str );  // str	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::LaunchImagePrintApplicationL()
+    {
+    FLOG(_L("[CAiwPrintingProvider]<<< LaunchImagePrintApplicationL"));
+    TUid appuid;
+    appuid.iUid = KImagePrintUID;
+    if (!IsImagePrintUiRunning())
+        { 
+        TRAPD( err, iService = CAknLaunchAppService::NewL(
+        appuid,
+        this,
+        NULL ));
+	   
+	    if ( err != KErrNone )
+		   { 
+		   FTRACE(FPrint(_L("[CAiwPrintingProvider] error when launch is  %d"), err ));
+	       FLOG(_L("[CAiwPrintingProvider] LaunchImagePrintApplicationL  error"));
+		   }   
+        }
+    else
+        {
+     	ShowNoteL(); 
+		}
+    
+    FLOG(_L("[CAiwPrintingProvider]>>> LaunchImagePrintApplicationL"));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiwPrintingProvider::HandleServerAppExit( TInt aReason )
+    {
+    delete iService;
+    iService = NULL;
+    FLOG(_L("[CAiwPrintingProvider]<<<  HandleServerAppExit"));
+
+    // In the case that we want to exit also the parent application,
+    // ImagePrint is exited with User::Exit() which is seen here as
+    // KErrServerTerminated (-15).
+    if( iConsumerInParamList && iConsumerOutParamList && iConsumerCallback && iConsumerCallback )
+        {
+        // Const cast is used to fix weirdness in AIW header files. MWaiNotifyCallback
+        // does not define any const function but CAiwServiceIfMenu interface provides
+        // const callback object.
+        TRAP_IGNORE( const_cast<MAiwNotifyCallback*>(iConsumerCallback)->HandleNotifyL(
+            KAiwCmdPrintPreview, KAiwEventCompleted,
+            *iConsumerOutParamList, *iConsumerInParamList ));
+        iConsumerInParamList = NULL;
+        iConsumerOutParamList = NULL;
+        iConsumerCallback = NULL;
+        }
+    if ( aReason == KErrServerTerminated )
+        {
+        FLOG(_L("[CAiwPrintingProvider]  HandleServerAppExit KErrServerTerminated"));
+        }
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/src/dllmain.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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:  Ecom plugin info for provider
+*
+*/
+
+
+
+
+/// INCLUDES
+#include <e32std.h>
+#include <implementationproxy.h>
+#include "aiwprintingprovideruid.h"
+#include "caiwprintingprovider.h"
+
+
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] =
+    {
+ 
+    IMPLEMENTATION_PROXY_ENTRY(KAiwPrintingProviderImplUid,
+                               CAiwPrintingProvider::NewL),                        
+    };
+    
+// The one and only exported function that is the ECom entry point
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy
+        (TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+#ifndef EKA2
+/**
+ * Standard Symbian OS DLL entry point.
+ */
+TBool E32Dll(TDllReason)
+    {
+    return ETrue;
+    }
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/data/1020E472.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2005, 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:  ECOM registry file for USB UI Plug-in
+*
+*/
+
+
+#include "registryinfo.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+{
+  dll_uid = 0x1020E472;
+  interfaces =
+  {
+  INTERFACE_INFO
+    {
+    interface_uid = 0x10207236;
+    implementations =
+        {
+        IMPLEMENTATION_INFO
+          {
+          // This implementation is used by General Settings
+          // With this implementation the Right Softkey in the main
+          // view will be "Back".
+          // This way we will not cause the whole General Settings
+          // application to exit.
+          implementation_uid = 0x1020E473;
+          version_no = 1;
+          display_name = "GS USBClassChangeUI Plugin";
+          // Parent UID (USBCCUI is under "Connection setting")
+          default_data = "0x10207250";
+          opaque_data = "40";
+          },        
+        
+        IMPLEMENTATION_INFO
+          {
+            // This implementation is used by USBClassChangeUIAppUI
+            // With this implementation the Right Softkey in the main
+            // view will be "Exit")
+            implementation_uid = 0x1027478F;
+            version_no = 1;
+            display_name = "USBClassChangeUI Plugin"; 
+            default_data = "0";
+            opaque_data = "0";
+          }
+        };
+    }
+    
+    
+  };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/data/USBClassChangeUIPlugin.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,215 @@
+/*
+* 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:  Resources for USBClassChangeUIPlugin. 
+*
+*/
+
+
+#include <data_caging_paths_strings.hrh>
+
+//  RESOURCE IDENTIFIER
+NAME    USBP // 4 letter ID
+
+//  INCLUDES
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <appinfo.rh>
+
+#include "USBClassChangeUIPlugin.hrh"
+#include <usbclasschangeui.loc>
+
+//  RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = "USBCLASSCHANGEUI"; }
+
+
+//-----------------------------------------------------------------------------
+//   
+// r_usbclasschangeui_menubar
+// Menubar for main view
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_usbclasschangeui_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane = r_usbui_menu; txt=""; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//   
+// r_usbui_menu
+// Application level menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_usbui_menu
+    {
+    items =
+        {
+        MENU_ITEM { command = EUSBUICmdSelect; txt = qtn_cffh_options_select ; flags = EEikMenuItemAction;},
+        MENU_ITEM { command = EUSBUICmdHelp; txt = qtn_options_help; },
+        MENU_ITEM { command = EAknCmdExit; txt = qtn_options_exit; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//   
+// r_usbclasschangeui_app_menu
+// application menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_usbclasschangeui_app_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=EAknCmdExit; txt=text_softkey_exit; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+// r_usb_mode_setting_editor
+// Editor for entering all settings
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_usb_mode_setting_editor
+    {
+    flags = EEikListBoxMultipleSelection;
+    }
+
+//----------------------------------------------------
+//
+//  Hotkeys for USB UI
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_usbui_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+
+//----------------------------------------------------
+//
+//  Softkeys for USB UI as application. 
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_usbui_softkeys_options_exit__select
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyExit; txt = text_softkey_exit;},
+        CBA_BUTTON {id=EUSBUICmdMskSelect; txt = text_softkey_select ;}
+        };
+    }
+
+
+//----------------------------------------------------
+//
+//  The main view of the USB UI application. Used when
+//  this .dll is loaded from the USBClassChangeUIAppUI
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_usbui_main_view
+    {
+    hotkeys = r_usbui_hotkeys;
+    menubar = r_usbclasschangeui_menubar;
+    cba     = r_usbui_softkeys_options_exit__select;
+    }
+
+//----------------------------------------------------
+//
+//  Title for the main view
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_usb_title { buf = qtn_usb_title; }
+
+//----------------------------------------------------
+//  r_gs_usbui_view_caption 
+// 
+// USBClassChangeUI view caption for GS plugin
+//----------------------------------------------------
+//
+RESOURCE TBUF r_gs_usbui_view_caption
+    {
+    buf = qtn_set_folder_usb;
+    }
+    
+//----------------------------------------------------
+//
+//  Softkeys for USB UI as GS plugin. 
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_usbui_softkeys_options_back__select
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back;},
+        CBA_BUTTON {id=EUSBUICmdMskSelect; txt = text_softkey_select ;}
+        };
+    }
+
+//----------------------------------------------------
+//
+//  The main view of the USB UI application as GS plugin
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_usbui_main_view_gs_plugin
+    {
+    hotkeys = r_usbui_hotkeys;
+    menubar = r_usbclasschangeui_menubar;
+    cba     = r_usbui_softkeys_options_back__select;
+    }
+
+//------------------------------------------------------------------------------
+//
+// Secondary status information
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_cp_detail_usb_not_connected { buf = qtn_cp_detail_usb_not_connected; }
+RESOURCE TBUF r_cp_detail_usb_otg_conn { buf = qtn_cp_detail_usb_otg_conn; }
+RESOURCE TBUF r_cp_detail_usb_conn_mass_storage { buf = qtn_cp_detail_usb_conn_mass_storage; }
+RESOURCE TBUF r_cp_detail_usb_conn_pc_suite { buf = qtn_cp_detail_usb_conn_ovi_suite; }
+RESOURCE TBUF r_cp_detail_usb_conn_picture_transfer { buf = qtn_cp_detail_usb_conn_picture_transfer; }
+RESOURCE TBUF r_cp_detail_usb_conn_media_transfer { buf = qtn_cp_detail_usb_conn_media_transfer; }
+RESOURCE TBUF r_cp_detail_usb_conn_modem_inst { buf = qtn_cp_detail_usb_conn_modem_inst; }
+RESOURCE TBUF r_cp_detail_usb_conn_rndis { buf = qtn_cp_detail_usb_conn_rndis; }
+
+RESOURCE TBUF r_usb_mode_default { buf = qtn_usb_settings_default ;} 
+RESOURCE TBUF r_usb_mode_active { buf = qtn_usb_settings_active;} 
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/group/USBClassChangeUIPlugin.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* 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:  Project specification file for the USBClassChangeUIPlugin.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          USBClassChangeUIPlugin.dll 
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D  0x1020E472
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH ../src
+SOURCE  USBClassChangeUIPluginImplementationTable.cpp
+SOURCE  USBClassChangeUIPluginView.cpp
+SOURCE  USBClassChangeUIPluginContainer.cpp
+SOURCE  USBClassChangeUIPluginModel.cpp
+SOURCE  USBClassChangeUIPluginCRWatcher.cpp
+SOURCE  USBDeviceStateWatcher.cpp 
+SOURCE  usbotghoststatewatcher.cpp
+
+// ECom resource file
+START RESOURCE ../data/1020E472.rss
+TARGET  USBClassChangeUIPlugin.rsc 
+END	
+
+START RESOURCE  ../data/USBClassChangeUIPlugin.rss
+TARGETPATH      RESOURCE_FILES_DIR
+HEADER
+LANGUAGE_IDS
+END
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+SYSTEMINCLUDE		../../../inc ../../../../inc     //for internal and private API headers
+SYSTEMINCLUDE   /epoc32/include/ecom
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib apparc.lib cone.lib eikcore.lib 
+LIBRARY eikcoctl.lib avkon.lib
+LIBRARY bafl.lib                            // Basic Application Framework 
+LIBRARY aknnotify.lib                       // Avkon global notes
+LIBRARY AknSkins.lib                        // Skinned icons
+LIBRARY aknicon.lib
+LIBRARY centralrepository.lib               // Central Repository
+LIBRARY commonengine.lib                    // Series 60 common components library
+LIBRARY eiksrv.lib      
+LIBRARY GSEcomPlugin.lib        
+LIBRARY ecom.lib
+LIBRARY usbman.lib
+LIBRARY usbwatcher.lib
+LIBRARY FeatMgr.lib                         // for fetching if help is supported
+LIBRARY hlplch.lib                          // Help library
+
+DEBUGLIBRARY flogger.lib                    // File logging services
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005, 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 building information for 
+*                 USBClassChangeUIPlugin.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// NOTE: this bld.inf is included from ../../../usbui/group/bld.inf
+// It defines _USBUI_BLF_INF_INCLUDED_ to prevent duplicate export error.
+#ifndef _USBUI_BLF_INF_INCLUDED_
+../../loc/USBClassChangeUI.loc  MW_LAYER_LOC_EXPORT_PATH(usbclasschangeui.loc)
+#endif // _USBUI_BLF_INF_INCLUDED_
+
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE usbui.mif
+OPTION HEADERFILE usbui.mbg
+OPTION SOURCES -c8,8 qgn_prop_set_apps_usb -c8,8 qgn_prop_set_apps_usb_off -c8,8 qgn_prop_usb_memc_large -c8,8 qgn_prop_usb_mtp -c8,8 qgn_prop_usb_pcsuite -c8,8 qgn_prop_usb_modem -c8,8 qgn_prop_usb_print
+END
+
+
+PRJ_MMPFILES
+
+../group/USBClassChangeUIPlugin.mmp
+
+// gnumakefile usbuiplugin_icons_dc.mk
+
+PRJ_TESTMMPFILES
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/group/usbuiplugin_icons_dc.mk	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\usbui.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\usbui.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_set_apps_usb.svg \
+		/c8,8 qgn_prop_set_apps_usb_off.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPlugin.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2005, 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:  Common declarations for USBClassChange classes
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGIN_H
+#define USBCLASSCHANGEUIPLUGIN_H
+
+#include <e32svr.h> 	// For RDebug and Panic
+
+// Application name
+//
+_LIT( KUSBUIAppName, "USBClassChangeUIPlugin" );
+
+// UID of the application
+//
+const TUid KUidUSBClassChangeUI = { 0x102068E2 };
+
+// Panic values
+//
+enum TUSBUIPanics 
+    {
+    EUSBUIMainListNotEmpty = 10000,    
+    EUSBUIPanicIllegalValue,
+    };
+
+// MACROS
+//
+#define PANIC( aPanic ) User::Panic( KUSBUIAppName, aPanic )
+
+// UID of the main view
+//
+const TUid KUSBUIMainViewId = { 1 };
+
+// UID of the General Settings Plugin
+const TUid KGsUSBUiPluginUid = { 0x1020E473 };
+
+#endif //USBCLASSCHANGEUIPLUGIN
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPlugin.hrh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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:  This file contains declarations for the resources
+                    of USBClassChangeUI.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGIN_HRH
+#define USBCLASSCHANGEUIPLUGIN_HRH
+
+// DATA TYPES
+
+enum TUSBUIMenuCommands
+    {
+    EUSBUICmdSelect = 1,
+    EUSBUICmdHelp,
+    EUSBUICmdMskSelect
+    };
+
+
+#endif      // USBCLASSCHANGEUIPLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginCRWatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2005, 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:  Central repository key watcher class.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGINCRWATCHER_H
+#define USBCLASSCHANGEUIPLUGINCRWATCHER_H
+
+// INCLUDES
+#include <centralrepository.h>
+
+// FORWARD DECLARATIONS
+class CRepository; 
+
+/**
+* A callback interface for informing change of a setting in Central Repository
+*/
+class MUSBUICRSettingObserver
+    {
+    public: // New functions
+        
+        /**
+        * Informs the observer that a setting has been changed. 
+        * @param aKey The changed key. 
+        * @return None.
+        */
+        virtual void SettingChangedL( TUint32 aKey ) = 0;
+    };
+
+
+/**
+* CUSBClassChangeUIPluginCRWatcher detects a change of the value of the CR key.
+* CUSBClassChangeUIPluginCRWatcher provides CActive object that is used to 
+* detect when the value of the selected key in Central Repository is changed 
+* by the USBWatcher. One observer can be notified by one or more
+* USBClassChangeUIPluginCRWatcher objects, each watching different keys. 
+*/
+class CUSBClassChangeUIPluginCRWatcher : public CActive
+    {
+        
+    public:
+
+        /**
+        * Factory method NewL
+        * @param aOwner     The observer to be notified on the change. 
+        * @param aKey       The Central Repository key to be watched. 
+        * @param aOneShot   If false, the listening is restarted after change.
+        * @return           The new watcher object. 
+        */
+        static CUSBClassChangeUIPluginCRWatcher* NewL( 
+            MUSBUICRSettingObserver& aOwner, TUint32 aKey, 
+            TBool aOneShot = EFalse);
+
+        /**
+        * Starts listening for notifications. If already listening, nothing 
+        * happens.
+        */
+        void StartListeningL();
+
+        /**
+        * Stops listening for notifications. If already stopped, nothing 
+        * happens.
+        * @param none
+        * @return none 
+        */
+        void StopListening();
+
+        /**
+        * C++ default constructor
+        * @param aOwner     The observer to be notified on the change. 
+        * @param aKey       The Central Repository key to be watched. 
+        * @param aOneShot   If false, the listening is restarted after change.
+        */
+        CUSBClassChangeUIPluginCRWatcher( 
+            MUSBUICRSettingObserver& aOwner, TUint32 aKey, 
+            TBool aOneShot = EFalse);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUSBClassChangeUIPluginCRWatcher();
+
+    private:
+
+        /**
+        * Constructor.
+        * @param none
+        */
+
+        void ConstructL();
+
+        /**
+        *	Implements CActive
+        *   If this is not a one-shot CR watcher, the listening is restarted.
+        *	@param none
+        *	@return none
+        */
+        void RunL();
+    
+        /**
+        *	Implements CActive
+        *	@param aError the error returned
+        *	@return error
+        */
+        TInt RunError(TInt aError);
+
+        /**
+        *	Implements CActive
+        *	@param none
+        *	@return none
+        */
+        void DoCancel();
+
+     
+    private:
+        /** USB Watcher repository access */
+        CRepository* iPersonalityRepository;
+        /** The observer to be notified */
+        MUSBUICRSettingObserver& iOwner;
+        /** The repository key to be watcher */
+        TUint32 iKey;
+        /** If iOneShot is false, listening is restarted on notification */
+        TBool iOneShot;
+    };
+
+
+#endif      // USBCLASSCHANGEUIPLUGINCRWATCHER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginContainer.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,211 @@
+/*
+* 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:  Declares container control for application.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGINCONTAINER_H
+#define USBCLASSCHANGEUIPLUGINCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eikfrlb.h>
+#include <eikclb.h>
+#include <aknlists.h> 
+#include <AknInfoPopupNoteController.h>
+#include <AknIconArray.h>
+#include "USBClassChangeUIPlugin.hrh"
+
+// CONSTANTS
+/** number of controls inside this component */
+const TInt KUSBClassChangeUIComponentCount = 1;
+const TInt KUSBClassChangeUIIconGranularity = 3;
+const TInt KMaxVisibleTime = 3500;
+const TInt KMsToWaitBeforePopup = 1000;
+
+// FORWARD DECLARATIONS
+class CUSBClassChangeUIPluginView;
+class CUSBClassChangeUIPluginModel;
+
+// CLASS DECLARATION
+
+/**
+*  This class handles main view dependent requests from user and 
+*  contains listbox for main view items.
+*  @lib
+*/
+class CUSBClassChangeUIPluginContainer : public CCoeControl,                                   
+                                         public MEikListBoxObserver,
+                                         public MDesCArray
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Factory method NewL
+        * @return a pointer to itself
+        */
+        static CUSBClassChangeUIPluginContainer* NewL(
+            CUSBClassChangeUIPluginView* aView,
+            CUSBClassChangeUIPluginModel* aModel );
+        
+	    /**
+        * Destructor.
+        */
+        virtual ~CUSBClassChangeUIPluginContainer();
+
+	private:
+
+        /**
+        * C++ constructor.
+        */
+        CUSBClassChangeUIPluginContainer(
+            CUSBClassChangeUIPluginView* aView,
+            CUSBClassChangeUIPluginModel* aModel);
+
+	    /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+	public: // new functions
+	 
+        /**
+        * Handles setting changes.
+        */
+        void SettingChanged();
+ 
+        /**
+        * Handles screen resolution changes
+        * @param aType informs the type of resource change
+        */
+        void HandleResourceChange( TInt aType ); 
+        
+        /**
+        * Returns the current item index (highlight position) 
+        * for main setting list.
+        * @return Current item index.
+        */
+        TInt CurrentItemIndex();
+
+        // MDesCArray implementation
+
+        /**
+        * Returns number of items in array / main list.
+        * @return Number of items.
+        */
+        TInt MdcaCount() const;
+
+        /**
+        * Returns the current format string for the given item.
+        * @param aIndex Index of the item.
+        * @return Pointer to the format string.
+        */
+        TPtrC MdcaPoint( TInt aIndex ) const;
+        
+        /**
+        * selects the string to be passed to ShowPopUpL
+        * @param aValue is the index of the item in the list.
+        */
+        void ShowPopUpsL( TInt aIndex);
+             
+    private: // Functions from base classes
+        
+        /**
+        * From CoeControl Gets the number of controls contained 
+        * in a compound control.        
+        * @return The number of component controls contained by this control.
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CoeControl Gets the specified component of a compound control.
+        * @param aIndex The index of the control to get.
+        * @return Reference to the component control.
+        */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+        /**
+        * From CoeControl Handles key events.
+        * @param aKeyEvent The key event that occurred.
+        * @param aType The event type.
+        * @return Response to the key event.
+        */
+        TKeyResponse OfferKeyEventL(
+            const TKeyEvent& aKeyEvent, TEventCode aType );        
+
+        /**
+        * From CoeControl Gets the control's help context.
+        * @param aContext The control's help context
+        */
+        void GetHelpContext(TCoeHelpContext& aContext) const;
+    
+        /**
+        * From CoeControl Responds to size changes. 
+        * Sets the size and position of the contents of this control.
+        */
+        void SizeChanged();
+        
+        /**
+        * From CoeControl Responds to a change in focus.
+        * @param aDrawnow Contains the value that was passed to it by 
+        *                 SetFocus(). 
+        */
+        void FocusChanged( TDrawNow aDrawnow );
+     
+  
+    protected:
+        /**
+        * From MEikListBoxObserver Handles list box events.
+        * @param aListBox The originating list box.
+        * @param aEventType The event type.
+        */
+        void HandleListBoxEventL(
+            CEikListBox* aListBox, TListBoxEvent aEventType );
+        
+    private: // Data
+
+        // The setting items listbox
+        // owned by this class
+        CAknDoubleLargeStyleListBox* iUSBMainListBox;		     
+        // Reference to appui object
+        CUSBClassChangeUIPluginView* iViewRef;
+        // To get personality IDs arrays
+        // not owned by this class
+        CUSBClassChangeUIPluginModel* iModelRef;
+        // All format string combinations 
+        // owned by this class              
+        CDesCArrayFlat* iUSBAllItemsArray; 
+        // All format string combinations 
+        // owned by this class 
+        CDesCArrayFlat* iUSBAllItemsArrayDefault; 
+        // All format string combinations 
+        // owned by this class 
+        CDesCArrayFlat* iUSBAllItemsArrayActive; 
+        // All format string combinations 
+        // owned by this class 
+        CDesCArrayFlat* iPopUpItems; 
+       
+        // Current highlighted main list item 
+        TInt iCurrentItemIndex;
+
+        // The controller for the PopUps (tooltips) in UI Setting view 
+        // owned by this class 
+        CAknInfoPopupNoteController* iPopupController;
+ 
+};
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginDebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2005, 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 defines logging macros
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGINDEBUG_H
+#define USBCLASSCHANGEUIPLUGINDEBUG_H
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"usbclasschangeuipluginlog.txt");
+_LIT(KLogDir,"USBUI");
+
+// 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);
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+inline void FPrint(const TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    TInt tmpInt = VA_ARG(list, TInt);
+    TInt tmpInt2 = VA_ARG(list, TInt);
+    TInt tmpInt3 = VA_ARG(list, TInt);
+    VA_END(list);
+    RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
+    }
+
+inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+    {
+
+	VA_LIST list;
+	VA_START(list, aFmt);
+    TBuf8<256> buf8;
+	buf8.AppendFormatList(aFmt, list);
+
+    TBuf16<256> buf16(buf8.Length());
+    buf16.Copy(buf8);
+
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    }
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // USBCLASSCHANGEUIPLUGINDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginInterface.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* 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: 
+*        Header file for CUSBClassChangeUIPluginInterface class.
+*
+*/
+
+#ifndef USBCLASSCHANGEUIPLUGININTERFACE_H
+#define USBCLASSCHANGEUIPLUGININTERFACE_H
+
+// System includes
+#include <gsplugininterface.h>
+
+
+/**
+ * ECOM plug-in creation for the standalone application. 
+ * The view class must inherit this class to be able to signal the
+ * destruction of the interface implementation. If this implementation
+ * was created in the GS application, the destruction must not be 
+ * signalled, since the view framework does it. If this implementation
+ * was created in the standalone USB UI application, the destruction
+ * must be signalled, since otherwise there will be memory leaks. 
+ * 
+ * The inherited CGSPluginInterface destructor does not signal the
+ * desctruction. Also, it cannot be signalled in the destructor of 
+ * this class, since it would be called while deleting the view. 
+ * This class stores the instance ID iDtor_ID_Key, because it can't
+ * access the private member variable of class CGSPluginInterface.
+ * 
+ * Note that the implementation is inline, because the concrete 
+ * plug-in has not been loaded. The implementation of this class can't
+ * reside in the plug-in to be loaded by the ECOM framework. 
+ * 
+ */ 
+class CUSBClassChangeUIPluginInterface	: public CGSPluginInterface
+    {    
+    public: // Constructors & destructors
+
+        /**
+         * Creates new USBClassChangeUI view plugin having the given UID.
+         * Uses Leave code KErrNotFound, if implementation is not found.
+         *
+         * @param aImplementationUid Implementation UID of the plugin to be 
+         *        created.
+         * @param aInitParams The AppUi of the USBClassChangeUI application.
+         * @return The new view. 
+         */                                                 
+        static CUSBClassChangeUIPluginInterface* NewL(
+            const TUid aImplementationUid, 
+            TAny* aInitParams);
+
+        /**
+         * Destructor
+         */
+        ~CUSBClassChangeUIPluginInterface();
+
+        /**
+         * Signal destruction of the interface implementation to ECOM.
+         * This should not be called from the GS plugin, since the 
+         * framework wants to do it itself. From the application, the
+         * view must call this before destruction. 
+         */
+        void SignalDestruction();
+            
+    protected: 
+
+        /**
+         * Default constructor
+         */    
+        CUSBClassChangeUIPluginInterface();
+        
+    private: // Data
+
+        /**
+         * ECOM plugin instance UID. 
+         * The inherited member variable with the same name is hidden, but
+         * there is no way to access it. 
+         */
+        TUid iDtor_ID_Key;
+    };
+
+
+#include "USBClassChangeUIPluginInterface.inl"
+
+#endif //USBCLASSCHANGEUIPLUGININTERFACE_H
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginInterface.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* 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:  Implementation for CUSBClassChangeUIPluginInterface class.
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Default constructor.
+// -----------------------------------------------------------------------------
+//
+inline CUSBClassChangeUIPluginInterface::CUSBClassChangeUIPluginInterface()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor. 
+// -----------------------------------------------------------------------------
+//
+inline CUSBClassChangeUIPluginInterface::~CUSBClassChangeUIPluginInterface()
+    {
+    //REComSession::DestroyedImplementation can't be called, because the 
+    //GS framework wants to do it. 
+    }
+
+
+// -----------------------------------------------------------------------------
+// Create new plugin having the given UID.
+// -----------------------------------------------------------------------------
+//
+inline CUSBClassChangeUIPluginInterface* CUSBClassChangeUIPluginInterface::NewL( 
+    TUid aImplementationUid, 
+    TAny* aInitParams )
+    {
+    TAny* ptr;
+    TInt32 keyOffset = _FOFF( CUSBClassChangeUIPluginInterface, iDtor_ID_Key );
+
+    ptr = REComSession::CreateImplementationL(
+        aImplementationUid,
+        keyOffset,
+        aInitParams);    
+     
+    return static_cast< CUSBClassChangeUIPluginInterface* >( ptr );
+    }
+    
+
+// -----------------------------------------------------------------------------
+// Signal destruction of interface implementation to ECOM.
+// -----------------------------------------------------------------------------
+//
+inline void CUSBClassChangeUIPluginInterface::SignalDestruction()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginModel.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,269 @@
+/*
+* 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:  Declares model class for application.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGINMODEL_H
+#define USBCLASSCHANGEUIPLUGINMODEL_H
+
+
+// INCLUDES
+#include <badesca.h>
+#include <usbman.h>
+#include <usbwatcher.h>
+#include <eikfrlb.h>
+#include <eikclb.h>
+#include <aknlists.h> 
+#include "USBClassChangeUIPlugin.hrh"
+#include "USBClassChangeUIPluginCRWatcher.h"
+#include "USBDeviceStateWatcher.h"
+#include "usbotghoststatewatcher.h"
+
+// CONSTANTS
+/** granularity for supported modes array */
+const TInt KUSBClassChangeUISupportedModesGranularity = 3;
+
+// FORWARD DECLARATIONS
+class CUSBDeviceStateWatcher;
+
+// CLASS DECLARATION
+
+/**
+ * A callback interface for informing change of settings and device state.
+ */
+class MUSBUIObserver : public MUSBDeviceStateObserver, 
+    public MUSBOtgHostStateObserver
+    {
+    public: // New functions
+        
+        /**
+        * Informs the observer that a setting has been changed. 
+        * The list should be refreshed.
+        */
+        virtual void SettingChanged() = 0;
+    };
+
+/**
+* This class has access to all data needed by this application.
+* All manipulation of data is done through this class.
+*/
+class CUSBClassChangeUIPluginModel : public CActive, 
+    public MUSBUICRSettingObserver, MUSBDeviceStateObserver, MUSBOtgHostStateObserver
+    {
+    public: // Constructors and destructor
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CUSBClassChangeUIPluginModel(); 
+
+    public: // New functions
+        
+        
+        /**
+        * Factory method NewL
+        * @return a pointer to itself
+        */
+        static CUSBClassChangeUIPluginModel* NewL();
+        
+        
+        /**
+        * Sets the USB mode.
+        * @param aMode the id of the selected personality 
+        */
+        void SetUSBModeL( TInt aMode );
+
+        /**
+        * Gets the USB mode.
+        * @return the id of the personality
+        */
+        TInt USBMode();
+        
+        /**
+         * Gets the number of usb personalities.
+         * @return the number of existing personalities 
+         */
+        TInt PersonalityCount() ;
+        /**
+         * Gets the current device state.
+         * @param   aState  receives the current state of the USB device
+         * @return  KErrNone if successful, otherwise the error that occurred
+         */
+        TInt GetDeviceState(TUsbDeviceState& aState);
+
+        /**
+         * Gets description for the specified USB mode (personality ID)
+         * @param   aMode a personality id
+         * @param   aDescription a localized text string
+         * @return  KErrNone if successful, otherwise the error that occurred.
+         */
+        TInt GetDescription(TInt aMode, HBufC*& aDescription);
+
+        /**
+        * Updates temporary member variable data.        
+        * @param aObserver Reference to MUSBUIObserver instance.        
+        */
+        void SetSettingsObserver(MUSBUIObserver* aObserver);
+        
+        /*
+        * Reads the supported USB modes from the resource file and CenRep.
+        * Adds modes to the CDesCArrayFlat lists to be used either
+        * for list box or for setting page
+        * @param aListBox The list where the USB modes are appended for list box
+        * @param aListBoxDefault The list where the USB modes are appended with their secondary line "default" 
+        * @param aListBoxActive The list where the USB modes are appended with their secondary line "active" 
+        * @param aPopUpItems The list where the descriptive strings will be stored 
+        * @param aIconArray The list where icons for USB modes are stored
+        */
+        void SupportedUSBModeArraysL(  CDesCArrayFlat& aListBox, CDesCArrayFlat& aListBoxDefault,
+                CDesCArrayFlat& aListBoxActive, CDesCArrayFlat& aPopUpItems, CArrayPtrFlat<CGulIcon>& aIconArray );       
+        
+        /**
+        * From MUSBUICRSettingObserver.
+        * Changes the USB mode in the USB application. 
+        * Called by CUSBClassChangeUICenRepWatcher, when the key 
+        * KUsbWatcherPersonality is changed by the USBWatcher.
+        * @param aKey identifies the setting that has changed
+        */
+        void SettingChangedL( TUint32 aKey );
+
+        /**
+         * From MUSBOtgHostStateObserver
+         * @see MUSBOtgHostStateObserver::OtgHostIdPinStateChanged
+         */
+        void OtgHostIdPinStateChanged(TBool aIsIdPinOn);
+        
+        /**
+         * From MUSBOtgHostStateObserver
+         * @see MUSBOtgHostStateObserver::OtgHostIdPinStateChanged
+         */
+        void HostEventNotify(TDeviceEventInformation aEventInfo);
+        
+        /**
+         * From MUSBDeviceStateObserver.
+         * Informs the observer that USB device state has changed.
+         * @param aPreviousState previous device state.
+         * @param aCurrentState current device state.
+         */
+        void DeviceStateChanged(TUsbDeviceState aPreviousState,
+                                TUsbDeviceState aCurrentState);
+
+        
+        /**
+        * Gets the IDs of supported USB personalities.
+        * @return RArray of personality IDs
+        */
+        RArray<TInt>& GetUsbIds();
+             
+        /**
+         * Returns if it acts as a host and the driver to the attached pheripheral 
+         * is loaded successfully(or partially). 
+         * NOTE: Only single perihperal supported now.
+         * @param aHasPeripheralEnabled Is A-device is ready to be used or not
+         * @return KErrNone if successful, otherwise the error that occurred
+         */
+        TInt HasPeripheralEnabled(TBool& aHasPeripheralEnabled);
+        
+  
+    protected:
+        /**
+        * Default ConstructL can leave.
+        */
+        void ConstructL();
+
+	    /**
+        * C++ default constructor.
+        */
+        CUSBClassChangeUIPluginModel();        
+        
+        /**
+        * Derived from CActive
+        */
+        void RunL();
+
+        /**
+        * Derived from CActive
+        */
+        void DoCancel();
+        
+    private:
+        /**
+         * selects the icon related to each mode to be added into the iconlist
+         * @param aMode the mode id
+         * @param aIconArray The list where icons for USB modes are stored
+         */
+        void AddIconL (TInt aMode, CArrayPtrFlat<CGulIcon>& aIconArray);
+               
+        /**
+         * creats and append the icons to the list
+         * @param aID Item ID of the masked bitmap to be created.
+         * @param aFilename Filename to be used to construct the item.
+         * @param aBitmapId The ID if bitmap 
+         * @param aMaskId The ID of bitmap's mask
+         * @param aIconArray The list where icons for USB modes are stored
+         */
+        void CreateAndAppendIconL( const TAknsItemID& aID,
+                                   const TDesC& aFileName,
+                                   const TInt aBitmapId,
+                                   const TInt aMaskId,
+                                   CArrayPtrFlat<CGulIcon>& aIconArray);
+                 
+    private: // Data
+         // Reference to settings observer
+         MUSBUIObserver* iObserver;
+
+         // References to central repository watcher
+         // owned by this class
+         CUSBClassChangeUIPluginCRWatcher* iCRPersonalityWatcher;
+
+         // Reference to device state watcher
+         // owned by this class
+         CUSBDeviceStateWatcher* iDeviceStateWatcher;
+         
+         // Contains USB mode indexes
+         RArray<TInt> iUsbModeIndexes; 
+         
+         // Central repository handle 
+         // owned by this class
+         CRepository* iRepository; 
+         
+         /** Handle to usbman for retrieving the personalities */
+         RUsb iUsbman;
+         
+         /** Handle to USBWatcher for setting the personality */
+         RUsbWatcher iUsbWatcher;         
+         
+         /** Is connected to USB Watcher */
+         TBool iUsbWatcherConnected;
+         
+         /** UsbOtg status watcher */
+         CUSBOtgHostStateWatcher* iOtgHostStateWatcher;
+         
+         /**
+          * Ids of the devices for which host drivers have been loaded.
+          * When we start to support hubs, there may be more than one element
+          * in this array.
+          */
+         RArray<TInt> iDeviceIDs;
+		 
+         //Number of personalities
+         TInt iPersonalityCount;
+         
+    };
+
+#endif // USBCLASSCHANGEUIPLUGINMODEL_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBClassChangeUIPluginView.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,242 @@
+/*
+* 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:  Declares container control for application.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIPLUGINVIEW_H
+#define USBCLASSCHANGEUIPLUGINVIEW_H
+
+// INCLUDES
+
+#include <aknview.h>            // AVKON components
+#include <AknQueryDialog.h>     // AVKON component
+#include <eikmenup.h>           // Menu pane definitions
+#include <gsplugininterface.h>  // General Settings plugin
+#include <ConeResLoader.h>
+#include <data_caging_path_literals.hrh> 
+
+#include "USBClassChangeUIPluginModel.h"   
+#include "USBClassChangeUIPluginInterface.h"
+
+// CONSTANTS
+/** implementation uid */
+const TUid KGsUSBUIPluginUid = { 0x1020E472 };
+
+_LIT(KFileDrive,"z:");
+_LIT(KResourceFileName, "USBClassChangeUIPlugin.rsc");
+_LIT(KUSBUIconFileName, "usbui.mif");
+
+/** USB modes are listed in the setting page */
+const TInt KSettingPageItemsGranularity = 3;
+
+// FORWARD DECLARATIONS
+class CUSBClassChangeUIPluginContainer;
+
+// CLASS DECLARATION
+ 
+/**
+* Main view of the application. Handles view activation, 
+* deactivation, commands and dynamic options menus.
+*/
+class CUSBClassChangeUIPluginView :
+    public CUSBClassChangeUIPluginInterface,
+    public MUSBUIObserver
+    {
+    public: // Constructors and destructor
+        	
+        /**
+        * Entry point for General Settings
+        */	
+        static CUSBClassChangeUIPluginView* NewPluginL();
+        
+        /**
+        * Entry point for USBClassChangeUIAppUi
+        */	
+        static CUSBClassChangeUIPluginView* NewL();
+        
+    	/**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+		/**
+        * Destructor.
+        */
+        virtual ~CUSBClassChangeUIPluginView();
+        
+    public: // Functions from base classes
+
+        /**
+        * From CAknView Returns view id.
+        * @param None.
+        * @return View id.
+        */
+        TUid Id() const;
+		
+		/**
+        * From CAknView Handles user commands.
+        * @param aCommand A command id.        
+        * @return None.
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * From CGSPluginInterface
+        * Method for getting caption of this plugin. This should be the 
+        * localized name of the settings view to be shown in parent view.
+        *
+        * @param aCaption pointer to Caption variable
+        */
+        void GetCaptionL( TDes& aCaption ) const;
+        
+        /**
+        * From CGSPluginInterface.
+        * Function for getting plugin's value for a certain key.
+        *
+        * @param aKey Key for the value to be retrieved.
+        * @parem aValue Value for the given gey in TDes format.
+        */
+        void GetValue(const TGSPluginValueKeys aKey, TDes& aValue );
+
+        /**
+        * From CGSPluginInterface
+        * Creates a new icon of desired type.
+        *
+        * @param  aIconType UID Icon type UID of the icon to be created.
+        * @return Pointer of the icon. NOTE: Ownership of this icon is
+        *         transferred to the caller.
+        */
+        CGulIcon* CreateIconL( const TUid aIconType );
+   
+        /**
+        * Initialize options menu.
+        * Remove help option, if the feature is not supported.
+        * @param aResId Resource Id
+        * @param aMenu The menu pane.
+        */
+        void DynInitMenuPaneL( TInt aResId, CEikMenuPane* aMenu );
+        
+        /**
+        * From MUSBUIObserver.
+        * Informs the observer that a setting has been changed. 
+        */
+        void SettingChanged();
+
+        /**
+         * From MUSBUIObserver/MUSBDeviceStateObserver.
+         * Informs the observer that USB device state has changed.
+         * @param aState current device state.
+         */
+        void DeviceStateChanged(TUsbDeviceState aPrevState,
+                                TUsbDeviceState aState);
+
+        /**
+         * From MUSBUIObserver/MUSBOtgHostStateObserver.
+         * @see MUSBOtgHostStateObserver::OtgHostIdPinStateChanged
+         */
+        void OtgHostIdPinStateChanged(TBool aIsIdPinOn);
+
+        /**
+         * From MUSBOtgHostStateObserver
+         * @see MUSBOtgHostStateObserver::OtgHostIdPinStateChanged
+         */
+        void HostEventNotify(TDeviceEventInformation aEventInfo);
+        
+        // New functions
+        
+        /**
+        * Gets the USB mode (from model)
+        * @param None.
+        * @return the value of the personality ID
+        */
+        TInt USBMode() const;
+        
+        /**
+        * Sets the USB mode (through model)
+        * @param The value of the personality ID.
+        * @return None.
+        */
+        void SetUSBModeL( TInt );
+                          
+        /**
+         * Checks whether USB device is connected.
+         */
+        TBool IsUSBDeviceConnected();
+
+     private: 
+     
+        
+         /**
+         * Updates parent view if we are loaded by GS plugin.
+         */
+        void UpdateParentView();
+
+        /**
+        * Handle change command for USB mode
+        * @param aMode usb mode id
+        */
+        void HandleCmdChangeUSBModeL(TInt aMode);
+        
+     private: // Functions from base classes
+
+        /**
+        * From CAknView Activates view.
+        * @param aPrevViewId Id of previous view.
+        * @param aCustomMessageId Custom message id.
+        * @param aCustomMessage Custom message.
+        * @return None.
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                                TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );		
+
+        /**
+        * From CAknView Deactivates view.        
+        * @param None.
+        * @return None.
+        */
+        void DoDeactivate();
+
+    private: // Data
+        //Reference to the UI container
+        //owned by this class
+        CUSBClassChangeUIPluginContainer*   iContainer;
+        
+        //reference to the AppUI
+        //not owned
+        CAknViewAppUi*              		iAppUIRef;
+        
+        //Reference to the Model
+        //owned by this class
+        CUSBClassChangeUIPluginModel*	    iModelRef;	
+        
+        // Flag used if it is needed to load 
+        // the UI plugin 
+        TBool                       		iLoadAsGSPlugin;
+        
+        CEikonEnv*                          iEikEnv;
+        // Flag for eikon env.
+        TInt                                iResourceFileFlag; 
+        // Previous view of GS ap
+        TVwsViewId 				    		iPrevViewId; 	   
+       
+        TBool                               iHelpSupported;
+
+    };
+
+#endif  // USBCLASSCHANGEUIPLUGINVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/USBDeviceStateWatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* 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:  Device state watcher class.
+ *
+*/
+
+
+#ifndef USBDEVICESTATEWATCHER_H
+#define USBDEVICESTATEWATCHER_H
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <usbman.h>
+
+/**
+ * A callback interface for informing about device state changes
+ */
+class MUSBDeviceStateObserver
+    {
+    public:
+        
+        /**
+         * Informs the observer that USB device state has changed.
+         * @param aPreviousState previous device state.
+         * @param aCurrentState current device state.
+         */
+        virtual void DeviceStateChanged(TUsbDeviceState aPreviousState,
+                                        TUsbDeviceState aCurrentState) = 0;
+    };
+
+// CLASS DECLARATION
+
+/**
+ * Class that listens for USB device state changes and notifies
+ * the observer.
+ */
+class CUSBDeviceStateWatcher : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor. Uses existing usb manager session.
+         * Note that it's not possible (and usually not necessary) to attach
+         * more than one USBDeviceStateWatcher to the same session.
+         *
+         * @param aObserver  Reference to device state observer.
+         * @param aUsbMan    Existing usb manager session.
+         * @return Pointer to created object.
+         */
+        static CUSBDeviceStateWatcher* NewL(MUSBDeviceStateObserver& aObserver,
+            RUsb& aUsbMan);
+        
+        /**
+         * Two-phased constructor. Creates its own usb manager session.
+         *
+         * @param aObserver  Reference to device state observer.
+         * @return Pointer to created object.
+         */
+        static CUSBDeviceStateWatcher* NewL(MUSBDeviceStateObserver& aObserver);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CUSBDeviceStateWatcher();
+
+    public: // from base class CActive
+
+        /**
+        * From CActive.
+        * This method is called when device state has changed.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * In this implementation this method should never be called.
+        *
+        * @param aError the leave code
+        * @return KErrNone
+        */
+        TInt RunError(TInt aError);
+
+        /**
+        * From CActive
+        * If there is outstanding request pending when Cancel() is called then
+        * this method must cancel request.
+        */
+        void DoCancel();
+
+    private:
+
+        /**
+         * Private constructor.
+         *
+         * @param aObserver Reference to MUSBDeviceStateObserver.
+         */
+        CUSBDeviceStateWatcher(MUSBDeviceStateObserver& aObserver);
+
+        /**
+         * 2nd phase constructor.
+         * Creates its own usb manager session.
+         */
+        void ConstructL();
+        
+        /**
+         * 2nd phase constructor.
+         * Uses existing usb manager session.
+         *
+         * @param aUsbMan    Existing usb manager session.
+         */
+        void ConstructL(RUsb& aUsbMan);
+        
+        /**
+         * Code shared by all ConstructL methods.
+         */
+        void CommonConstructL();
+        
+        // Disable default C++ behavior that makes no sense
+        // for this implementation.
+        CUSBDeviceStateWatcher();
+        CUSBDeviceStateWatcher(const CUSBDeviceStateWatcher&);
+        CUSBDeviceStateWatcher& operator=(const CUSBDeviceStateWatcher&);
+
+    private: // Data
+
+        /**
+         * Handle to Usb Manager
+         */
+        RUsb iUsbMan;
+
+        /**
+         * Current device state
+         */
+        TUsbDeviceState iCurrentState;
+
+        /**
+         * Last known device state
+         */
+        TUsbDeviceState iPreviousState;
+
+        /**
+         * Refernce to the observer
+         */
+        MUSBDeviceStateObserver& iObserver;
+    };
+
+#endif   // USBDEVICESTATEWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/inc/usbotghoststatewatcher.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,267 @@
+/*
+* 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:  OtgHost state watcher class.
+ *
+*/
+
+
+#ifndef USBOTGHOSTSTATEWATCHER_H
+#define USBOTGHOSTSTATEWATCHER_H
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32property.h>
+#include <usbman.h>
+#include <usbhostdefs.h>
+
+
+/**
+ * A callback interface for informing about OtgHost state changes
+ */
+class MUSBOtgHostStateObserver
+    {
+    public:
+        
+        /**
+         * Informs the observer that USB Otg Id Pin state has changed.
+         * @param aIsPinOn Id pin state - ETrue(On), EFalse(Off) 
+         */
+        virtual void OtgHostIdPinStateChanged(TBool aIsIdPinOn) = 0;
+
+        /**
+         * Informs the observer that USB host event.
+         * @param aEventInfo Device information related to this event
+         */
+        virtual void HostEventNotify(TDeviceEventInformation aEventInfo) = 0;
+    };
+
+// CLASS DECLARATION
+
+/**
+ * Class that listens for USB OtgHost state changes then notifies
+ * the observer.
+ */
+class CUSBOtgHostStateWatcher : CBase
+    {
+    class CUSBOtgIdPinStateWatcher : public CActive
+        {
+    public:
+        /**
+         * Two-phased constructor. 
+         *
+         * @param aOtgHostStateWatcher Reference to the owner - CUSBOtgHostStateWatcher.
+         * @return Pointer to created object.
+         */
+        static CUSBOtgIdPinStateWatcher* NewL(CUSBOtgHostStateWatcher& aOtgHostStateWatcher);
+
+        /** C++ destructor */
+        virtual ~CUSBOtgIdPinStateWatcher();
+
+        /**
+         * Get Id pin state
+         * @aIsIdPinOn Receive Id pin on/off state. ETrue: Id pin on, EFalse: Id pin off.
+         * @return KErrNone if successful, otherwise the error that occurred 
+         */
+        TInt IsIdPinOn(TBool &aIsIdPinOn);
+        
+    protected:
+        // from base class CActive
+        /**
+         * From CActive.
+         * This method is called when Id pin state has changed.
+         */
+        void RunL();
+
+        /**
+         * From CActive.
+         * In this implementation this method should never be called.
+         *
+         * @param aError the leave code
+         * @return KErrNone
+         */
+        TInt RunError(TInt aError);
+
+        /**
+         * From CActive
+         * If there is outstanding request pending when Cancel() is called then
+         * this method must cancel request.
+         */
+        void DoCancel();
+
+    private:
+        /**
+         * C++ constructor
+         * @param aOtgHostStateWatcher Reference to the owner - CUSBOtgHostStateWatcher.
+         */
+        CUSBOtgIdPinStateWatcher(CUSBOtgHostStateWatcher& aOtgHostStateWatcher);
+        
+        /**
+         * 2nd phase constructor.
+         */
+        void ConstructL();
+        
+    private: // Data
+        /**
+         * The observer observes property change
+         */
+        RProperty iIdPin;
+        
+        /**
+         * The owner - CUSBOtgHostStateWatcher
+         */
+        CUSBOtgHostStateWatcher& iOtgHostStateWatcher;
+        };
+
+    class CUSBHostEventNotifWatcher : public CActive
+        {
+    public:
+        /**
+         * Two-phased constructor. 
+         *
+         * @param aOtgHostStateWatcher Reference to the owner - CUSBOtgHostStateWatcher.
+         * @return Pointer to created object.
+         */
+        static CUSBHostEventNotifWatcher* NewL(CUSBOtgHostStateWatcher& aOtgHostStateWatcher);
+
+        /** C++ destructor */
+        virtual ~CUSBHostEventNotifWatcher();
+
+    protected:
+        // from base class CActive
+        /**
+         * From CActive.
+         * This method is called when host event emerged .
+         */
+        void RunL();
+
+        /**
+         * From CActive.
+         * In this implementation this method should never be called.
+         *
+         * @param aError the leave code
+         * @return KErrNone
+         */
+        TInt RunError(TInt aError);
+
+        /**
+         * From CActive
+         * If there is outstanding request pending when Cancel() is called then
+         * this method must cancel request.
+         */
+        void DoCancel();
+
+    private:
+        /**
+         * C++ constructor
+         * @param aOtgHostStateWatcher Reference to the owner - CUSBOtgHostStateWatcher.
+         */
+        CUSBHostEventNotifWatcher(CUSBOtgHostStateWatcher& aOtgHostStateWatcher);
+        
+        /**
+         * 2nd phase constructor.
+         */
+        void ConstructL();
+        
+    private: // Data
+        /**
+         * Notification info comes to this member
+         */
+        TDeviceEventInformation iEventInfo;
+        
+        /**
+         * The owner - CUSBOtgHostStateWatcher
+         */
+        CUSBOtgHostStateWatcher& iOtgHostStateWatcher;
+        };
+    
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor. Uses existing usb manager session.
+         * Note that it's not possible (and usually not necessary) to attach
+         * more than one USBOtgHostStateWatcher to the same session.
+         *
+         * @param aObserver  Reference to OtgHost state observer.
+         * @param aUsbMan    Existing usb manager session.
+         * @return Pointer to created object.
+         */
+        static CUSBOtgHostStateWatcher* NewL(MUSBOtgHostStateObserver& aObserver,
+            RUsb& aUsbMan);
+        
+        /**
+         * Destructor.
+         */
+        virtual ~CUSBOtgHostStateWatcher();
+
+        /**
+         * Get Id pin state
+         * @aIsIdPinOn Receive Id pin on/off state. ETrue: Id pin on, EFalse: Id pin off.
+         * @return KErrNone if successful, otherwise the error that occurred 
+         * @see CUSBOtgIdPinStateWatcher::IsIdPinOn
+         */
+        TInt IsIdPinOn(TBool &aIsIdPinOn);
+        
+        /**
+         * Check wheather a pheripheral device is connected or not. 
+         * @aIsConnected A pheripheral device connected(ETrue) or not(EFailse).
+         * @return KErrNone if successful, otherwise the error that occurred 
+         */
+       TInt IsPeripheralConnected(TBool &aIsConnected);
+        
+    private:
+
+        /**
+         * Private constructor.
+         * @param aObserver Reference to MUSBOtgHostStateObserver.
+         * @param aUsbMan Existing usb manager session.
+         */
+        CUSBOtgHostStateWatcher(MUSBOtgHostStateObserver& aObserver, RUsb& aUsbMan);
+
+        /**
+         * 2nd phase constructor.
+         */
+        void ConstructL();
+        
+    private: // Data
+
+        /**
+         * Usb Manager
+         */
+        RUsb& iUsbMan;
+
+        /**
+         * Property of peripheral-connected
+         */
+        RProperty iPeripheral;
+        
+        /**
+         * The observer of OTG/host events
+         */
+        MUSBOtgHostStateObserver& iObserver;
+        
+        /**
+         * The watcher of Otg Id Pin state
+         * Own.
+         */
+        CUSBOtgIdPinStateWatcher* iOtgIdPinWatcher;
+        
+        /**
+         * The watcher of host event
+         * Own.
+         */
+        CUSBHostEventNotifWatcher* iHostEventWatcher;
+        
+    };
+
+#endif   // USBOTGHOSTSTATEWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginCRWatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2005, 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 implements USBClassChangeUIPluginCRWatcher class.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "USBClassChangeUIPluginCRWatcher.h"
+#include "UsbWatcherInternalCRKeys.h"
+#include "USBClassChangeUIPluginModel.h"
+#include "USBClassChangeUIPluginDebug.h"
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginCRWatcher* CUSBClassChangeUIPluginCRWatcher::NewL(
+    MUSBUICRSettingObserver& aOwner, TUint32 aKey, TBool aOneShot)
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher:NewL"));
+    CUSBClassChangeUIPluginCRWatcher* self 
+        = new (ELeave) CUSBClassChangeUIPluginCRWatcher(aOwner, aKey, aOneShot);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::~CUSBClassChangeUIPluginCRWatcher
+// C++ default destructor
+// -----------------------------------------------------------------------------
+//    
+CUSBClassChangeUIPluginCRWatcher::~CUSBClassChangeUIPluginCRWatcher()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: desctructor"));
+    Cancel(); // cancels any existing active object orders for iStatus
+    delete iPersonalityRepository; // deletes CRepository* member object.
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: desctructor complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::CUSBClassChangeUIPluginCRWatcher
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginCRWatcher::CUSBClassChangeUIPluginCRWatcher(
+    MUSBUICRSettingObserver& aOwner, TUint32 aKey, TBool aOneShot)
+    : CActive(EPriorityStandard), 
+    iOwner(aOwner),
+    iKey(aKey),
+    iOneShot(aOneShot)
+    {
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::RunError
+// Standard active object error function.
+// -----------------------------------------------------------------------------
+//
+
+TInt CUSBClassChangeUIPluginCRWatcher::RunError(TInt /*aError*/)
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher::RunError: ERROR %d \
+        from RunL.") );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::RunL
+// This function will be called upon a change in the watched key.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginCRWatcher::RunL()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher::RunL"));
+
+    iOwner.SettingChangedL( iKey );        
+    if (!iOneShot)
+        {
+        StartListeningL(); 
+        }
+
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher::RunL complete."));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::ConstructL
+// Construct member variable iPersonalityRepository that is to access the
+// repository. Then start listening of the changes in the repository.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginCRWatcher::ConstructL()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: ConstructL"));
+    CActiveScheduler::Add(this);
+
+    iPersonalityRepository = CRepository::NewL( KCRUidUsbWatcher );
+    
+    StartListeningL();
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: ConstructL complete"));        
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::StopListening
+// Cancels notifications.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginCRWatcher::StopListening()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: StopListening"));
+    Cancel();
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: StopListening complete"));
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::StartListeningL
+// Orders notifications and sets the object active.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginCRWatcher::StartListeningL()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: StartListeningL"));
+    if(IsActive())
+        {
+        return;   
+        }
+
+    User::LeaveIfError(iPersonalityRepository->NotifyRequest(
+        iKey, 
+        iStatus ) );
+    SetActive();
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher: StartListening complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginCRWatcher::DoCancel
+// Standard active object cancellation function.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginCRWatcher::DoCancel()
+    {
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher::DoCancel"));
+    
+    if ( iPersonalityRepository )
+        {
+        // cancel the order for change notifications
+        iPersonalityRepository->NotifyCancel( iKey );
+        }
+    FLOG(_L("[USBCLASSCHANGEUIPLUGIN]\tCUSBClassChangeUIPluginCRWatcher::DoCancel complete"));
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginContainer.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,446 @@
+/*
+* 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:  Container that contains the USB mode listbox
+*
+*/
+
+
+// INCLUDE FILES
+#include <barsread.h>	// Resource reader
+
+#include <usbpersonalityids.h>
+#include <USBClassChangeUIPlugin.rsg> // Resources
+#include <csxhelp/usb.hlp.hrh>   // Help id
+#include <StringLoader.h>
+#include <AknIconArray.h>
+#include <eikmenub.h>
+#include <eikmobs.h>
+
+#include "USBClassChangeUIPlugin.h"
+#include "USBClassChangeUIPluginContainer.h"
+#include "USBClassChangeUIPluginModel.h"
+#include "USBClassChangeUIPluginView.h"
+#include "USBClassChangeUIPluginDebug.h"
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginContainer*
+CUSBClassChangeUIPluginContainer::NewL(
+    CUSBClassChangeUIPluginView* aView,
+    CUSBClassChangeUIPluginModel* aModel)
+    {
+    FLOG(_L("[USBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer:NewL"));
+    CUSBClassChangeUIPluginContainer* self 
+        = new (ELeave) CUSBClassChangeUIPluginContainer(aView, aModel);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self); 
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::ConstructL(const TRect& aRect)
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::ConstructL()
+    { 
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::ConstructL()"));
+    
+    CreateWindowL();
+    iPopupController = CAknInfoPopupNoteController::NewL();
+   
+    iUSBAllItemsArray = new ( ELeave ) CDesCArrayFlat( 
+        KUSBClassChangeUISupportedModesGranularity );
+    iUSBAllItemsArrayDefault = new ( ELeave ) CDesCArrayFlat( 
+            KUSBClassChangeUISupportedModesGranularity );
+    iUSBAllItemsArrayActive = new ( ELeave ) CDesCArrayFlat( 
+            KUSBClassChangeUISupportedModesGranularity );
+    iPopUpItems = new ( ELeave ) CDesCArrayFlat( 
+            KUSBClassChangeUISupportedModesGranularity );
+    CArrayPtrFlat<CGulIcon>* iconArray = new(ELeave) CArrayPtrFlat<CGulIcon>(KUSBClassChangeUIIconGranularity);  
+    CleanupStack::PushL( iconArray );
+       
+    // prepare the listbox items and the tooltip strings for the USB UI view
+    iModelRef->SupportedUSBModeArraysL( *iUSBAllItemsArray, *iUSBAllItemsArrayDefault, *iUSBAllItemsArrayActive, *iPopUpItems, *iconArray);
+
+    // Create DoubleLargeStyleListBox for USB UI view
+    //
+    iUSBMainListBox = new ( ELeave ) CAknDoubleLargeStyleListBox;
+    iUSBMainListBox->SetContainerWindowL( *this );
+    iUSBMainListBox->ConstructL( this, EAknListBoxMarkableList );
+
+    // Set up scroll bar for the Listbox
+    iUSBMainListBox->CreateScrollBarFrameL( ETrue );
+    iUSBMainListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
+        CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
+    
+    // As soon as the list is created the tooltip info of the first item in the list is shown
+    
+   
+    //creating a handle to the icon array and passing its ownership to data object
+    //no need to handle its deletion
+    iUSBMainListBox->ItemDrawer()->FormattedCellData()->SetIconArray(iconArray);
+    CleanupStack::Pop(iconArray);
+    
+    iUSBMainListBox->Model()->SetItemTextArray( this );
+    iUSBMainListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+
+    iUSBMainListBox->SetListBoxObserver( this );
+
+    SetRect( iViewRef->ClientRect() );
+   
+    const RArray<TInt> usbIds = iModelRef->GetUsbIds();
+    TInt currentMode = usbIds.Find(iViewRef->USBMode());
+    ShowPopUpsL(currentMode);
+    ActivateL();
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::ConstructL complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginContainer::CUSBClassChangeUIPluginContainer( 
+    CUSBClassChangeUIPluginView* aView,
+    CUSBClassChangeUIPluginModel* aModel) :
+    iViewRef(aView), iModelRef(aModel)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginContainer::~CUSBClassChangeUIPluginContainer()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::Destructor"));
+
+	delete iUSBMainListBox;
+	
+	delete iUSBAllItemsArray;
+	delete iUSBAllItemsArrayDefault;
+	delete iUSBAllItemsArrayActive;
+	delete iPopUpItems;
+	
+    delete iPopupController;
+	FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::Destructor complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::SizeChanged()
+// Called by framework when the view size is changed
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::SizeChanged()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::SizeChangedL()"));
+    
+    iUSBMainListBox->SetRect( Rect() ); 
+    iUSBMainListBox->SetFocus( ETrue );
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::SizeChangedL complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::FocusChanged()
+// Called by framework when the focus is changed
+// ----------------------------------------------------------------------------
+//    
+void CUSBClassChangeUIPluginContainer::FocusChanged( TDrawNow /*aDranow*/ )
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::FocusChanged()"));
+    if( iUSBMainListBox)
+        {
+        iUSBMainListBox->SetFocus( IsFocused() );
+        }
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::FocusChanged() complete"));    
+    }
+    
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::CountComponentControls() const
+// Returns the number of controls inside this container
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginContainer::CountComponentControls() const
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::CountComponentControls()"));
+    
+    return KUSBClassChangeUIComponentCount; 
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::ComponentControl(TInt aIndex) const
+// Returns the control inside this container. Note that this function is
+// inherited from CCoeControl and thus must be const even it returns a pointer,
+// which can be used for modifying the class. 
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CUSBClassChangeUIPluginContainer::ComponentControl( 
+    TInt aIndex ) const
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::ComponentControl()"));
+    
+    switch ( aIndex )
+        {
+        case 0:
+            {
+            return iUSBMainListBox;
+            }
+        default:
+            {
+            return NULL;
+            }            
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::OfferKeyEventL
+// Redirects keypresses to the listbox
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CUSBClassChangeUIPluginContainer::OfferKeyEventL(
+    const TKeyEvent& aKeyEvent,TEventCode aType )
+    {
+    TInt maxItemcount = iModelRef->PersonalityCount();
+    TInt maxIndex = maxItemcount-1;
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::OfferKeyEventL()"));
+    TBool isfocus =  iViewRef->MenuBar()->ItemSpecificCommandsEnabled();   
+    if ( isfocus && aType == EEventKey && 
+            (aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow) )
+            {
+            iCurrentItemIndex = iUSBMainListBox->CurrentItemIndex();
+            if( aKeyEvent.iCode == EKeyDownArrow )
+                {
+                if( iCurrentItemIndex >= maxIndex )
+                    {
+                    iCurrentItemIndex = 0;
+                    }
+                else
+                    {
+                    iCurrentItemIndex++;
+                    }
+                }
+            else // ( aKeyEvent.iCode == EKeyUpArrow )    
+                {
+                if( iCurrentItemIndex <= 0 )
+                    {
+                    iCurrentItemIndex = maxIndex;
+                    }
+                else
+                    {
+                    iCurrentItemIndex--;
+                    }
+                }
+            ShowPopUpsL( iCurrentItemIndex );
+            iCurrentItemIndex = iUSBMainListBox->CurrentItemIndex();
+            }
+
+   
+          TKeyResponse res = iUSBMainListBox->OfferKeyEventL( aKeyEvent, aType );
+           FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::OfferKeyEventL complete"));
+
+          return res;
+    }
+
+//------------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::showpopupsFinal(TInt &aValue)
+// Display the popups
+//------------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::ShowPopUpsL(TInt aIndex)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::ShowPopUpsL "));
+    if ( aIndex >= 0 && aIndex < iPopUpItems->Count() )
+        {
+        iPopupController->SetTimePopupInView( KMaxVisibleTime);
+        TPtrC chosen = iPopUpItems->MdcaPoint(aIndex);
+        iPopupController->SetTextL( chosen );
+        iPopupController->SetPositionByHighlight( TRect( 
+                   iUSBMainListBox->View()->ItemPos( aIndex + 1 ), 
+                   iUSBMainListBox->View()->ItemSize() ) );
+        iPopupController->SetTimeDelayBeforeShow( KMsToWaitBeforePopup );
+        iPopupController->ShowInfoPopupNote();
+        }
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::ShowPopUpsL complete"));
+  
+}
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::HandleListBoxEventL(
+//     CEikListBox* aListBox,TListBoxEvent aEventType)
+// Handle events from the ListBox
+// ----------------------------------------------------------------------------
+//    
+void CUSBClassChangeUIPluginContainer::HandleListBoxEventL(
+    CEikListBox* /*aListBox*/,TListBoxEvent aEventType )
+   {
+   FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::HandleListBoxEventL()"));
+   
+    __ASSERT_DEBUG( iViewRef!=0, PANIC( EUSBUIPanicIllegalValue ) );
+    
+    //Selection key pressed, when MSK is not enabled. Or touch stylus 
+    //double clicked.
+    //
+    if( AknLayoutUtils::PenEnabled() )
+           {
+           switch ( aEventType )
+               {
+               case EEventItemSingleClicked:
+                   {
+                   FLOG(_L("[CUSBClassChangeUIPlugin]\t HandleListBoxEventL()EEventItemSingleClicked"));
+                   iViewRef->HandleCommandL( EUSBUICmdSelect );
+                   break;
+                   }
+               case EEventPenDownOnItem:
+            	   {
+            	   ShowPopUpsL (CurrentItemIndex());
+            	   break;
+            	   }
+               case EEventPanningStarted:
+               case EEventPanningStopped:
+               case EEventFlickStarted:
+               case EEventFlickStopped:
+               case EEventItemDraggingActioned:
+            	   break;
+              default:
+                     break;
+                     }
+                }
+    if( (aEventType == EEventEnterKeyPressed) || 
+        (aEventType == EEventItemDoubleClicked) ) //for touch support
+            {
+            iViewRef->HandleCommandL( EUSBUICmdSelect );
+            }
+        
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::HandleListBoxEventL complete"));
+	}
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::MdcaCount()
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginContainer::MdcaCount() const
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::MdcaCount()"));
+    TInt numberOfMainViewItems =iModelRef->PersonalityCount();
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::MdcaCount()= %d"), numberOfMainViewItems));
+    return numberOfMainViewItems;
+    }
+    
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::MdcaPoint()
+// Main view listbox item formatter:
+// Returns the current format string depending value
+// of the item concerned.
+// ----------------------------------------------------------------------------
+//
+TPtrC CUSBClassChangeUIPluginContainer::MdcaPoint( TInt aIndex ) const
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::MdcaPoint()"));
+    
+    TPtrC chosen;
+    const RArray<TInt> usbIds = iModelRef->GetUsbIds();
+    TInt currentIndex = usbIds.Find(iViewRef->USBMode());
+    if (aIndex == currentIndex)
+        {
+        if(iViewRef->IsUSBDeviceConnected())
+            {
+            FLOG(_L("[CUSBClassChangeUIPlugin]\t MdcaPoint()The selected mode and usbconnected"));
+            chosen.Set(iUSBAllItemsArrayActive->MdcaPoint(aIndex));
+            }
+        else
+            {
+            FLOG(_L("[CUSBClassChangeUIPlugin]\t MdcaPoint()The selected mode and usb not connected"));
+            chosen.Set(iUSBAllItemsArrayDefault->MdcaPoint(aIndex));
+            }
+        }
+    else
+        {
+        FLOG(_L("[CUSBClassChangeUIPlugin]\t MdcaPoint()not selected mode"));
+        chosen.Set(iUSBAllItemsArray->MdcaPoint(aIndex));
+        }
+     
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::MdcaPoint complete"));
+    
+    return chosen;
+    }
+    
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::SettingChanged
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::SettingChanged()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::SettingChangedL()"));
+    
+	iUSBMainListBox->DrawDeferred();
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::SettingChangedL complete"));
+    }
+    
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::GetHelpContext
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::GetHelpContext(TCoeHelpContext& aContext) const
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::GetHelpContext()"));
+    
+    aContext.iMajor = KUidUSBClassChangeUI;
+    aContext.iContext = KUSB_HLP_MAIN;
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::GetHelpContext complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::HandleResourceChange
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginContainer::HandleResourceChange( TInt aType )
+    {
+    CCoeControl::HandleResourceChange( aType ); 
+    if( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        SetRect( iViewRef->ClientRect() );
+        DrawNow(); 
+        }
+    else 
+        {
+        if ( aType == KAknsMessageSkinChange )
+            {
+            iUSBMainListBox->HandleResourceChange( aType ); 
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginContainer::CurrentItemIndex
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginContainer::CurrentItemIndex()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginContainer::CurrentItemIndex()"));
+
+    return iUSBMainListBox->CurrentItemIndex();
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginImplementationTable.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2005, 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:  ECOM proxy table for this plugin
+*
+*/
+
+
+// System includes
+#include <e32std.h>
+#include <implementationproxy.h>
+
+// User includes
+#include "USBClassChangeUIPluginView.h"
+
+const TImplementationProxy KUSBClassChangeUIPluginImplementationTable[] = 
+    {
+    // Uid for plugin implementation for General Settings application:
+    IMPLEMENTATION_PROXY_ENTRY( 0x1020E473,	CUSBClassChangeUIPluginView::NewPluginL ),
+    // Uid for plugin implementation for USBClassChangeUIAppUi:
+    IMPLEMENTATION_PROXY_ENTRY( 0x1027478F,	CUSBClassChangeUIPluginView::NewL )
+    };
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Gate/factory function
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof(KUSBClassChangeUIPluginImplementationTable) 
+        / sizeof(TImplementationProxy);
+    return KUSBClassChangeUIPluginImplementationTable;
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginModel.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,611 @@
+/*
+* 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:  This is the interface to all the settings.
+*
+*/
+
+// INCLUDE FILES
+
+#include <centralrepository.h> 
+#include <usb.h>
+#include <usbwatcher.h>
+#include <UsbWatcherInternalCRKeys.h>
+#include <USBClassChangeUIPlugin.rsg> // Resources
+#include <coemain.h>
+#include <usbpersonalityids.h>
+#include <avkon.mbg>
+#include <usbui.mbg>
+#include <aknappui.h>
+#include <AknIconArray.h>
+#include <aknlists.h>
+#include <featmgr.h>
+
+#include "USBClassChangeUIPluginModel.h"
+#include "USBClassChangeUIPluginDebug.h"
+#include "USBClassChangeUIPlugin.h"
+#include "USBClassChangeUIPluginView.h"
+
+_LIT( KFirstTab, "%d\t" );
+_LIT( KSecondTab, "\t" );
+_LIT(KUSBUIEmptyString, "0\t \t "); 
+
+#if defined(__WINS__) && !defined(__USB_EMULATION__)
+    // There are two situations under emulator:
+    // 1. Do not use UsbManager and UsbWatcher, which is the normal case, and
+    // 2. Use UsbManagerDummy and UsbWatcherDummy, for UI testing.
+    // Comment the define line for case 2. 
+   #define NO_USBWATCHER_USBMANAGER  
+#endif //__WINS__
+
+// ================= MEMBER FUNCTIONS ==========================================
+//
+
+CUSBClassChangeUIPluginModel::CUSBClassChangeUIPluginModel()
+: CActive( EPriorityNormal ), iUsbWatcherConnected(EFalse)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginModel::~CUSBClassChangeUIPluginModel()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::Destructor"));
+    
+    Cancel();
+    delete iCRPersonalityWatcher;
+    delete iDeviceStateWatcher;
+    delete iOtgHostStateWatcher;
+    delete iRepository; 
+    iUsbModeIndexes.Close(); 
+#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
+    iUsbman.Close();
+    iUsbWatcher.Close();  
+    iDeviceIDs.Close();
+#endif //NO_USBWATCHER_USBMANAGER
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::Destructor complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::ConstructL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL()"));
+
+    iCRPersonalityWatcher = CUSBClassChangeUIPluginCRWatcher::NewL( *this, 
+        KUsbWatcherPersonality);
+
+    iUsbModeIndexes = RArray<TInt>(KUSBClassChangeUISupportedModesGranularity);
+    iRepository = CRepository::NewL( KCRUidUsbWatcher );
+
+#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
+    User::LeaveIfError(iUsbman.Connect());
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL() iUsbman OK"));
+    
+    iDeviceStateWatcher = CUSBDeviceStateWatcher::NewL(*this, iUsbman);
+    iOtgHostStateWatcher = CUSBOtgHostStateWatcher::NewL(*this, iUsbman);
+    iDeviceIDs.ReserveL(1);
+    
+#endif //NO_USBWATCHER_USBMANAGER
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL() complete"));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBClassChangeUIPluginModel* CUSBClassChangeUIPluginModel::NewL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\tCUSBClassChangeUIPluginModel:NewL"));
+    CUSBClassChangeUIPluginModel* self 
+        = new (ELeave) CUSBClassChangeUIPluginModel();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::SetUSBModeL
+// Sets the Central Repository key to the parameter.
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::SetUSBModeL(TInt aMode)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL()"));
+    
+    // Only change the value if necessary
+    TInt usbMode = USBMode();
+    if (usbMode != aMode)
+        {
+#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
+        // Change the personality asynchrously, result checked in RunL()
+        if( IsActive() ) 
+            {
+            Cancel();
+            }
+        if ( (!iUsbWatcherConnected) && (iUsbWatcher.Connect() == KErrNone) )
+            {
+            iUsbWatcherConnected = ETrue;
+            FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL iUsbWatcher connected"));
+            }
+        if (iUsbWatcherConnected)
+            {
+            FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL setting personality"));
+            iUsbWatcher.SetPersonality(iStatus, aMode);
+            SetActive();
+            }
+#endif //NO_USBWATCHER_USBMANAGER
+        }
+        
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL complete"));
+    }
+
+void CUSBClassChangeUIPluginModel::RunL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::RunL()"));
+    
+    //Check the return value of SetPersonality()
+    //Leave if KErrDiskFull
+    if( iStatus == KErrDiskFull ) // Other errors not leave
+        {
+        User::Leave( KErrDiskFull );    
+        }
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::RunL complete"));
+    }
+    
+void CUSBClassChangeUIPluginModel::DoCancel()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::DoCancel()"));
+    
+    if (iUsbWatcherConnected)
+        {
+        iUsbWatcher.CancelSetPersonality();
+        }
+
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::DoCancel complete()"));
+    }
+    
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::USBMode
+// Returns the value in Central Repository.
+// -----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginModel::USBMode()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::USBMode()"));
+    TInt mode = 0;
+    iRepository->Get(KUsbWatcherPersonality, mode);
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::USBMode complete"));
+    return mode;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::GetDeviceState
+// Gets the current device state
+// -----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginModel::GetDeviceState(TUsbDeviceState& aState)
+    {
+#ifdef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
+        aState = EUsbDeviceStateUndefined;
+        return KErrNone;
+#else
+        return iUsbman.GetDeviceState(aState);
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::GetDescription
+// Gets description for the specified USB mode (personality ID)
+// -----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginModel::GetDescription(TInt aMode, HBufC*& aDescription)
+    {
+        return iUsbman.GetDescription(aMode, aDescription);
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::UpdateMainContainerReference
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::SetSettingsObserver(MUSBUIObserver* aObserver)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetSettingsObserver()"));
+    iObserver = aObserver;
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetSettingsObserver complete"));
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::GetSupportedUSBModesL
+// Reads the supported USB Modes from USBManager
+// The lists received as parameters are updated. 
+// -----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL( 
+        CDesCArrayFlat& aListBox,CDesCArrayFlat& aListBoxDefault,
+        CDesCArrayFlat& aListBoxActive, CDesCArrayFlat& aPopUpItems,
+        CArrayPtrFlat<CGulIcon>& aIconArray)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL()"));  
+    RArray<TInt> personalityIds;
+    CleanupClosePushL( personalityIds );
+    HBufC* usbModeListBox = NULL;
+    HBufC* usbModeListBoxActive = NULL;
+   
+    // Allocate memory for descriptors to hold texts for listbox 
+    usbModeListBox = HBufC::NewLC( KUsbStringDescStringMaxSize );
+    TPtr usbModeListBoxPtr = usbModeListBox->Des();
+       
+    usbModeListBoxActive = HBufC::NewLC( KUsbStringDescStringMaxSize );
+    TPtr usbModeListBoxActivePtr = usbModeListBoxActive->Des();
+
+    HBufC* usbDefaultText = NULL;
+    usbDefaultText = CCoeEnv::Static()->AllocReadResourceLC( R_USB_MODE_DEFAULT );
+   
+    HBufC* usbActiveText = NULL;
+    usbActiveText = CCoeEnv::Static()->AllocReadResourceLC( R_USB_MODE_ACTIVE );
+   
+    //Check phone as modem is supported or not
+    FeatureManager::InitializeLibL();
+    TBool phoneAsModemSupported = FeatureManager::FeatureSupported(
+        KFeatureIdUsbModem );
+    FeatureManager::UnInitializeLib();
+ 
+    // Get personality ids
+     iPersonalityCount = 0;
+#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
+    if (iUsbman.GetPersonalityIds(personalityIds) == KErrNone)
+        {
+        FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): Personality Ids got"));              
+        for (TInt i = 0; i < personalityIds.Count(); i++)
+            {  
+            FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t i= %d "), i));
+            
+            if (personalityIds[i] == KUsbPersonalityIdModemInst)
+                {
+                if (!phoneAsModemSupported)
+                    {
+                    FLOG(_L("Phone as modem is not supported!"));    
+                    continue;
+                    }
+                }
+				
+			TUint32 property;
+			TInt ret  =  iUsbman.GetPersonalityProperty(personalityIds[i], property);
+			if (ret == KErrNone)
+				{
+				FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin] property\t i= 0x%x "), property));
+				if (property & KUsbPersonalityPropertyHidden)
+					{
+					FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): The Personality is hidden"));
+					continue;
+					}
+				}
+			else
+				{
+				FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin] Error to get the property\t i= %d "), ret));
+				}
+
+            HBufC* description = NULL;
+            HBufC* detailDescription = NULL;
+            
+            if (iUsbman.GetDescription(personalityIds[i], description) == KErrNone)
+                {
+                CleanupStack::PushL(description);
+                FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): Description read"));
+                //mode strings for setting page
+                TPtr descriptionPtr = description->Des();                                        
+                iUsbModeIndexes.Append(personalityIds[i]);
+ 
+                //modes with labels for list box
+                usbModeListBoxPtr.Zero();
+                usbModeListBoxActivePtr.Zero();
+                
+                usbModeListBoxPtr.Format(KFirstTab, iPersonalityCount);
+                usbModeListBoxPtr.Append(descriptionPtr);
+                usbModeListBoxPtr.Append(KSecondTab);
+                
+                usbModeListBoxActivePtr.Copy(usbModeListBoxPtr);
+                            
+                aListBox.AppendL(usbModeListBoxPtr);
+                                
+                usbModeListBoxPtr.Append(*usbDefaultText);
+                usbModeListBoxActivePtr.Append(*usbActiveText);
+               
+                aListBoxDefault.AppendL(usbModeListBoxPtr);
+                aListBoxActive.AppendL(usbModeListBoxActivePtr);
+                
+                CleanupStack::PopAndDestroy(description); 
+                //creating the icon list
+                AddIconL (personalityIds[i], aIconArray);
+                if (iUsbman.GetDetailedDescription(personalityIds[i], detailDescription) == KErrNone)
+                	{
+                	CleanupStack::PushL(detailDescription);
+                	aPopUpItems.AppendL(detailDescription->Des());
+                	CleanupStack::PopAndDestroy(detailDescription); 
+               		}
+                else
+                	{ 
+                	aPopUpItems.AppendL(KNullDesC);
+                	}
+                iPersonalityCount++;
+                }
+                
+            }
+        }
+#endif // NO_USBWATCHER_USBMANAGER
+ 
+    if (iPersonalityCount == 0)
+        {
+        // Add empty value
+        AddIconL (iPersonalityCount, aIconArray);
+        iUsbModeIndexes.Append(0);
+        aPopUpItems.AppendL(KNullDesC);
+        aListBox.AppendL(KUSBUIEmptyString);
+        aListBoxDefault.AppendL(KUSBUIEmptyString);
+        aListBoxActive.AppendL(KUSBUIEmptyString);
+        }
+    
+    CleanupStack::PopAndDestroy( usbActiveText ); 
+    CleanupStack::PopAndDestroy( usbDefaultText ); 
+    CleanupStack::PopAndDestroy( usbModeListBoxActive ); 
+    CleanupStack::PopAndDestroy( usbModeListBox ); 
+    CleanupStack::PopAndDestroy( &personalityIds ); 
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL() complete"));  
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::AddIconL()
+// creates the icon list 
+// 
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::AddIconL (TInt aMode, CArrayPtrFlat<CGulIcon>& aIconArray )
+    {
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::AddIconL()"));
+    TFileName usbUiIconFilename( KFileDrive );
+    usbUiIconFilename += KDC_APP_BITMAP_DIR;
+    usbUiIconFilename += KUSBUIconFileName;
+
+    switch (aMode)
+        {
+        case KUsbPersonalityIdPCSuite:
+        case KUsbPersonalityIdPCSuiteMTP:
+            CreateAndAppendIconL( KAknsIIDQgnPropUsbPcsuite,
+                    usbUiIconFilename,
+                    EMbmUsbuiQgn_prop_usb_pcsuite,
+                    EMbmUsbuiQgn_prop_usb_pcsuite_mask,
+                    aIconArray);
+            break;
+        case KUsbPersonalityIdMS:
+            CreateAndAppendIconL( KAknsIIDQgnPropUsbMemcLarge,
+                    usbUiIconFilename,
+                    EMbmUsbuiQgn_prop_usb_memc_large,
+                    EMbmUsbuiQgn_prop_usb_memc_large_mask,
+                    aIconArray);
+            break;
+        case KUsbPersonalityIdPTP:
+            CreateAndAppendIconL( KAknsIIDQgnPropUsbPrint,
+                    usbUiIconFilename,
+                    EMbmUsbuiQgn_prop_usb_print,
+                    EMbmUsbuiQgn_prop_usb_print_mask,
+                    aIconArray);
+            break;
+        case KUsbPersonalityIdMTP:
+            CreateAndAppendIconL( KAknsIIDQgnPropUsbMtp,
+                    usbUiIconFilename,
+                    EMbmUsbuiQgn_prop_usb_mtp,
+                    EMbmUsbuiQgn_prop_usb_mtp_mask,
+                    aIconArray);
+            break;
+        case KUsbPersonalityIdModemInst:
+            CreateAndAppendIconL( KAknsIIDQgnPropUsbModem,
+                    usbUiIconFilename,
+                    EMbmUsbuiQgn_prop_usb_modem,
+                    EMbmUsbuiQgn_prop_usb_modem_mask,
+                    aIconArray);
+            break;
+        default:
+            CreateAndAppendIconL( KAknsIIDQgnPropSetAppsUsb, 
+                    usbUiIconFilename, 
+                    EMbmUsbuiQgn_prop_set_apps_usb,
+                    EMbmUsbuiQgn_prop_set_apps_usb_mask,
+                    aIconArray);
+           break;
+       }
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::AddIconL() completed"));
+    }
+// ----------------------------------------------------
+// CUSBClassChangeUIPluginContainer::CreateAndAppendIconL
+// ----------------------------------------------------
+void CUSBClassChangeUIPluginModel::CreateAndAppendIconL( 
+    const TAknsItemID& aID,
+    const TDesC& aFileName,
+    const TInt aBitmapId,
+    const TInt aMaskId,
+    CArrayPtrFlat<CGulIcon>& aIconArray)
+    {    
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::CreateAndAppendIconL"));
+
+    CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(),
+                                    aID, aFileName, aBitmapId, aMaskId);
+    
+    CleanupStack::PushL(icon);    
+    aIconArray.AppendL(icon);
+    CleanupStack::Pop(icon);
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::CreateAndAppendIconL completed"));
+
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::GetPersonalityCount()
+// Informs the container, that a setting has changed. 
+// 
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginModel::PersonalityCount()
+    {
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t PersonalityCount= %d "), iPersonalityCount));
+       return iPersonalityCount;
+    }  
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::SettingChangedL()
+// Informs the container, that a setting has changed. 
+// 
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginModel::SettingChangedL( TUint32 /*aKey*/ )
+    {
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SettingChangedL()"));
+    
+    if ( iObserver )
+        {
+        iObserver->SettingChanged();  
+        }
+        
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SettingChangedL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// From MUSBOtgHostStateObserver
+// Handle Otg Id pin on/off notification
+// ----------------------------------------------------------------------------
+void CUSBClassChangeUIPluginModel::OtgHostIdPinStateChanged(TBool aIsIdPinOn)
+    {
+    iDeviceIDs.Reset();
+    if (iObserver)
+        {
+        iObserver->OtgHostIdPinStateChanged(aIsIdPinOn);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// From MUSBOtgHostStateObserver
+// Handle host event notification
+// ----------------------------------------------------------------------------
+void CUSBClassChangeUIPluginModel::HostEventNotify(TDeviceEventInformation aEventInfo)
+    {
+    if (iObserver)
+        {
+        FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::HostEventNotify"));        
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iDeviceId         = %d" ), aEventInfo.iDeviceId));
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iEventType        = %d" ), aEventInfo.iEventType));
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iError            = %d" ), aEventInfo.iError));
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iDriverLoadStatus = %d" ), aEventInfo.iDriverLoadStatus));
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iVid              = %d" ), aEventInfo.iVid));
+        FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iPid              = %d" ), aEventInfo.iPid));
+
+        switch (aEventInfo.iEventType)
+            {
+            case EDeviceAttachment:
+                {
+                iObserver->HostEventNotify(aEventInfo);
+                break;
+                }
+            case EDeviceDetachment:
+                {
+                TInt index = iDeviceIDs.Find(aEventInfo.iDeviceId);
+                if (index >= 0)
+                    {
+                     iDeviceIDs.Remove(index);
+                    }
+                iObserver->HostEventNotify(aEventInfo);
+                break;
+                }
+            case EDriverLoad:
+                {
+                switch (aEventInfo.iDriverLoadStatus)
+                    {
+                    case EDriverLoadSuccess:
+                    case EDriverLoadPartialSuccess:
+                        {
+                        // Drivers are loaded more or less successfully
+                        iDeviceIDs.Append(aEventInfo.iDeviceId);
+                        iObserver->HostEventNotify(aEventInfo);
+                        break;
+                        }
+                    }
+                break;
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Informs the observer that USB device state has changed.
+// ----------------------------------------------------------------------------
+void CUSBClassChangeUIPluginModel::DeviceStateChanged(
+    TUsbDeviceState aPreviousState, TUsbDeviceState aCurrentState)
+{
+    if (iObserver)
+        {
+            iObserver->DeviceStateChanged(aPreviousState, aCurrentState);
+        }
+}
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginModel::GetUsbIds()
+// Return an RArray of the personality indexes
+// 
+// ----------------------------------------------------------------------------
+//
+RArray<TInt>& CUSBClassChangeUIPluginModel::GetUsbIds()
+    {
+    return iUsbModeIndexes; 
+    }
+// ----------------------------------------------------------------------------
+// Returns if it's A-device and the driver to the attached pheripheral 
+// is loaded successfully(or partially). 
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginModel::HasPeripheralEnabled(TBool& aHasPeripheralEnabled)
+    {
+    aHasPeripheralEnabled = EFalse;
+#ifdef NO_USBWATCHER_USBMANAGER     ////UsbWatcher/UsbManager API N/A 
+    return KErrNone;
+#else
+    TBool idPinOn;
+    TInt ret = iOtgHostStateWatcher->IsIdPinOn(idPinOn);
+    if (ret != KErrNone || !idPinOn)
+        {
+        return ret;
+        }
+    
+    //aHasPeripheralEnabled = (iDeviceIDs.Count() > 0 ? ETrue : EFalse);
+    ret = iOtgHostStateWatcher->IsPeripheralConnected(aHasPeripheralEnabled); 
+    if (ret != KErrNone)
+        {
+        return ret;
+        }
+    
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::HasPeripheralEnabled - aHasPeripheralEnabled=%d"), aHasPeripheralEnabled));
+    
+    return KErrNone;
+#endif
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginView.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,566 @@
+/*
+* 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:  This the implementation of the view class
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <aknradiobuttonsettingpage.h>
+#include <akntitle.h>
+#include <bautils.h>         // BAFL utils (for language file)
+#include <StringLoader.h> 
+#include <usbui.mbg>
+#include <featmgr.h>
+#include <hlplch.h>         // Help launcher
+#include <usbpersonalityids.h>
+#include <gsparentplugin.h>
+#include <gsfwviewuids.h>
+#include <USBClassChangeUIPlugin.rsg> // Resources
+
+#include "USBClassChangeUIPluginView.h"
+#include "USBClassChangeUIPluginDebug.h"
+#include "USBClassChangeUIPlugin.h"
+#include "USBClassChangeUIPluginContainer.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::NewPluginL
+// Entry point for CGSPluginInterface.
+// Used by General Settings Application
+// ---------------------------------------------------------
+//
+CUSBClassChangeUIPluginView* CUSBClassChangeUIPluginView::NewPluginL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::NewPluginL()"));
+    
+    CUSBClassChangeUIPluginView* self = new ( ELeave ) CUSBClassChangeUIPluginView();
+    
+    self->iLoadAsGSPlugin = ETrue;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+       
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::NewPluginL() completed"));
+    
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::NewL
+// Entry point for CGSPluginInterface.
+// Used by USBClassChangeUIPluginAppUI.
+// ---------------------------------------------------------
+//
+CUSBClassChangeUIPluginView* CUSBClassChangeUIPluginView::NewL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::NewL()"));
+    
+    CUSBClassChangeUIPluginView* self = new ( ELeave ) CUSBClassChangeUIPluginView();
+    
+    self->iLoadAsGSPlugin = EFalse;
+     
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::NewL() completed"));
+    
+    return self;
+    }    
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::ConstructL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::ConstructL()"));
+
+    iEikEnv = CEikonEnv::Static();
+
+    TFileName filename;
+    filename += KFileDrive;
+    filename += KDC_RESOURCE_FILES_DIR; 
+    filename += KResourceFileName;
+    BaflUtils::NearestLanguageFile(iEikEnv->FsSession(),filename);
+    iResourceFileFlag = iEikEnv->AddResourceFileL(filename);
+    
+    //"Back" or "Exit" right-softkey resource
+    BaseConstructL( iLoadAsGSPlugin ? 
+        R_USBUI_MAIN_VIEW_GS_PLUGIN : R_USBUI_MAIN_VIEW );
+    
+    iAppUIRef = AppUi();
+    
+    iModelRef = CUSBClassChangeUIPluginModel::NewL();
+    iModelRef->SetSettingsObserver(this);
+
+    FeatureManager::InitializeLibL();
+    iHelpSupported = FeatureManager::FeatureSupported( KFeatureIdHelp );
+    FeatureManager::UnInitializeLib(); 
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::ConstructL() completed"));
+    }
+     
+// ---------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------
+//
+CUSBClassChangeUIPluginView::~CUSBClassChangeUIPluginView()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::~CUSBClassChangeUIPluginView()"));
+
+    if ( iContainer )
+        {
+        if ( iAppUIRef )
+            {
+            iAppUIRef->RemoveFromViewStack( *this, iContainer );
+            }
+        delete iContainer;
+            }
+
+    if ( iEikEnv )
+        {
+        iEikEnv->DeleteResourceFile ( iResourceFileFlag );
+        }
+    
+    if ( iModelRef )
+        {
+        delete iModelRef;    
+        }
+   
+    if ( !iLoadAsGSPlugin )
+        {
+        SignalDestruction();
+        }
+    
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::~CUSBClassChangeUIPluginView() completed"));
+    }
+    
+// ---------------------------------------------------------
+// TUid CUSBClassChangeUIPluginView::Id
+// ---------------------------------------------------------
+//
+TUid CUSBClassChangeUIPluginView::Id() const
+    {
+    if ( iLoadAsGSPlugin )
+    	{
+	    return KGsUSBUIPluginUid; //same as ecom impl UID, required by GS interface.
+    	}
+    else
+    	{
+    	return KUSBUIMainViewId;  //view id
+    	}
+    }
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::HandleCommandL
+// Redirects commands to the appui class.
+// ---------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::HandleCommandL(TInt aCommand)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::HandleCommandL()"));
+
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EEikCmdExit:
+            {
+            iAppUIRef->Exit();
+            break;
+            }
+        
+        case EAknSoftkeyBack:
+            /** 
+            * UPDATE THIS if this view has a sub-view. 
+            * In this case constant UID must be used instead of the
+            * previous view - otherwise the "back" might return to the 
+            * sub-view. See GSFWViewUIDs.h for constant UIDs.
+            */
+            iAppUIRef->ActivateLocalViewL( iPrevViewId.iViewUid );
+            break; 
+            
+        case EUSBUICmdHelp:
+        case EAknCmdHelp:
+            {
+            HlpLauncher::LaunchHelpApplicationL( 
+                iEikonEnv->WsSession(), iAppUIRef->AppHelpContextL() );
+            break;
+            }
+      
+        case EUSBUICmdSelect:
+        case EUSBUICmdMskSelect:
+            {
+             TInt CurrentIndex = iContainer->CurrentItemIndex() ;
+             HandleCmdChangeUSBModeL(CurrentIndex);
+             break;
+            }
+
+        default:
+            {
+            FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginAppUi::HandleCommandL default switch"));    
+            break;
+            }
+        }
+    }
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::DoActivateL
+// ---------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::DoActivateL( const TVwsViewId& aPrevViewId,
+                                 TUid /*aCustomMessageId*/,
+                                 const TDesC8& /*aCustomMessage*/)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DoActivateL()"));
+
+    iPrevViewId = aPrevViewId;
+    if( !iContainer )
+        {
+        iContainer = CUSBClassChangeUIPluginContainer::NewL(this, iModelRef);
+        iContainer->SetMopParent( this ); // MObjectProvider
+    
+        // Setup the title
+        //
+        HBufC* usbTitleMain = iCoeEnv->AllocReadResourceLC( R_USB_TITLE );
+        CEikStatusPane* statusPane = StatusPane();
+        CAknTitlePane* titlePane;
+        titlePane = ( CAknTitlePane* ) statusPane->ControlL(TUid::Uid( EEikStatusPaneUidTitle ));
+        titlePane->SetTextL( *usbTitleMain );
+        CleanupStack::PopAndDestroy(usbTitleMain);
+        iAppUIRef->AddToStackL( *this, iContainer );
+        }
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DoActivateL() completed"));
+    }
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::DoDeactivate
+// ---------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::DoDeactivate()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DoDeactivate()"));
+
+    if ( iContainer )
+        {
+        iAppUIRef->RemoveFromStack( iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+
+
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DoDeactivate() completed"));
+    }
+ 
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::GetCaptionL
+// Method for getting caption of this plugin.
+// ---------------------------------------------------------
+//   
+void CUSBClassChangeUIPluginView::GetCaptionL (TDes& aCaption) const
+    {   
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::GetCaptionL()")); 
+    // The resource file is already opened, see ConstructL()
+    //
+    HBufC* result = StringLoader::LoadL( R_GS_USBUI_VIEW_CAPTION );
+    aCaption.Copy( *result );
+    delete result;  
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::GetCaptionL() completed"));
+    }
+    
+// ---------------------------------------------------------
+// CUSBClassChangeUIPluginView::GetValue
+// Function for getting plugin's value for a certain key.
+// ---------------------------------------------------------
+//   
+void CUSBClassChangeUIPluginView::GetValue(const TGSPluginValueKeys aKey,
+                                           TDes& aValue)
+    {
+    switch( aKey )
+        {
+        case EGSPluginKeySettingsItemValueString:
+            {
+            // Get Id pin state of UsbOtg-capable device
+            TBool hasPeripheralEnabled = EFalse;
+            // Ignore error code
+            TInt ret = iModelRef->HasPeripheralEnabled(hasPeripheralEnabled);
+            FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::GetValue - HasPeripheralEnabled=%d"), ret));
+
+            TInt resId = 0;
+            if (hasPeripheralEnabled)
+                {
+                resId = R_CP_DETAIL_USB_OTG_CONN;
+                }
+            else if (IsUSBDeviceConnected())
+                {
+                TInt mode = USBMode();
+                switch (mode)
+                    {
+                    case KUsbPersonalityIdPCSuite:
+                    case KUsbPersonalityIdPCSuiteMTP:
+                        resId = R_CP_DETAIL_USB_CONN_PC_SUITE;
+                        break;
+                    case KUsbPersonalityIdMS:
+                        resId = R_CP_DETAIL_USB_CONN_MASS_STORAGE;
+                        break;
+                    case KUsbPersonalityIdPTP:
+                        resId = R_CP_DETAIL_USB_CONN_PICTURE_TRANSFER;
+                        break;
+                    case KUsbPersonalityIdMTP:
+                        resId = R_CP_DETAIL_USB_CONN_MEDIA_TRANSFER;
+                        break;
+                    case KUsbPersonalityIdModemInst:
+                        resId = R_CP_DETAIL_USB_CONN_MODEM_INST;
+                        break;
+					
+					case KUsbPersonalityIdRNDIS:
+                        resId = R_CP_DETAIL_USB_CONN_RNDIS;
+                        break;
+                    default:
+                        // Leave value empty
+                        break;
+                    }
+                }
+            else
+                {
+                resId = R_CP_DETAIL_USB_NOT_CONNECTED;
+                }
+
+            if (resId)
+                {
+                    TRAP_IGNORE(
+                        HBufC* text = StringLoader::LoadL(resId);
+                        aValue.Append(*text);
+                        delete text;
+                    );
+                }
+            }
+            break;
+
+        default:
+            CGSPluginInterface::GetValue(aKey, aValue);
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::SettingChanged()
+// A setting has been changed. 
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::SettingChanged()
+    {
+        if (iContainer)
+            {
+                iContainer->SettingChanged();
+            }
+
+        // Personality changes only affect USB UI when USB device is connected
+        if (IsUSBDeviceConnected())
+            {
+                UpdateParentView();
+            }
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::DeviceStateChanged()
+// USB device state has changed.
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::DeviceStateChanged(TUsbDeviceState /*aPrevState*/,
+                                                     TUsbDeviceState aState)
+    {
+		//Transitions to EUsbDeviceStateUndefined, EUsbDeviceStateConfigured 
+		//and EUsbDeviceStateAttached states update UI view.
+        if (aState == EUsbDeviceStateConfigured ||
+            aState == EUsbDeviceStateUndefined ||
+			aState == EUsbDeviceStateAttached)
+            {
+                UpdateParentView();
+                if (iContainer)
+                           {
+                               iContainer->SettingChanged();
+                           }
+            }
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::OtgHostIdPinStateChanged
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::OtgHostIdPinStateChanged(TBool aIsIdPinOn)
+    {
+    if (!aIsIdPinOn)
+        {
+        UpdateParentView();
+        }
+    // else, Ignore Id pin on event, host event to be checked further
+    }
+
+// ----------------------------------------------------------------------------
+// From MUSBOtgHostStateObserver
+// Handle host event notification
+// ----------------------------------------------------------------------------
+void CUSBClassChangeUIPluginView::HostEventNotify(TDeviceEventInformation /*aEventInfo*/)
+    {
+    UpdateParentView();
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::USBMode()
+// Gets the current USB mode from model
+// ----------------------------------------------------------------------------
+//
+TInt CUSBClassChangeUIPluginView::USBMode() const
+    {
+    return iModelRef->USBMode();
+    }
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::SetUSBModeL(TInt)
+// Sets the current USB mode through model
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::SetUSBModeL( TInt aMode )
+    {
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::SetUSBModeL()"));
+    
+    iModelRef->SetUSBModeL( aMode );
+    
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::SetUSBModeL complete"));
+    }   
+ 
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::CreateIconL()
+// Creates icon for General Settings application
+// ----------------------------------------------------------------------------
+//  
+CGulIcon* CUSBClassChangeUIPluginView::CreateIconL( const TUid aIconType )
+{
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::CreateIconL() - aIconType=0x%x"), aIconType.iUid));
+
+    CGulIcon* icon = NULL;
+        
+    if( aIconType == KGSIconTypeLbxItem )
+        {
+        TFileName usbUiIconFilename( KFileDrive );
+        usbUiIconFilename += KDC_APP_BITMAP_DIR;
+        usbUiIconFilename += KUSBUIconFileName;
+      
+
+        // Get peripheral connected state of UsbOtg-capable device
+        TBool hasPeripheralEnabled = EFalse;
+        TInt ret = iModelRef->HasPeripheralEnabled(hasPeripheralEnabled);
+        // In case of failure of getting the status, hasPeripheralEnabled is EFalse.
+        // So ignore the error code here.
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::CreateIconL - HasPeripheralEnabled=%d"), ret));
+
+        if (hasPeripheralEnabled || IsUSBDeviceConnected())
+            {
+            icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), 
+                KAknsIIDQgnPropSetAppsUsb, usbUiIconFilename, 
+                EMbmUsbuiQgn_prop_set_apps_usb, 
+                EMbmUsbuiQgn_prop_set_apps_usb_mask );
+            }
+        else
+            {
+            icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), 
+                KAknsIIDQgnPropSetAppsUsbOff, usbUiIconFilename, 
+                EMbmUsbuiQgn_prop_set_apps_usb_off, 
+                EMbmUsbuiQgn_prop_set_apps_usb_off_mask );
+            }
+        }
+    else 
+        {
+        icon = CGSPluginInterface::CreateIconL( aIconType );
+        }
+        
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::CreateIconL() completed"));
+    return icon;
+}
+
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::HandleCmdChangeUSBModeL()
+// sets the selected usb mode 
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::HandleCmdChangeUSBModeL(TInt aMode)
+    {
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::HandleCmdChangeUSBModeL()"));
+    const RArray<TInt> usbIndexes = iModelRef->GetUsbIds(); 
+    SetUSBModeL( usbIndexes[aMode] );
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::HandleCmdChangeUSBModeL() completed"));
+    }
+
+
+// ----------------------------------------------------------------------------
+// Remove Help from options menu, if the feature is not supported. 
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::DynInitMenuPaneL( TInt /*aResId*/, CEikMenuPane* aMenu )
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DynInitMenuPaneL()"));
+	//dim help if it is not supported and it exists
+	if (!iHelpSupported)
+	    {
+    	TInt tmp;
+        if (  aMenu->MenuItemExists(EUSBUICmdHelp, tmp) )
+            {			
+            aMenu->SetItemDimmed(EUSBUICmdHelp, ETrue);
+            }
+        }
+    FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginView::DynInitMenuPaneL() completed"));
+    }
+    
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::IsUSBDeviceConnected()
+// Checks whether USB device is connected.
+// ----------------------------------------------------------------------------
+//
+TBool CUSBClassChangeUIPluginView::IsUSBDeviceConnected()
+    {
+        TUsbDeviceState state = EUsbDeviceStateUndefined;
+        return (iModelRef->GetDeviceState(state) == KErrNone && 
+                state != EUsbDeviceStateUndefined);
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIPluginView::UpdateParentView()
+// Updates parent view if we are loaded by GS plugin.
+// Copied from irappgspluginview.cpp
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIPluginView::UpdateParentView()
+    {
+        if (iLoadAsGSPlugin)
+            {
+                // Note: GetActiveViewId returns KErrNotFound if GS application
+                // is running in the background.
+		        TVwsViewId vid;
+		        AppUi()->GetTopViewId(vid);
+		        if (vid.iViewUid == KGSConPluginUid)
+			        {
+			            CGSParentPlugin* parent;
+			            parent = (CGSParentPlugin*)AppUi()->View(vid.iViewUid);
+			            parent->UpdateView();
+			        }
+            }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBDeviceStateWatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,131 @@
+/*
+* 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:  Device state watcher class.
+ *
+*/
+
+
+// INCLUDE FILES
+#include "USBDeviceStateWatcher.h"
+
+// CONSTANTS
+const TUint KUsbAllStates = 0xFFFFFFFF;
+
+// --------------------------------------------------------------------------
+// Two-phased constructor. Uses existing usb manager session.
+// --------------------------------------------------------------------------
+CUSBDeviceStateWatcher*
+CUSBDeviceStateWatcher::NewL(MUSBDeviceStateObserver& aObserver, RUsb& aUsbMan)
+    {
+    CUSBDeviceStateWatcher* self = new(ELeave)CUSBDeviceStateWatcher(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL(aUsbMan);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// Two-phased constructor. Creates its own usb manager session.
+// --------------------------------------------------------------------------
+CUSBDeviceStateWatcher*
+CUSBDeviceStateWatcher::NewL(MUSBDeviceStateObserver& aObserver)
+    {
+    CUSBDeviceStateWatcher* self = new(ELeave)CUSBDeviceStateWatcher(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// C++ constructor
+// --------------------------------------------------------------------------
+CUSBDeviceStateWatcher::CUSBDeviceStateWatcher(MUSBDeviceStateObserver& aObserver) 
+    : CActive(EPriorityStandard), iObserver(aObserver)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------
+// C++ destructor
+// --------------------------------------------------------------------------
+CUSBDeviceStateWatcher::~CUSBDeviceStateWatcher()
+    {
+    Cancel();
+    }
+
+// --------------------------------------------------------------------------
+// Symbian 2nd phase constructor. Uses existing usb manager session. 
+// --------------------------------------------------------------------------
+void CUSBDeviceStateWatcher::ConstructL(RUsb& aUsbMan)
+    {
+    iUsbMan.SetHandleNC(aUsbMan.Handle()); // NC == NoClose
+    CommonConstructL();
+    }
+
+// --------------------------------------------------------------------------
+// Symbian 2nd phase constructor. Creates its own usb manager session. 
+// --------------------------------------------------------------------------
+void CUSBDeviceStateWatcher::ConstructL()
+    {
+    User::LeaveIfError(iUsbMan.Connect());
+    CommonConstructL();
+    }
+
+// --------------------------------------------------------------------------
+// Code shared by all ConstructL methods.
+// Usb manager session has already been set up.
+// --------------------------------------------------------------------------
+void CUSBDeviceStateWatcher::CommonConstructL()
+    {
+    User::LeaveIfError(iUsbMan.GetDeviceState(iCurrentState));
+    iPreviousState = iCurrentState;
+    iUsbMan.DeviceStateNotification(KUsbAllStates, iCurrentState, iStatus);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// The device state has changed.
+// --------------------------------------------------------------------------
+void CUSBDeviceStateWatcher::RunL()
+    {
+    if (iStatus == KErrNone)
+        {
+            if (iCurrentState != iPreviousState)
+                {
+                    iObserver.DeviceStateChanged(iPreviousState, iCurrentState);
+                    iPreviousState = iCurrentState;
+                }
+            iUsbMan.DeviceStateNotification(KUsbAllStates, iCurrentState, iStatus);
+            SetActive();
+        }
+    }
+ 
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+TInt CUSBDeviceStateWatcher::RunError(TInt /*aError*/)
+    {
+    // Currently no leaving functions called in RunL, thus nothing should cause
+    // this to be called -> return.
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+void CUSBDeviceStateWatcher::DoCancel()
+    {
+    iUsbMan.DeviceStateNotificationCancel();    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/usbotghoststatewatcher.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,334 @@
+/*
+* 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:  Device state watcher class.
+ *
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32property.h>
+#include <UsbWatcherInternalPSKeys.h>
+
+#include "usbotghoststatewatcher.h"
+#include "USBClassChangeUIPluginDebug.h"
+
+// --------------------------------------------------------------------------
+// Two-phased constructor. Uses existing usb manager session.
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher* 
+CUSBOtgHostStateWatcher::NewL(MUSBOtgHostStateObserver& aObserver, RUsb& aUsbMan)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgHostStateWatcher:NewL"));
+    
+    CUSBOtgHostStateWatcher* self = new(ELeave)CUSBOtgHostStateWatcher(aObserver, aUsbMan);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// C++ destructor
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::~CUSBOtgHostStateWatcher()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgHostStateWatcher:~CUSBOtgHostStateWatcher"));
+
+    delete iOtgIdPinWatcher;
+    delete iHostEventWatcher;
+    iPeripheral.Close();
+    }
+
+// --------------------------------------------------------------------------
+// Get Id pin state
+// --------------------------------------------------------------------------
+TInt CUSBOtgHostStateWatcher::IsIdPinOn(TBool& aIsIdPinOn)
+    {
+    return iOtgIdPinWatcher->IsIdPinOn(aIsIdPinOn);
+    }
+
+// --------------------------------------------------------------------------
+// Check wheather a pheripheral device is connected or not. 
+// --------------------------------------------------------------------------
+TInt CUSBOtgHostStateWatcher::IsPeripheralConnected(TBool &aIsConnected)
+    {
+    aIsConnected = EFalse;
+
+    TInt val(0);
+    TInt err = iPeripheral.Get(val);
+
+    if (KErrNone != err)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgHostStateWatcher::IsPeripheralConnected - err=%d"), err));
+        return err;
+        }
+    
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgHostStateWatcher::IsPeripheralConnected - val=%d"), val));
+    aIsConnected = (TBool)val;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// C++ constructor
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBOtgHostStateWatcher(
+        MUSBOtgHostStateObserver& aObserver, RUsb& aUsbMan) 
+    : iUsbMan(aUsbMan), iObserver(aObserver)
+    {
+    }
+
+// --------------------------------------------------------------------------
+// Symbian 2nd phase constructor. 
+// --------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::ConstructL()
+    {
+    iOtgIdPinWatcher = CUSBOtgIdPinStateWatcher::NewL(*this);
+    iHostEventWatcher = CUSBHostEventNotifWatcher::NewL(*this);
+    TInt ret = iPeripheral.Attach(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected);
+    if (ret != KErrNone)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgHostStateWatcher::ConstructL - iPeripheral.Attach err=%d"), ret));
+        User::Leave(ret);
+        }    
+    }
+
+
+// --------------------------------------------------------------------------
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher* 
+CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::NewL(CUSBOtgHostStateWatcher& aOtgHostStateWatcher)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::NewL"));
+
+    CUSBOtgIdPinStateWatcher* self = new(ELeave)CUSBOtgIdPinStateWatcher(aOtgHostStateWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// C++ destructor
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::~CUSBOtgIdPinStateWatcher()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::~CUSBOtgIdPinStateWatcher"));
+
+    Cancel();    
+    iIdPin.Close();
+    }
+
+// --------------------------------------------------------------------------
+// Get Id pin state
+// --------------------------------------------------------------------------
+TInt CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::IsIdPinOn(TBool& aIsIdPinOn)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::IsIdPinOn" ));
+
+    TInt val(0);
+    TInt err = iIdPin.Get(val);
+
+    if (KErrNone != err)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::IsIdPinOn - err=%d"), err));
+        return err;
+        }
+
+    FTRACE(FPrint(_L( "[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::IsIdPinOn=%d" ), val ));
+
+    // not found in docs clear definition of this property. Verification is needed   
+    aIsIdPinOn = (0 == val ? EFalse : ETrue);
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// The Id pin state has changed.
+// --------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::RunL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL"));
+
+    if (iStatus.Int() != KErrNone)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL - iStatus=%d"), iStatus.Int()));
+        User::Leave(iStatus.Int());
+        }    
+
+    // re-issue request first
+    iIdPin.Subscribe(iStatus);
+    SetActive();
+
+    TBool isIdPinOn;
+    TInt ret = IsIdPinOn(isIdPinOn);
+    if (ret != KErrNone)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL - IsIdPinOn=%d"), ret));
+        User::Leave(ret);
+        }    
+
+    if (isIdPinOn)
+        {
+        FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL IdPin ON"));
+
+        iOtgHostStateWatcher.iObserver.OtgHostIdPinStateChanged(ETrue);
+        }
+    else
+        {
+        FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL IdPin OFF"));
+
+        iOtgHostStateWatcher.iObserver.OtgHostIdPinStateChanged(EFalse);
+        }
+    }
+ 
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+TInt CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::RunL"), aError));
+
+    // Currently no leaving functions called in RunL, thus nothing should cause
+    // this to be called -> return.
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::DoCancel()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::DoCancel"));
+    
+    iIdPin.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::CUSBOtgIdPinStateWatcher(
+        CUSBOtgHostStateWatcher& aOtgHostStateWatcher)
+    : CActive(EPriorityStandard), iOtgHostStateWatcher(aOtgHostStateWatcher)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------
+// Symbian 2nd phase constructor. 
+// --------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBOtgIdPinStateWatcher::ConstructL()
+    {
+    TInt ret = iIdPin.Attach(KUidUsbManCategory, KUsbOtgIdPinPresentProperty);
+    if (ret != KErrNone)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBOtgIdPinStateWatcher::ConstructL - iIdPin.Attach error:%d"), ret));
+        User::Leave(ret);
+        }
+    
+    // Issue request first
+    iIdPin.Subscribe(iStatus);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher* 
+CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::NewL(CUSBOtgHostStateWatcher& aOtgHostStateWatcher)
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::NewL"));
+
+    CUSBHostEventNotifWatcher* self = new(ELeave)CUSBHostEventNotifWatcher(aOtgHostStateWatcher);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// C++ destructor
+// --------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::~CUSBHostEventNotifWatcher()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::~CUSBHostEventNotifWatcher"));
+
+    Cancel();    
+    }
+
+// --------------------------------------------------------------------------
+// The Id pin state has changed.
+// --------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::RunL()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::RunL"));
+
+    if (iStatus.Int() != KErrNone)
+        {
+        FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::RunL - iStatus=%d"), iStatus.Int()));
+        User::Leave(iStatus.Int());
+        }    
+
+    // Save current event
+    TDeviceEventInformation dei = iEventInfo;
+
+    // Re-issue request first
+    iOtgHostStateWatcher.iUsbMan.HostEventNotification(iStatus, iEventInfo);
+    SetActive();
+   
+    iOtgHostStateWatcher.iObserver.HostEventNotify(dei);    
+    }
+ 
+// ----------------------------------------------------------------------------
+// Standard active object error function.
+// ----------------------------------------------------------------------------
+TInt CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::RunL"), aError));
+
+    // Currently no leaving functions called in RunL, thus nothing should cause
+    // this to be called -> return.
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// Standard active object cancellation function.
+// ----------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::DoCancel()
+    {
+    FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBHostEventNotifWatcher::DoCancel"));
+    
+    iOtgHostStateWatcher.iUsbMan.HostEventNotificationCancel();
+    }
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::CUSBHostEventNotifWatcher(
+        CUSBOtgHostStateWatcher& aOtgHostStateWatcher)
+    : CActive(EPriorityStandard), iOtgHostStateWatcher(aOtgHostStateWatcher)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------
+// Symbian 2nd phase constructor. 
+// --------------------------------------------------------------------------
+void CUSBOtgHostStateWatcher::CUSBHostEventNotifWatcher::ConstructL()
+    {
+    iOtgHostStateWatcher.iUsbMan.HostEventNotification(iStatus, iEventInfo);
+    SetActive();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/aif/USBClassChangeUI_caption.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2005, 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:  Caption resource for USB UI.
+*
+*/
+
+
+#include "usbclasschangeui.loc"
+#include <apcaptionfile.rh>
+
+RESOURCE CAPTION_DATA
+    {
+    caption      = qtn_apps_usb_list;
+    shortcaption = qtn_apps_usb_grid;
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/aif/USBClassChangeUIaif.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2005, 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:  Application information resource file for USB UI.
+*
+*/
+
+
+#include <aiftool.rh>
+
+RESOURCE AIF_DATA
+    {
+    app_uid=0x102068E2;
+    num_icons=2;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/data/USBClassChangeUI.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2005, 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:  USB UI application resources.
+*
+*/
+
+
+#include <data_caging_paths_strings.hrh>
+
+//  RESOURCE IDENTIFIER
+NAME    USBC // 4 letter ID
+
+//  INCLUDES
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <appinfo.rh>
+
+#include <usbclasschangeui.loc>
+
+//  RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+// default file name for a document
+RESOURCE TBUF { buf = "USBCLASSCHANGEUI"; }
+
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+RESOURCE LOCALISABLE_APP_INFO r_usbclasschangeui_localisable_app_info
+    {
+    short_caption = qtn_apps_usb_grid;
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_apps_usb_list;
+        #ifdef __SCALABLE_ICONS
+        number_of_icons = 1;
+        icon_file = APP_BITMAP_DIR"\\usbclasschangeui_aif.mif";
+        #else
+        number_of_icons = 2; 
+        icon_file = APP_BITMAP_DIR"\\usbclasschangeui_aif.mbm"; 
+        #endif	
+        };
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/data/USBClassChangeUI_reg.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2005, 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:  USB UI application registration information.
+*
+*/
+
+
+#include <appinfo.rh>
+#include <USBClassChangeUI.rsg>
+#include <data_caging_paths_strings.hrh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x0102068E2
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "usbclasschangeui";
+
+    localisable_resource_file = APP_RESOURCE_DIR"\\usbclasschangeui";
+    localisable_resource_id = R_USBCLASSCHANGEUI_LOCALISABLE_APP_INFO;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/group/USBClassChangeUI.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2005, 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 project specification file for the USBClassChangeUI.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET              USBClassChangeUI.exe
+EPOCSTACKSIZE       0x5000
+TARGETTYPE  	    exe
+UID                 0x0 0x102068E2 
+
+
+VENDORID	VID_DEFAULT
+CAPABILITY	CAP_APPLICATION
+
+SOURCEPATH ../src
+SOURCE  USBClassChangeUIApp.cpp 
+SOURCE  USBClassChangeUIAppui.cpp
+SOURCE  USBClassChangeUIDocument.cpp
+
+
+START RESOURCE  ../data/USBClassChangeUI.rss
+TARGETPATH 	APP_RESOURCE_DIR
+HEADER
+LANGUAGE_IDS
+END
+
+START RESOURCE ../data/USBClassChangeUI_reg.rss
+DEPENDS usbclasschangeui.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+USERINCLUDE ../inc
+//for USBClassChangeUIPluginInterface.h
+USERINCLUDE ../USBClassChangeUIPlugin/inc
+
+SYSTEMINCLUDE         ../../inc ../../../inc     //for internal and private API headers
+MW_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib
+LIBRARY eikcore.lib 
+LIBRARY avkon.lib
+LIBRARY bafl.lib                            // Basic Application Framework 
+LIBRARY AknSkins.lib                        // Skinned icons
+LIBRARY aknicon.lib
+LIBRARY commonengine.lib                    // Series 60 common components library
+
+LIBRARY GSEcomPlugin.lib
+
+
+LIBRARY ecom.lib
+       
+DEBUGLIBRARY flogger.lib                    // File logging services
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2005, 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 project information required for 
+                  USB UI.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../loc/USBClassChangeUI.loc             MW_LAYER_LOC_EXPORT_PATH(usbclasschangeui.loc)
+../rom/USBClassChangeUI.iby             CORE_MW_LAYER_IBY_EXPORT_PATH(USBClassChangeUI.iby)
+../rom/USBClassChangeUIResources.iby    LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(USBClassChangeUIResources.iby)
+// Help exports
+#include "../help/group/bld.inf"
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE usbclasschangeui_aif.mif
+OPTION SOURCES -c8,8 qgn_menu_usb
+END
+
+PRJ_MMPFILES
+/*
+#ifdef __SCALABLE_ICONS
+    gnumakefile usbui_icons_aif_scalable_dc.mk
+#else 
+    gnumakefile usbui_icons_aif_bitmaps_dc.mk
+#endif
+*/
+../group/USBClassChangeUI.mmp
+
+// Define _USBUI_BLF_INF_INCLUDED_ to prevent duplicate export
+// of USBClassChangeUI.loc
+#define _USBUI_BLF_INF_INCLUDED_
+
+#include "../USBClassChangeUIPlugin/group/bld.inf"
+
+
+PRJ_TESTMMPFILES
+// None
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/group/usbui_Icons_aif_scalable_dc.mk	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2005,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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\usbclasschangeui_aif.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_usb.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/group/usbui_icons_aif_bitmaps_dc.mk	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,52 @@
+#
+# 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\usbclasschangeui_aif.mbm
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_usb_lst.bmp \
+		/c8,8 qgn_menu_usb_cxt.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+  
\ No newline at end of file
Binary file usbuis/usbui/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/help/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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:
+* Export help related files.
+*
+*/
+
+#include <platform_paths.hrh>				
+PRJ_EXPORTS
+:zip ../data/xhtml.zip   /epoc32/data/z/resource/ overwrite
+:zip ../data/xhtml.zip   /epoc32/winscw/c/resource/ overwrite
+
+../inc/usb.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/usb.hlp.hrh)
+../rom/usbuihelps_variant.iby		CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(usbuihelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/help/inc/usb.hlp.hrh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:
+*
+*/
+	
+//
+// usb.hlp.hrh generated by CSXHelp Utilities.
+//           
+
+#ifndef __USB_HLP_HRH__
+#define __USB_HLP_HRH__
+
+_LIT(KUSB_HLP_MAIN, "USB_HLP_MAIN"); // 
+_LIT(KUSB_HLP_PRINT_SETTINGS, "USB_HLP_PRINT_SETTINGS"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/help/rom/usbuihelps_variant.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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:
+ *
+ */
+
+#ifndef __USBUIHELPS_VARIANT_IBY__
+#define __USBUIHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE) && defined(__USB)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x102068E2\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x102068E2\contents.zip)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x102068E2\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x102068E2\index.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x102068E2\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x102068E2\keywords.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x102068E2\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x102068E2\meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/inc/USBClassChangeUI.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005, 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:  Common declarations for USBClassChange classes
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUI_H
+#define USBCLASSCHANGEUI_H
+
+#include <e32svr.h> 	// For RDebug and Panic
+
+// Application name
+//
+_LIT( KUSBUIAppName, "USBUI" );
+
+// UID of the application
+//
+const TUid KUidUSBClassChangeUI = { 0x102068E2 };
+
+// MACROS
+//
+#define PANIC( aPanic ) User::Panic( KUSBUIAppName, aPanic )
+
+// UID of the General Settings Plugin
+const TUid KGsUSBUiPluginUid = { 0x1020E473 };
+
+#endif //USBCLASSCHANGEUI_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/inc/USBClassChangeUIApp.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2005, 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:  Declares main application class.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIAPP_H
+#define USBCLASSCHANGEUIAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+#include "USBClassChangeUI.h"
+
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* CUSBCLASSCHANGEUIAPP application class.
+* Provides factory to create concrete document object.
+*
+*/
+class CUSBClassChangeUIApp : public CAknApplication
+    {
+    private:
+
+        /**
+        * From CAknApplication, creates CUSBClassChangeUIDocument document
+        * object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+
+        /**
+        * From CAknApplication, returns application's UID (KUidUSBUI).
+        * @return The value of KUidUSBClassChangeUI.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/inc/USBClassChangeUIAppUi.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2005, 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:  Declares UI class for application.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIAPPUI_H
+#define USBCLASSCHANGEUIAPPUI_H
+
+// INCLUDES
+#include <aknappui.h>
+#include <aknViewAppUi.h>
+
+
+// FORWARD DECLARATIONS
+class CUSBClassChangeUIView;
+class CUSBClassChangeUIModel;
+
+// CLASS DECLARATION
+
+/**
+*  AppUI class.
+*
+*  @lib 
+*  @since Series 60 3.0
+*/
+class CUSBClassChangeUIAppUi : public CAknViewAppUi
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor
+        */
+        virtual ~CUSBClassChangeUIAppUi();
+        
+    public: // Functions from base classes
+
+        /**
+        * From CAknViewAppUi Handles user commands.
+        *
+        * @param aCommand A command id.        
+        * @return None.
+        */
+        void HandleCommandL(TInt aCommand);
+
+    public: // New functions
+		
+     
+        
+    private: // New functions
+    
+        /**
+        * Handles the "No USB mode active" state in startup.
+        * @since Series 60 3.0
+        * @param None.
+        * @return None.
+        */
+        void NoUSBModeActiveL();
+        
+    private: // Data
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/inc/USBClassChangeUIDebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2005, 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 defines logging macros for USB Class
+*                Change UI
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIDEBUG_H
+#define USBCLASSCHANGEUIDEBUG_H
+ 
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+
+//The curly braces and the usual semicolon after the macro call cause
+//a harmless extra null statement. 
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"usbclasschangeuilog.txt");
+_LIT(KLogDir,"USBUI");
+
+//Declare the FPrint function with variable number of arguments.
+inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend,
+        aFmt, list);
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+//Debug message printing function with variable number of arguments. 
+inline void FPrint(const TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    TInt tmpInt = VA_ARG(list, TInt);
+    TInt tmpInt2 = VA_ARG(list, TInt);
+    TInt tmpInt3 = VA_ARG(list, TInt);
+    VA_END(list);
+    RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
+    }
+
+//Debug message printing function with variable number of arguments. 
+inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+    {
+
+	VA_LIST list;
+	VA_START(list, aFmt);
+    TBuf8<256> buf8;
+	buf8.AppendFormatList(aFmt, list);
+
+    TBuf16<256> buf16(buf8.Length());
+    buf16.Copy(buf8);
+
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    }
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // USBCLASSCHANGEUIDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/inc/USBClassChangeUIDocument.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2005, 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:  Declares document for application.
+*
+*/
+
+
+#ifndef USBCLASSCHANGEUIDOCUMENT_H
+#define USBCLASSCHANGEUIDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+
+class CEikAppUi;
+class CUSBClassChangeUIModel;
+
+// CLASS DECLARATION
+
+/**
+*  This class is a base class mandatory for all Symbian OS UI applications.
+*
+*  @lib
+*  @since Series 60 3.0
+*/
+class CUSBClassChangeUIDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+
+		
+	    /**
+        * C++ default constructor.
+        */
+        CUSBClassChangeUIDocument( 
+            CEikApplication& aApp ): CAknDocument( aApp ){ }
+		
+		
+	    /**
+        * Destructor.
+        */
+        virtual ~CUSBClassChangeUIDocument();
+        
+    public:		// New functions
+	
+	private: // Functions from base classes
+
+	    /**
+        * From CEikDocument, to create CUSBClassChangeUiAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+	
+	private:
+	
+        
+	private:	// Data	
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/loc/USBClassChangeUI.loc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* 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:  This is a localisation file for USB UI application.
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+
+// *** CAPTION STRINGS ***
+
+// d: USB Class Change UI application name on the application shell's app. list
+// l: list_single_large_graphic_pane_t1
+// r: 3.0
+//
+#define qtn_apps_usb_list "USB"
+
+// d: USB Class Change UI application name on the application shell's app. grid
+// l: cell_app_pane_t1
+// r: 3.0
+//
+#define qtn_apps_usb_grid "USB"
+
+// d: USB Setting folder caption 
+// l: list_single_large_graphic_pane_t1
+// r: 3.1
+#define qtn_set_folder_usb "USB"
+
+
+// *** TITLES ***
+
+// d: Status pane title for main view
+// l: title_pane_t2/opt9
+// r: 3.0
+//
+#define qtn_usb_title "USB"
+
+// *** SECONDARY STATUS INFORMATION ***
+
+// d: Secondary status information when not connected
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_not_connected "Not connected"
+
+// d: Shown when USB is connected and the phone is functioning as a USB OTG host.
+// l: list_double_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_otg_conn "Connected"
+
+// d: Secondary status information when connected in mass storage mode
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_conn_mass_storage "Mass storage mode"
+
+// d: Secondary status information when connected in Ovi suite mode
+// l: list_double_large_graphic_pane_t2
+// r: 5.2
+//
+#define qtn_cp_detail_usb_conn_ovi_suite "Ovi suite mode"
+
+// d: Secondary status information when connected in image print mode
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_conn_picture_transfer "Image print mode"
+
+// d: Secondary status information when connected in media transfer mode
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_conn_media_transfer "Media transfer mode"
+
+// d: Secondary status information when connect to internet mode
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_conn_modem_inst "Connect to internet mode"
+
+// d: Secondary status information when connected in RNDIS mode, not to be localized
+// l: list_double_large_graphic_pane_t2
+// r: 5.0
+//
+#define qtn_cp_detail_usb_conn_rndis "Connect PC with RNDIS mode"
+
+// d: Secondary status information in the USB UI setting list when the mode is a default mode
+// l: list_double_large_graphic_pane_t2_cp2
+// r: 5.2
+#define qtn_usb_settings_default "Default"
+
+// d: Secondary status information in the USB UI setting list when the mode is selected and cable is connected
+// l: list_double_large_graphic_pane_t2_cp2
+// r: 5.2
+#define qtn_usb_settings_active "Active"
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/rom/USBClassChangeUI.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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 __USBCLASSCHANGEUI_IBY__
+#define __USBCLASSCHANGEUI_IBY__
+
+#ifdef __USB_MULTIPERSONALITY 
+
+S60_APP_EXE(usbclasschangeui)
+
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,usbui)
+S60_APP_AIF_ICONS(usbclasschangeui)
+S60_APP_AIF_RSC(usbclasschangeui)
+
+//ECom Plugin
+ECOM_PLUGIN(USBClassChangeUIPlugin.dll, 1020E472.rsc)
+
+
+#endif // __USB_MULTIPERSONALITY
+#endif // __USBCLASSCHANGEUI_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/rom/USBClassChangeUIResources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* 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 __USBCLASSCHANGEUIRESOURCES_IBY__
+#define __USBCLASSCHANGEUIRESOURCES_IBY__
+
+#ifdef __USB_MULTIPERSONALITY 
+
+//USBClassChangeUI
+data=DATAZ_\APP_RESOURCE_DIR\USBClassChangeUI.RSC    APP_RESOURCE_DIR\USBClassChangeUI.rsc
+
+//USBClassChangeUIPlugin
+data=DATAZ_\RESOURCE_FILES_DIR\USBClassChangeUIPlugin.rsc RESOURCE_FILES_DIR\USBClassChangeUIPlugin.rsc
+
+#endif // __USB_MULTIPERSONALITY
+#endif // __USBCLASSCHANGEUIRESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/src/USBClassChangeUIApp.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2005, 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 implementation of application class.
+*
+*/
+
+
+// INCLUDE FILES
+#include    "USBClassChangeUIApp.h"
+#include    "USBClassChangeUIDocument.h"
+#include    <eikstart.h>
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIApp::AppDllUid()
+// Returns application UID
+// ----------------------------------------------------------------------------
+//
+TUid CUSBClassChangeUIApp::AppDllUid() const
+    {
+    return KUidUSBClassChangeUI;
+    }
+   
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIApp::CreateDocumentL()
+// Creates CUSBClassChangeUIDocument object
+// ----------------------------------------------------------------------------
+//
+CApaDocument* CUSBClassChangeUIApp::CreateDocumentL()
+    {
+    CUSBClassChangeUIDocument* doc = 
+        new ( ELeave ) CUSBClassChangeUIDocument( *this );
+    return doc; 
+    
+    }
+    
+// ================= OTHER EXPORTED FUNCTIONS =================================   
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CUSBClassChangeUIApp;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/src/USBClassChangeUIAppui.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2005, 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:  Implementation of AppUI class
+*
+*/
+
+
+// INCLUDE FILES
+
+#include    "USBClassChangeUIAppUi.h"
+#include    "USBClassChangeUIDocument.h"
+#include    "USBClassChangeUIDebug.h"
+#include    "USBClassChangeUIPluginInterface.h"
+
+#include    <avkon.hrh>
+
+#include    <gsplugininterface.h>
+
+const TUid KUidImpl = { 0x1027478F };   // implementation UID of the plugin
+
+// ================= MEMBER FUNCTIONS =========================================
+//
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIAppUi::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIAppUi::ConstructL()
+    {
+    FLOG(_L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::ConstructL()"));
+    
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK |EAknSingleClickCompatible);
+    
+    // Create the view using the GSPluginInterface
+    //   
+    CUSBClassChangeUIPluginInterface* mainView = 
+        CUSBClassChangeUIPluginInterface::NewL( KUidImpl, this );
+    
+    CleanupStack::PushL( mainView );
+    AddViewL( mainView ); // Transfer ownership to CAknViewAppUi
+    CleanupStack::Pop( mainView );
+    
+    ActivateLocalViewL( mainView->Id() );
+        
+    FLOG( _L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::ConstructL complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIAppUi::~CUSBUIAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------------------------------
+//
+CUSBClassChangeUIAppUi::~CUSBClassChangeUIAppUi()
+    {
+    FLOG( _L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::Destructor (empty) complete"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIAppUi::HandleCommandL(TInt aCommand)
+// Takes care of command handling
+// ----------------------------------------------------------------------------
+//
+void CUSBClassChangeUIAppUi::HandleCommandL(TInt aCommand)
+    {
+    FLOG( _L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::HandleCommandL()"));
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }    
+         
+        default:
+            {
+            FLOG( _L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::HandleCommandL default switch"));    
+            break;
+            }   
+        }
+        
+    FLOG( _L("[CUSBClassChangeUI]\t CUSBClassChangeUIAppUi::HandleCommandL complete"));
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/src/USBClassChangeUIDocument.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005, 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 implementation of document class.
+*
+*/
+
+
+// INCLUDE FILES
+#include "USBClassChangeUIDocument.h"
+#include "USBClassChangeUIAppUi.h"
+#include "USBClassChangeUIDebug.h"
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUSBClassChangeUIDocument::~CUSBClassChangeUIDocument()
+    {  
+    FLOG(_L("[CUSBClassChangeUI]\t CUSBClassChangeUIDocument::Destructor (empty) completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBClassChangeUIDocument::CreateAppUiL()
+// Constructs CUSBClassChangeUIAppUi
+// ----------------------------------------------------------------------------
+//
+CEikAppUi* CUSBClassChangeUIDocument::CreateAppUiL()
+    {
+    FLOG(_L("[CUSBClassChangeUI]\t CUSBClassChangeUIDocument::CreateAppUiL()"));
+    
+    return new ( ELeave ) CUSBClassChangeUIAppUi;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/bmarm/usbuiapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/bwins/usbuiapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbuis/usbui/tsrc/usbuiapitest/conf/ui_usbuiapitest.cfg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,399 @@
+/*
+* 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:  Test script config file
+*
+*/
+
+// USBUiApiTest Module - total ... tc
+
+// USBUiApiTest Api Tests (... tc)
+
+//[Test]
+//title Example Api Test
+//create USBUiApiTest tester
+//tester ExecuteApiTestBlock ExampleTestL API option 1 a
+//delete tester
+//[Endtest]
+
+// USB UI tests -  total 14 tc
+/////////////////////
+//Ovi->MS
+[Test]
+title Change USB Connection Ovi Suite to MS Manual/KeyDown
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+
+[Test]
+title Change USB Connection Ovi Suite to MS Manual/KeyUp
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow	//OVI
+pause 500
+presskey global EKeyUpArrow	//MODEM
+pause 500
+presskey global EKeyUpArrow	//MTP
+pause 500
+presskey global EKeyUpArrow	//MS
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+/////////////////////////
+//Ovi->MTP
+[Test]
+title Change USB Connection Ovi Suite to MTP Manual/KeyUp
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow	//OVI
+pause 500
+presskey global EKeyUpArrow	//MODEM
+pause 500
+presskey global EKeyUpArrow	//MTP
+pause 500
+presskey global EKeyEnter	
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP
+delete tester
+[Endtest]
+
+[Test]
+title Change USB Connection Ovi Suite to MTP Manual/KeyDown
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+pause 500
+presskey global EKeyDownArrow	//MTP
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP
+delete tester
+[Endtest]
+/////////////////////////
+//MS->Ovi
+[Test]
+title Change USB Connection MS to Ovi Suite Manual
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow	//OVI
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE
+delete tester
+[Endtest]
+/////////////////////////
+//MS->MTP
+[Test]
+title Change USB Connection MS to MTP Manual
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+pause 500
+presskey global EKeyDownArrow	//MTP
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP
+delete tester
+[Endtest]
+/////////////////////////
+//MTP->Ovi
+[Test]
+title Change USB Connection MTP to Ovi Suite Manual/KeyDown
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE
+delete tester
+[Endtest]
+/////////////////////////
+//MTP->MS
+[Test]
+title Change USB Connection MTP to MS Manual/KeyDown
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+/////////////////////////
+//OVI->MODEM
+[Test]
+title Change USB Connection OVI to Modem Manual/KeyDown
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+pause 500
+presskey global EKeyDownArrow	//MTP
+pause 500
+presskey global EKeyDownArrow	//MODEM
+pause 500
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MODEM
+delete tester
+[Endtest]
+/////////////////////////
+//MODEM->OVI
+[Test]
+title Change USB Connection Modem to MS Options Menu/KeyUp
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MODEM
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow	//OVI
+pause 500
+presskey global EKeyUpArrow	//MODEM
+pause 500
+presskey global EKeyUpArrow	//MTP
+pause 500
+presskey global EKeyUpArrow	//MS
+pause 500
+presskey global EKeyDevice0
+pause 1000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+/////////////////////////
+//Change In Options Menu
+//MS->MTP
+[Test]
+title Change USB Connection MS to MTP Change In Options Menu
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDownArrow	//MS
+pause 500
+presskey global EKeyDownArrow	//MTP
+pause 500
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP
+delete tester
+[Endtest]
+/////////////////////////
+//MTP->Ovi
+[Test]
+title Change USB Connection MTP to Ovi Suite Change In Options Menu
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE
+delete tester
+[Endtest]
+/////////////////////////
+//Ovi->MS
+[Test]
+title Change USB Connection Ovi Suite to MS Change In Options Menu
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI	
+pause 500
+presskey global EKeyDownArrow	//MS	
+pause 500
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+/////////////////////////
+//Exit
+[Test]
+title USB Application Exit/Device Key 1 Exit
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDevice1
+pause 2000
+tester ExecuteApiTestBlock FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//OPTIONS Cancel / EXIT
+[Test]
+title USB Application Cancelled/Options Key 1 Exit
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp  OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDevice0	//OPTIONS
+pause 500
+presskey global EKeyDevice1	//CANCEL OPTIONS
+pause 500
+presskey global EKeyDevice1	//EXIT
+pause 2000
+tester ExecuteApiTestBlock FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//EXIT WHEN NOT SELECTED
+[Test]
+title USB Application Exit/Options Menu Exit nothing selected
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp  OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDevice0		//OPTIONS/HELP
+pause 500
+presskey global EKeyDownArrow	//EXIT
+pause 500	
+presskey global EKeyDevice0		//SELECT EXIT
+pause 2000
+tester ExecuteApiTestBlock FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//EXIT WHEN SELECTED
+[Test]
+title USB Application Exit/Options Menu Exit Ovi Suite selected
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp  OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow	//OVI
+pause 500	
+presskey global EKeyDevice0	//OPTIONS/SELECT
+pause 500
+presskey global EKeyDownArrow	//Help
+pause 500
+presskey global EKeyDownArrow	//EXIT
+pause 500	
+presskey global EKeyDevice0		//SELECT EXIT
+pause 2000
+tester ExecuteApiTestBlock FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//Help
+[Test]
+title USB Application Help Option Entered/Key 1 Exit
+create USBUiApiTest tester
+tester ExecuteApiTestBlock LaunchUsbUiApp  OFF PCSUITE
+tester ExecuteApiTestBlock TurnLightsOn
+pause 4000
+presskey global EKeyDevice0	//OPTIONS
+pause 500
+presskey global EKeyEnter	//ENTER HELP 
+pause 5000
+presskey global EKeyDevice1	//KEY EXIT HELP
+pause 500
+presskey global EKeyDevice1	//KEY EXIT USB
+pause 2000
+tester ExecuteApiTestBlock FinishTest CANCELLED
+delete tester
+[Endtest]
+
+// Add new api tests here
+// ...
+
+
+// USBUiApiTest Module Tests (... tc)
+
+
+// Add new module tests here
+// ...
+
+
+// USBUiApiTest Branch Tests (... tc)
+
+
+// Add new branch tests here
+// ...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/eabi/usbuiapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/Bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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:
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+USBUiApiTest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/build_sis_ats.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+rem
+rem Copyright (c) 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:
+rem
+
+rd /S /Q \epoc32\BUILD
+del usbuiapitest.sisx
+call bldmake bldfiles
+call abld reallyclean armv5
+call abld test build armv5
+call makesis usbuiapitest.pkg
+call signsis usbuiapitest.sis usbuiapitest.sisx x:\rd.cer x:\rd-key.pem
+
+del usbuiapitest.sis
+
+call pause
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/build_sis_phone.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+rem
+rem Copyright (c) 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:
+rem
+
+rd /S /Q \epoc32\BUILD
+del usbuiapitest_phone.sisx
+call bldmake bldfiles
+call abld reallyclean armv5
+call abld test build armv5
+call makesis usbuiapitest_phone.pkg
+call signsis usbuiapitest_phone.sis usbuiapitest_phone.sisx x:\rd.cer x:\rd-key.pem
+
+del usbuiapitest_phone.sis
+
+call pause
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:  TYPE TESTSCRIPT
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          usbuiapitest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         usbuiapitest.def
+
+//#define ATS
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE	../inc 
+USERINCLUDE	../../../inc
+
+SOURCEPATH      ../src
+SOURCE          usbuiapitest.cpp
+SOURCE          usbuiapitestblocks.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY		centralrepository.lib
+LIBRARY 	apparc.lib
+LIBRARY 	apgrfx.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+;
+; 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:  Installation file for STIF
+;
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.2
+[0x20022E6D], 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/usbuiapitest.dll"-"c:/Sys/Bin/usbuiapitest.dll"
+
+"../init/usbuiapitest.ini"-"e:/testing/init/usbuiapitest.ini"
+"../conf/ui_usbuiapitest.cfg"-"e:/testing/conf/ui_usbuiapitest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest_phone.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+;
+; 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:  Installation file for STIF
+;
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.2
+[0x20022E6D], 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/urel/usbuiapitest.dll"-"c:/Sys/Bin/usbuiapitest.dll"
+
+"../init/usbuiapitest_phone.ini"-"c:/testframework/testframework.ini"
+"../conf/ui_usbuiapitest.cfg"-"c:/testframework/ui_usbuiapitest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitest.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,259 @@
+/*
+* 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:
+*
+*/
+
+
+
+
+#ifndef USBUIAPITEST_H
+#define USBUIAPITEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include "coreapplicationuisdomainpskeys.h"
+#include <SettingsInternalCRKeys.h>
+#include <centralrepository.h>
+#include <apgcli.h>
+#include <apacmdln.h>
+#include <UsbWatcherInternalCRKeys.h>
+#include <usbpersonalityids.h>
+
+#include "USBClassChangeUI.h"
+// CONSTANTS
+_LIT( KUsbAppFileName, "usbclasschangeui" );
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Logging path
+//_LIT( KUSBUiApiTestLogPath, "\\logs\\testframework\\USBUiApiTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+_LIT( KUSBUiApiTestLogPath, "e:\\testing\\stiflogs\\" ); 
+
+// Log file
+_LIT( KUSBUiApiTestLogFile, "USBUiApiTest.txt" ); 
+_LIT( KUSBUiApiTestLogFileWithTitle, "USBUiApiTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CUSBUiApiTest;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TUSBUiApiTestResult
+    {
+    ETestCasePassed,
+    ETestCaseFailed
+    };
+
+enum TUSBAppTestOption
+    {
+    EAppCancelled = 0,
+    EAskOnConnectionSettingChanged,//1
+    EUsbConnectionModeSettingChanged//2
+    };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( TUSBUiApiTestBlockParams )
+    {
+    public:
+        TPtrC iTestBlockName;
+        
+        TPtrC iTestOption1;
+        TPtrC iTestOption2;
+        TPtrC iTestOption3;
+        
+        TInt iTestIntOption1;
+        TInt iTestIntOption2;
+        
+        TChar iTestCharOption1;
+        TChar iTestCharOption2;
+    };
+
+/**
+*  CUSBUiApiTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS( CUSBUiApiTest ) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CUSBUiApiTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUSBUiApiTest();
+
+    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.
+        */
+        CUSBUiApiTest( 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, TUSBUiApiTestResult& aTestResult );    	
+    	void DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult );    
+    	void DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult );
+    	
+        void ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+                 TInt aTestIntOption, TInt aTestCharOption, TUSBUiApiTestResult& aTestResult );
+
+        virtual TInt LaunchUsbUiApp( TPtrC aTestOption, TPtrC aTestSubOption, TUSBUiApiTestResult& aTestResult );
+        virtual TInt FinishTest( TPtrC aTestOption, TPtrC aTestSubOption, TPtrC aTestSubOption2, TUSBUiApiTestResult& aTestResult );
+        TInt GetTestOption( TPtrC aOptionString, TUSBAppTestOption& aOption );
+        TInt GetAskOnConnectionOptionFromString( TPtrC aOptionString, TInt& aOption );
+        TInt GetUsbPersonalityOptionFromString( TPtrC aOptionString, TInt& aOption );
+        TBool IsUsbAppRunning();
+        TInt GetUsbSettings( TInt& aUsbPersinalityId, TInt& aAskOnConnectionSetting );
+        TInt SetUsbSettings( TInt aUsbPersinalityId, TInt aAskOnConnectionSetting );
+
+        TInt TurnLightsOn( );   
+
+
+
+        inline void Trace(TRefByValue<const TDesC8> aFmt, ...);
+        inline void Trace(TRefByValue<const TDesC16> aFmt, ...);
+	
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        TUSBUiApiTestBlockParams iTestBlockParams;
+        
+        RApaLsSession iApaLsSession;
+        
+        CApaCommandLine *iCommandLine;
+        CRepository *iRepository;
+        
+        TSecureId iUsbAppSecureId;
+        TInt iAskOnConnectionSettingBackup;
+        TInt iUsbPersonalityBackup;
+        TInt iTestAskOnConnectionSetting;
+        TInt iTestUsbPersonality;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+        
+    };
+
+#include "USBUiApiTestDebug.inl"
+
+#endif      // USBUIAPITEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitestdebug.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* 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 <e32debug.h>
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/) {}
+    }; 
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/) {}
+    };
+
+
+_LIT8(KStifTestPrefix8, "[STIF_LOG] ");
+_LIT(KStifTestPrefix, "[STIF_LOG] ");
+
+const TInt KMaxLogLineLength = 512;
+
+#define TRACE_INFO(p) { Trace p; }
+
+void CUSBUiApiTest::Trace(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TOverflowTruncate8 overflow;        
+	RBuf8 buf8;
+	buf8.Create( KMaxLogLineLength );
+	buf8.Append( KStifTestPrefix8 );
+	buf8.AppendFormatList(aFmt, list, &overflow);
+			
+	RBuf16 buf16;
+	buf16.Create( KMaxLogLineLength );
+	buf16.Copy(buf8);    
+	TRefByValue<const TDesC> tmpFmt(_L("%S"));
+	RDebug::Print(tmpFmt, &buf16);
+	iLog->Log(tmpFmt, &buf16);
+	buf8.Close();         
+	buf16.Close();
+	};
+
+void CUSBUiApiTest::Trace(TRefByValue<const TDesC16> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list,aFmt);
+	RBuf16 theFinalString;
+	theFinalString.Create( KMaxLogLineLength );
+	theFinalString.Append( KStifTestPrefix );
+	TOverflowTruncate16 overflow;
+	theFinalString.AppendFormatList(aFmt,list,&overflow);
+	RDebug::Print(theFinalString);
+	iLog->Log(theFinalString);
+	theFinalString.Close(); 
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -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= USBUiApiTest_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= USBUiApiTestUSBUiApiTestUSBUiApiTest
+# 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\ui_USBUiApiTest.cfg
+[End_Module]
+
+
+# Load testmoduleUSBUiApiTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBUiApiTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBUiApiTest 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/usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest_phone.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -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\USBUiApiTest\
+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= USBUiApiTestUSBUiApiTestUSBUiApiTest
+# 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\ui_USBUiApiTest.cfg
+[End_Module]
+
+
+# Load testmoduleUSBUiApiTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUSBUiApiTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUSBUiApiTest 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/usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitest.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,205 @@
+/*
+* 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:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "USBUiApiTest.h"
+#include <SettingServerClient.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::CUSBUiApiTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUSBUiApiTest::CUSBUiApiTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUSBUiApiTest::ConstructL()
+    {
+    //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(KUSBUiApiTestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KUSBUiApiTestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KUSBUiApiTestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    SendTestClassVersion();
+
+    iCommandLine = CApaCommandLine::NewL();
+    iUsbAppSecureId = TSecureId( KUidUSBClassChangeUI );
+    iRepository = CRepository::NewL( KCRUidUsbWatcher );
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBUiApiTest* CUSBUiApiTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CUSBUiApiTest* self = new (ELeave) CUSBUiApiTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CUSBUiApiTest::~CUSBUiApiTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+//-----------------------------------------------------------------------------
+// CUSBUiApiTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CUSBUiApiTest::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("USBUiApiTest.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* ) CUSBUiApiTest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitestblocks.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,701 @@
+/*
+* 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:
+*
+*/
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "USBUiApiTest.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CUSBUiApiTest::Delete() 
+    {
+    iApaLsSession.Close();
+    delete iCommandLine;
+    iCommandLine = NULL;
+    delete iRepository;
+    iRepository = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CUSBUiApiTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+	    ENTRY( "ExecuteApiTestBlock", CUSBUiApiTest::ExecuteApiTestBlock ),
+        ENTRY( "ExecuteModuleTestBlock", CUSBUiApiTest::ExecuteModuleTestBlock ),
+        ENTRY( "ExecuteBranchTestBlock", CUSBUiApiTest::ExecuteBranchTestBlock ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::GetTestBlockParamsL
+// -----------------------------------------------------------------------------
+
+void CUSBUiApiTest::GetTestBlockParamsL( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>> 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( "LaunchUsbUiApp" ) ) )
+        {       
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );      
+        }
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "TurnLightsOn" ) ) )
+		{         
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishTest" ) ) )
+		{       
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); 
+		if( iTestBlockParams.iTestOption1.Compare(_L("CANCELLED")) == KErrNotFound )
+			{
+			User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );        
+			User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption3 ) );
+			}
+		}
+    else
+        {
+        TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    TRACE_INFO( _L("<<< GetTestBlockParamsL") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::ExecuteApiTestBlock
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::ExecuteApiTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>> ExecuteApiTestBlock") );
+	
+	TInt res;
+    TUSBUiApiTestResult testResult;
+	
+    TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    TRACE_INFO( _L("<<< ExecuteApiTestBlock") );
+	
+    return KErrNone;
+    }
+	
+	
+void CUSBUiApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") );
+
+	User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) );
+        TRACE_INFO( (_L("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 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LaunchUsbUiApp" ) ) )
+        {      
+        LaunchUsbUiApp( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishTest" ) ) )
+        {      
+        FinishTest( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, iTestBlockParams.iTestOption3, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "TurnLightsOn" ) ) )
+        {      
+        TurnLightsOn(  );
+        }
+    else
+        {
+    TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+	
+    TRACE_INFO( _L("<<<DoExecuteApiTestBlockL") );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::ExecuteModuleTestBlock
+// -----------------------------------------------------------------------------	
+
+TInt CUSBUiApiTest::ExecuteModuleTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>>ExecuteModuleTestBlock") );
+	
+    TInt res;
+    TUSBUiApiTestResult testResult;
+    
+    TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    TRACE_INFO( _L("<<<ExecuteModuleTestBlock") );
+    return KErrNone;
+    }	
+	
+	
+void CUSBUiApiTest::DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteModuleTestBlockL") );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    TRACE_INFO( (_L("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
+        {
+    TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    
+    TRACE_INFO( _L("<<<DoExecuteModuleTestBlockL") );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::ExecuteBranchTestBlock
+// -----------------------------------------------------------------------------
+	
+TInt CUSBUiApiTest::ExecuteBranchTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>>ExecuteBranchTestBlock") );
+	
+    TInt res;
+    TUSBUiApiTestResult testResult;
+    
+    TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) );
+        return res;
+        }   
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    TRACE_INFO( _L("<<<ExecuteBranchTestBlock") );
+    return KErrNone;
+    }
+
+	
+void CUSBUiApiTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteBranchTestBlockL") );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    TRACE_INFO( (_L("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
+        {
+    TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    
+    TRACE_INFO( _L("<<<DoExecuteBranchTestBlockL") );
+    }
+
+// Add test block methods implementation here
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::ExampleTestL
+// -----------------------------------------------------------------------------
+
+void CUSBUiApiTest::ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+        TInt aTestIntOption, TInt aTestCharOption, TUSBUiApiTestResult& aTestResult )
+    {
+    
+    if ( !aTestOption.Compare( _L( "API" ) ) )
+        {
+    TRACE_INFO( (_L("Api test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Api test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Api test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Api test char option: %c"), aTestCharOption) );
+        }
+    else if ( !aTestOption.Compare( _L( "MODULE" ) ) )
+        {
+    TRACE_INFO( (_L("Module test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Module test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Module test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Module test char option: %c"), aTestCharOption) );
+        }
+    else if ( !aTestOption.Compare( _L( "BRANCH" ) ) )
+        {
+    TRACE_INFO( (_L("Branch test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Branch test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Branch test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Branch test char option: %c"), aTestCharOption) );
+        }
+    else
+        {
+        TRACE_INFO( _L("Invalid test parameter") );
+        User::Leave( KErrNotFound );
+        }
+    
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO( _L("<<<ExampleTestL") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::LaunchUsbUiApp
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::LaunchUsbUiApp( TPtrC aTestOption, TPtrC aTestSubOption, TUSBUiApiTestResult& aTestResult )
+    {
+    TInt res;
+    TInt testAskOnConnectionSetting;
+    TInt testUsbPersonalityId;
+        
+    res = GetAskOnConnectionOptionFromString( aTestOption, testAskOnConnectionSetting );   
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("GetAskOnConnectionOptionFromString failed with value: %d"), res) );
+        iApaLsSession.Close();
+        return res;
+        }
+    TRACE_INFO( (_L("GetAskOnConnectionOptionFromString OK:  %d"), testAskOnConnectionSetting) );
+    
+    
+    res = GetUsbPersonalityOptionFromString( aTestSubOption, testUsbPersonalityId );   
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("GetUsbPersonalityOptionFromString failed with value: %d"), res) );
+        iApaLsSession.Close();
+        return res;
+        }
+    TRACE_INFO( (_L("GetUsbPersonalityOptionFromString OK: %d"),testUsbPersonalityId) );
+    
+    res = GetUsbSettings( iUsbPersonalityBackup, iAskOnConnectionSettingBackup );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("Failed to backup usb settings with value: %d"), res) );
+        return res;
+        }
+    TRACE_INFO( (_L("GetUsbSettings OK: %d, %d"), iUsbPersonalityBackup, iAskOnConnectionSettingBackup) );
+    
+    res = SetUsbSettings( testUsbPersonalityId, testAskOnConnectionSetting );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("Changing usb settings failed with value (cenrep): %d"), res) );
+        return res;
+        }
+    TRACE_INFO( (_L("SetUsbSettings OK: %d, %d"), testUsbPersonalityId, testAskOnConnectionSetting) );
+  
+    iCommandLine->SetCommandL( EApaCommandRun );
+    iCommandLine->SetExecutableNameL( KUsbAppFileName );
+
+    res = iApaLsSession.Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("Connecting to application server failed with value: %d"), res) );
+        return res;
+
+        }
+    STIF_LOG("iApaLsSession.Connect OK");
+
+    res = iApaLsSession.StartApp( *iCommandLine );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("Starting application failed with value: %d"), res) );
+        iApaLsSession.Close();
+        return res;
+        }
+    STIF_LOG("iApaLsSession.StartApp OK");
+    
+    if ( !IsUsbAppRunning() )
+        {
+        TRACE_INFO( _L("Usb application launch error") );
+        iApaLsSession.Close();
+        return KErrGeneral;
+        }
+    STIF_LOG("IsUsbAppRunning OK");
+
+    TRACE_INFO( _L("Usb application started") );
+
+    aTestResult = ETestCasePassed;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::FinishTest
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::FinishTest( TPtrC aTestOption, TPtrC aTestSubOption, TPtrC aTestSubOption2, TUSBUiApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>FinishTest") );
+    
+    TInt res;
+    TUSBAppTestOption option;
+    TBool isAppRunning;
+    TInt actualAskOnConnectionSetting;
+    TInt expectedAskOnConnectionSetting;
+    TInt actualPersonalityIdSetting;
+    TInt expectedPersonalityIdSetting;
+        
+    res = GetTestOption( aTestOption, option );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("GetTestOption failed with value: %d"), res) );
+        iApaLsSession.Close();
+        return res;
+        }
+    TRACE_INFO( (_L("GetTestOption OK: %d"),option) );
+    
+    if ( option == EAskOnConnectionSettingChanged || option == EUsbConnectionModeSettingChanged )
+        {     
+        res = GetAskOnConnectionOptionFromString( aTestSubOption, expectedAskOnConnectionSetting );   
+        if ( res != KErrNone )
+            {
+            TRACE_INFO( (_L("GetAskOnConnectionOptionFromString failed with value: %d"), res) );
+            iApaLsSession.Close();
+            return res;
+            }
+        TRACE_INFO( (_L("GetAskOnConnectionOptionFromString OK: %d"), expectedAskOnConnectionSetting) );
+                
+        res = GetUsbPersonalityOptionFromString( aTestSubOption2, expectedPersonalityIdSetting );   
+        if ( res != KErrNone )
+            {
+            TRACE_INFO( (_L("GetUsbPersonalityOptionFromString failed with value: %d"), res) );
+            iApaLsSession.Close();
+            return res;
+            }
+        TRACE_INFO( (_L("GetUsbPersonalityOptionFromString OK %d"), expectedPersonalityIdSetting) );
+        }
+    
+    isAppRunning = IsUsbAppRunning();
+
+    res = GetUsbSettings( actualPersonalityIdSetting, actualAskOnConnectionSetting );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("Getting usb settings failed with value (cenrep): %d"), res) );
+        iApaLsSession.Close();
+        return res;
+        }
+    TRACE_INFO( (_L("GetUsbSettings OK: %d, %d"), actualPersonalityIdSetting, actualAskOnConnectionSetting) );
+    
+    res = SetUsbSettings( iUsbPersonalityBackup, iAskOnConnectionSettingBackup );
+    if ( res != KErrNone )
+        TRACE_INFO( _L("Failed to restore original usb settings!") );
+    TRACE_INFO( (_L("SetUsbSettings OK: %d, %d"), iUsbPersonalityBackup, iAskOnConnectionSettingBackup) );
+    
+    iApaLsSession.Close();
+    
+    switch( option )
+        {
+        case EAskOnConnectionSettingChanged:       
+        case EUsbConnectionModeSettingChanged:
+            TRACE_INFO( (_L("Actual USB ask on connection setting value: %d, expected: %d"), actualAskOnConnectionSetting, expectedAskOnConnectionSetting) );
+            STIF_ASSERT_EQUALS( expectedAskOnConnectionSetting, actualAskOnConnectionSetting );
+            TRACE_INFO( (_L("Actual USB personality setting value: %d, expected: %d"), actualPersonalityIdSetting, expectedPersonalityIdSetting) );
+            STIF_ASSERT_EQUALS( expectedPersonalityIdSetting, actualPersonalityIdSetting );   
+            TRACE_INFO( (_L("USB app is running: %d, expected: %d"), isAppRunning, EFalse) );
+            STIF_ASSERT_FALSE( isAppRunning );
+            break;
+        case EAppCancelled:
+            TRACE_INFO( (_L("USB app is running: %d, expected: %d"), isAppRunning, EFalse) );
+            STIF_ASSERT_FALSE( isAppRunning );
+            break;
+        default:
+            return KErrNotFound;
+        }
+      
+    TRACE_INFO( _L("Test case passed!") );
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO( _L("<<<FinishTest") );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::GetTestOption
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::GetTestOption( TPtrC aOptionString, TUSBAppTestOption& aOption )
+    {    
+    if ( !aOptionString.Compare( _L( "USB_CONN_MODE" ) ) )
+        {
+        aOption = EUsbConnectionModeSettingChanged;
+        TRACE_INFO( _L("Test type: EUsbConnectionModeSettingChanged") );
+        }
+    else if ( !aOptionString.Compare( _L( "ASK_ON_CONN" ) ) )
+        {
+        aOption = EAskOnConnectionSettingChanged;
+        TRACE_INFO( _L("Test type: EAskOnConnectionSettingChanged") );
+        }
+    else if ( !aOptionString.Compare( _L( "CANCELLED" ) ) )
+        {
+        aOption = EAppCancelled;
+        TRACE_INFO( _L("Test type: EAppCancelled") );
+        }
+    else
+        {
+        TRACE_INFO( _L("Test type: not supported") );
+        return KErrNotFound;
+        }
+ 
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::GetAskOnConnectionOptionFromString
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::GetAskOnConnectionOptionFromString( TPtrC aOptionString, TInt& aOption )
+    {    
+    if ( !aOptionString.Compare( _L( "ON" ) ) )
+        {
+        aOption = KUsbWatcherChangeOnConnectionOn;
+        TRACE_INFO( _L("Ask on connection option: ON") );
+        }
+    else if ( !aOptionString.Compare( _L( "OFF" ) ) )
+        {
+        aOption = KUsbWatcherChangeOnConnectionOff;
+        TRACE_INFO( _L("Ask on connection option: OFF") );
+        }
+    else
+        {
+        TRACE_INFO( _L("Ask on connection option: not supported") );
+        return KErrNotFound;
+        }
+ 
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::GetUsbPersonalityOptionFromString
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::GetUsbPersonalityOptionFromString( TPtrC aOptionString, TInt& aOption )
+    {    
+    if ( !aOptionString.Compare( _L( "PCSUITE" ) ) )
+        {
+        aOption = KUsbPersonalityIdPCSuiteMTP;
+        TRACE_INFO( _L("Usb personality option: KUsbPersonalityIdPCSuiteMTP") );
+        }
+    else if ( !aOptionString.Compare( _L( "MS" ) ) )
+        {
+        aOption = KUsbPersonalityIdMS;
+        TRACE_INFO( _L("Usb personality option: KUsbPersonalityIdMS") );
+        }
+    else if ( !aOptionString.Compare( _L( "PTP" ) ) )
+        {
+        aOption = KUsbPersonalityIdPTP;
+        TRACE_INFO( _L("Usb personality option: KUsbPersonalityIdPTP") );
+        }
+    else if ( !aOptionString.Compare( _L( "MTP" ) ) )
+        {
+        aOption = KUsbPersonalityIdMTP;
+        TRACE_INFO( _L("Usb personality option: KUsbPersonalityIdMTP") );
+        }
+	else if ( !aOptionString.Compare( _L( "MODEM" ) ) )
+		{
+		aOption = KUsbPersonalityIdModemInst;
+		TRACE_INFO( _L("Usb personality option: KUsbPersonalityIdModemInst") );
+		}
+    else
+        {
+        TRACE_INFO( _L("Usb personality option: not supported") );
+        return KErrNotFound;
+        }
+ 
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::IsUsbAppRunning
+// -----------------------------------------------------------------------------
+
+TBool CUSBUiApiTest::IsUsbAppRunning()
+    {
+    TFindProcess processFinder;
+    TFullName processName;
+    TBool isAppRunning = EFalse;
+    RProcess matchedProcess;
+    
+    while ( processFinder.Next( processName ) == KErrNone )
+            {
+            matchedProcess.Open( processFinder );
+            if ( matchedProcess.SecureId() == iUsbAppSecureId )
+                isAppRunning = ETrue;
+            }
+    
+    matchedProcess.Close();    
+    return isAppRunning;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::GetUsbSettings
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::GetUsbSettings( TInt& aUsbPersonalityId, TInt& aAskOnConnectionSetting )
+    {
+    TInt res;   
+    res = iRepository -> Get( KUsbWatcherChangeOnConnectionSetting, aAskOnConnectionSetting );
+    if ( res != KErrNone )
+        return res;
+    
+    res = iRepository -> Get( KUsbWatcherPersonality, aUsbPersonalityId );
+    if ( res != KErrNone )
+        return res;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::SetUsbSettings
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::SetUsbSettings( TInt aUsbPersonalityId, TInt aAskOnConnectionSetting )
+    {
+    TInt res;   
+    res = iRepository -> Set( KUsbWatcherChangeOnConnectionSetting, aAskOnConnectionSetting );
+    if ( res != KErrNone )
+        return res;
+    
+    res = iRepository -> Set( KUsbWatcherPersonality, aUsbPersonalityId );
+    if ( res != KErrNone )
+        return res;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::TurnLightsOn
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::TurnLightsOn(  )
+    {
+    TInt res;
+    res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
+    res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsVTForcedLightsOn, EForcedLightsOn);
+    return res;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/BWINS/usbavkonnotifu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?NotifierArray@@YAPAV?$CArrayPtr@VMEikSrvNotifierBase2@@@@XZ @ 1 NONAME ; class CArrayPtr<class MEikSrvNotifierBase2> * NotifierArray(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/data/102068DC.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2005, 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 specifies the interface and implementation 
+*                 information for USBUINotif Ecom Plugins.
+*
+*/
+
+
+#include "registryinfo.rh"
+#include "uikon.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+{
+	dll_uid = 0x102068DC;
+	interfaces =
+	{
+	INTERFACE_INFO
+		{
+		interface_uid = KUikonUidPluginInterfaceNotifiers;
+		implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10281F23;
+					version_no = 1;
+					display_name = "TTNOTIFY2V2 Plugin 1";
+					default_data = "TTNOTIFY2V2";
+					opaque_data = "0";
+					}
+				};
+		}
+	};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/data/usbuinotif.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2005, 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 contains all the resources for the module 
+*                   USBUINotif.
+*
+*/
+
+
+NAME USBN
+
+#include <eikon.rsg>
+#include <eikon.rh>
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+
+#include <usbuinotif.loc>
+
+
+RESOURCE RSS_SIGNATURE { }
+
+//default document name - not used
+RESOURCE TBUF { buf=""; }
+
+// === QUERIES ================================================================
+
+//-----------------------------------------------------------------------------
+// r_usb_query_with_cancel
+// Query resource (with Cancel) 
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_usb_query_with_cancel
+    {
+    flags   = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout    = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_QUERY_ANIM;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+// r_usb_query_without_cancel 
+// Query resource (without Cancel) 
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_usb_query_without_cancel
+    {
+    flags   = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout    = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_INFO_ANIM;
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+// r_usb_on_connection_query
+// Defines a dialog for usb mode query
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_usb_on_connection_query
+    {
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSingleGraphicPopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_usb_empty_array;
+                    };
+                heading = qtn_usb_mode_query_header; 
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//Prompts for message queries
+//-----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_usb_mode_msg_header {
+    buf=qtn_usb_mode_msg_header; }
+
+RESOURCE TBUF r_usb_mode_msg_mass_storage {
+    buf= "%U mode :\n"qtn_usb_mode_msg_mass_storage"\n<AknMessageQuery Link>"qtn_usb_mode_msg_link"</AknMessageQuery Link>"; }
+
+RESOURCE TBUF r_usb_mode_msg_pc_suite {
+    buf= "%U mode :\n"qtn_usb_mode_msg_pc_suite"\n<AknMessageQuery Link>" qtn_usb_mode_msg_link"</AknMessageQuery Link>"; }
+
+RESOURCE TBUF r_usb_mode_msg_mtp {
+    buf= "%U mode :\n"qtn_usb_mode_msg_mtp"\n<AknMessageQuery Link>" qtn_usb_mode_msg_link"</AknMessageQuery Link>"; }
+
+RESOURCE TBUF r_usb_mode_msg_ptp {
+    buf= "%U mode :\n"qtn_usb_mode_msg_ptp"\n<AknMessageQuery Link>" qtn_usb_mode_msg_link"</AknMessageQuery Link>"; }
+
+RESOURCE TBUF r_usb_mode_msg_link {
+    buf=qtn_usb_mode_msg_link; }
+
+//-----------------------------------------------------------------------------
+// r_usb_on_connection_message_query
+// Defines a dialog for ask on connection query
+//-----------------------------------------------------------------------------
+//   
+RESOURCE DIALOG r_usb_on_connection_message_query 
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE 
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = header_not_defined;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+// r_usb_empty_array
+// Defines an empty array
+//-----------------------------------------------------------------------------
+RESOURCE ARRAY r_usb_empty_array
+    {
+    items=
+        {
+        LBUF { txt=""; }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+// Prompts for information notes
+//-----------------------------------------------------------------------------
+//
+
+//-----------------------------------------------------------------------------
+// Prompts for confirmation queries
+//-----------------------------------------------------------------------------
+//
+#ifndef RD_MULTIPLE_DRIVE
+RESOURCE TBUF r_usb_memory_card_locked { 
+    buf = qtn_usb_mode_note_memory_card_locked; }
+
+RESOURCE TBUF r_usb_cable_unsafely_removed {
+    buf = qtn_usb_mode_note_cable_unsafely_removed; }
+
+RESOURCE TBUF r_usb_memorycard_unsafely_removed { 
+    buf = qtn_usb_mode_note_mmc_unsafely_removed; }
+#endif
+
+RESOURCE TBUF r_usb_change_from_mass_storage {
+    buf = qtn_usb_mode_query_change_from_mass_storage; }
+
+RESOURCE TBUF r_usb_storage_media_failure { 
+    buf = qtn_usb_mode_note_storage_media_failure; }
+
+// USB OTG Resources
+
+//-----------------------------------------------------------------------------
+// r_usb_query_otg_error
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_usb_query_otg_error
+    {
+    flags   = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout    = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_ERROR_ANIM;
+                };
+            }
+        };
+    }
+
+RESOURCE TBUF r_usb_otg_error_current_limit { 
+    buf = qtn_usb_otg_error_current_limit; }
+
+RESOURCE TBUF r_usb_otg_error_too_much_current_required { 
+    buf = qtn_usb_otg_error_too_much_current_required; }
+    
+RESOURCE TBUF r_usb_otg_error_unsupported { 
+    buf = qtn_usb_otg_error_unsupported; }
+
+RESOURCE TBUF r_usb_otg_error_hub_unsupported { 
+    buf = qtn_usb_otg_error_hub; }
+
+RESOURCE TBUF r_usb_otg_error_unrecoverable { 
+    buf = qtn_usb_otg_error_unrecoverable; }
+
+RESOURCE TBUF r_usb_otg_warning_partial_support { 
+    buf = qtn_usb_otg_warning_partial_support; }
+
+RESOURCE TBUF r_usb_no_memory_card {
+    buf = qtn_usb_mode_query_no_memory_card; }
+
+RESOURCE TBUF r_usb_otg_error_attach_timedout { 
+    buf = qtn_usb_otg_error_cable; }
+
+RESOURCE TBUF r_usb_msmm_error_unknown_filesystem { 
+    buf = qtn_usb_otg_error_unsupported_filesystem; }
+
+RESOURCE TBUF r_usb_msmm_error_general_mass_storage_error { 
+    buf = qtn_usb_otg_general_mass_storage_error; }
+
+RESOURCE TBUF r_usb_msmm_error_out_of_memory { 
+    buf = qtn_memlo_not_enough_memory; }
+
+RESOURCE TBUF r_usb_error_memory_not_enough { 
+    buf = qtn_usb_error_memory_not_enough; }
+	
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/eabi/usbavkonnotifu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z13NotifierArrayv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -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:  This file provides building information for usbuinotif.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../loc/usbuinotif.loc             MW_LAYER_LOC_EXPORT_PATH(usbuinotif.loc)
+../rom/usbuinotif.iby             CORE_MW_LAYER_IBY_EXPORT_PATH(usbuinotif.iby)
+../rom/usbuinotifresources.iby    LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(usbuinotifresources.iby)
+
+PRJ_MMPFILES
+usbuinotif.mmp
+
+PRJ_TESTMMPFILES
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/group/usbuinotif.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2005-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:  Project definition file for project USBUINotif
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>  //this is needed for RESOURCE_FILES_DIR
+
+TARGET          usbuinotif.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D  0x102068DC
+
+CAPABILITY	CAP_ECOM_PLUGIN
+VENDORID	VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          usbuinmain.cpp
+SOURCE	        usbnotifier.cpp
+SOURCE          usbuincableconnectednotifier.cpp
+SOURCE          usbuinqueriesnotifiermdrv.cpp
+SOURCE          usbuinotifotgwarning.cpp
+SOURCE          usbuinotifotgerror.cpp 
+SOURCE          usbuinotifmsmmerror.cpp
+// ECom resource file
+START RESOURCE ../data/102068DC.rss
+TARGET  usbuinotif.rsc 
+END	
+
+// Notifier resource file
+START RESOURCE  ../data/usbuinotif.rss
+HEADER
+TARGETPATH    RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../inc
+
+SYSTEMINCLUDE         ../../inc ../../../inc MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/)    //for internal and private API headers
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/mw/hb/hbcore 
+MW_LAYER_SYSTEMINCLUDE
+
+
+
+LIBRARY ECOM.LIB                            // Symbian E-Com Plugin definitions and types
+LIBRARY euser.lib cone.lib                  // Symbian OS frameworklibraries
+LIBRARY avkon.lib                           // UI library
+LIBRARY bafl.lib                            // Basic Application Framework
+LIBRARY commonengine.lib                    // Series 60 common components
+LIBRARY eikcoctl.lib eiksrv.lib             // Eikon libraries
+LIBRARY eikdlg.lib                          // Eikon dialogs
+LIBRARY estor.lib                           // for Cover Display UI support
+LIBRARY FeatMgr.lib                         // for fetching if Cover Display is supported
+LIBRARY centralrepository.lib               // Central Repository
+LIBRARY efsrv.lib                           // File server
+LIBRARY eikcore.lib                         // for icons
+LIBRARY aknskins.lib 
+LIBRARY aknskinsrv.lib
+LIBRARY aknicon.lib
+LIBRARY egul.lib
+LIBRARY usbman.lib                          // for personality IDs and descriptions
+LIBRARY aknnotifierwrapper.lib              // Avkon's notifier wrapper
+LIBRARY         apparc.lib 
+LIBRARY akncapserverclient.lib              // for suppressing the application key
+LIBRARY hbcore.lib
+
+DEBUGLIBRARY flogger.lib                    // File logging services
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,206 @@
+/*
+ * 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:  Declares USB UI notifiers base class.
+ *
+ */
+#ifndef USBUINOTIFIER_H
+#define USBUINOTIFIER_H
+// INCLUDES
+#include <usbuinotif.h>
+#include <eikenv.h>
+#include <data_caging_path_literals.hrh> 
+#include <usbman.h>
+#include <usbwatcher.h>
+#include <AknCapServerClient.h>  
+#include "usbuinotifdebug.h"
+// CONSTANTS
+// Literal resource filename 
+_LIT(KResourceFileName, "usbuinotif.rsc");
+
+// FORWARD DECLARATIONS
+
+
+// CLASS DECLARATION
+
+/**
+ *  This class is the base class for all notifiers.
+ *
+ *  @lib
+ */
+NONSHARABLE_CLASS(CUSBUINotifierBase) : public CActive, public MEikSrvNotifierBase2
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUSBUINotifierBase();
+
+protected:
+    // Constructors and destructor
+
+    /**
+     * C++ default constructor.
+     */
+    CUSBUINotifierBase();
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    virtual void ConstructL();
+
+protected:
+    // New functions
+
+    /**
+     * Used in asynchronous notifier launch to store received parameters 
+     * into members variables and make needed initializations.        
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot a Reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return None.
+     */
+    virtual void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage)=0;
+
+    /**
+     * A function for checking the status of Apps key.
+     * @param aEnable A Boolean according to Apps key status
+     * @return None.
+     */
+    void SuppressAppSwitching(TBool aEnable);
+
+    /**
+     * Check if message needs to be completed and complete it
+     * @param aReason   The completetion code
+     */
+    void CompleteMessage(TInt aReason);
+
+    /*
+     * Check whether the keylock is on. If yes turn it off.
+     * @since S60 3.2
+     */
+    void DisableKeylock();
+
+    /*
+     * Restore the keyguard on if it has been disabled by DisableKeylock.
+     * @since S60 3.2
+     */
+    void RestoreKeylock();
+
+protected:
+    // Functions from base classes        
+
+    /**
+     * From CActive Gets called when a request completes.
+     * @param None.
+     * @return None.
+     */
+    virtual void RunL()=0;
+
+    /**
+     * From CActive Gets called when a leave occurres in RunL.
+     * @param aError Symbian OS errorcode.
+     * @return error code.
+     */
+    virtual TInt RunError(TInt aError);
+
+    /**
+     * From MEikSrvNotifierBase2 Called when a notifier is first loaded 
+     * to allow any initial construction that is required.
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    virtual TNotifierInfo RegisterL()=0;
+
+    /**
+     * From MEikSrvNotifierBase2 The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     * @param None.
+     * @return None.
+     */
+    virtual void Cancel();
+
+private:
+    // Functions from base classes        
+
+    /**
+     * From MEikSrvNotifierBase2 Called when all resources allocated 
+     * by notifiers should be freed.
+     * @param None.
+     * @return None.
+     */
+    virtual void Release();
+
+    /**
+     * From MEikSrvNotifierBase2 Return the priority a notifier takes 
+     * and the channels it acts on.
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    virtual TNotifierInfo Info() const;
+
+    /**
+     * From MEikSrvNotifierBase2 Synchronic notifier launch.        
+     * @param aBuffer Received parameter data.
+     * @return A pointer to return value.
+     */
+    virtual TPtrC8 StartL(const TDesC8& aBuffer);
+
+    /**
+     * From MEikSrvNotifierBase2 Asynchronic notifier launch.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReturnVal The return value to be passed back.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return A pointer to return value.
+     */
+    virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+    /**
+     * From MEikSrvNotifierBase2 Updates a currently active notifier.
+     * @param aBuffer The updated data.
+     * @return A pointer to return value.
+     */
+    virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
+
+    /**
+     * From CActive Gets called when a request is cancelled.
+     * @param None.
+     * @return None.
+     */
+    virtual void DoCancel();
+
+private:
+    TBool iKeylockChanged; // Flag used to restore the keylock
+    RAknUiServer iAknServer;
+protected:
+    // Data
+
+    RMessagePtr2 iMessage; // Received message
+    TInt iReplySlot; // Reply slot
+    TBool iNeedToCompleteMessage; // Flag for releasing messages
+
+    TInt iResourceFileFlag; // Flag for eikon env.
+    TNotifierInfo iInfo; // Notifier parameters structure    
+    CEikonEnv* iEikEnv; // Local eikonenv, not own
+    TBool iAppsKeyBlocked; // Apps key status 
+
+    TBool iCoverDisplaySupported; // Cover Display UI feature support
+
+    };
+
+#endif // USBUINOTIFIER_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuincableconnectednotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,151 @@
+/*
+ * 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:  Declares USB Cable Connected notifier class.
+ *
+ */
+
+#ifndef USBUINCABLECONNECTEDNOTIFIER_H
+#define USBUINCABLECONNECTEDNOTIFIER_H
+
+// INCLUDES
+
+#include <hbdevicedialogsymbian.h>
+#include <hbsymbianvariant.h>
+
+#include "usbnotifier.h" // Base class
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show query related to the USB cable connection
+ *
+ *  @lib
+ */
+NONSHARABLE_CLASS(CUSBUICableConnectedNotifier) : public CUSBUINotifierBase, 
+    public MHbDeviceDialogObserver
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUSBUICableConnectedNotifier* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUSBUICableConnectedNotifier();
+
+private:
+    // Functions from base class
+
+    /**
+     * From CUSBUINotifierBase Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     * @param None.
+     * @return None.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase Gets called when a request completes.
+     * @param None.
+     * @return None.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot a Reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return None.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+ 
+       
+private:
+    // functions from MHbDeviceDialogObserver
+   
+    /**
+    * lunches the QT usb ui setting
+    * @param aData is a CHbSymbianVariantMap daya which contains the keys
+    */ 
+    void DataReceived(CHbSymbianVariantMap& aData);
+    /*
+     * Virtual function from MHbDeviceDialogObserver
+     * Not implemented
+     */     
+    void DeviceDialogClosed(TInt aCompletionCode);
+         
+    
+
+private:
+    //New functions
+     /**
+     * Get the ID for current USB personality mode
+     * @param aCurrentPersonality current personality id
+     */
+    void GetCurrentIdL(TInt& aCurrentPersonality);
+    /**
+     * Get the mode name and header for current personality
+     * The parameters are pushed to the cleanup stack in order
+     * aDescription, aHeader.
+     * @param aDescription The returned current personality string.
+     * @param aHeader The header string for message query.
+     */
+    void GetPersonalityStringLC(HBufC*& aHeader,HBufC*& aDescription );
+
+    /**
+     * Runs the connected discreet note
+     */
+    void RunQueryL();
+
+  
+    /**
+     * launches the (USB) application
+     * @param aProcessName The process name (*.exe)
+     * @param TUidType 
+     */
+    void LaunchApplication(const TDesC & aProcessName,const TUidType & aUidType) const;
+
+    /**
+     * Adds a parameter to the dialog parameters.
+     */
+    void AddParameterL(
+            CHbSymbianVariantMap* aParameters,
+            const TDesC& aKey,
+            const TAny* aData,
+            CHbSymbianVariant::TType aDataType);
+
+private:
+    /**
+     *  C++ default constructor.
+     */
+    CUSBUICableConnectedNotifier();
+    
+    CHbDeviceDialogSymbian* iDialog; 
+
+    };
+#endif // USBUINCABLECONNECTEDNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotif.hrh	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,32 @@
+/*
+ * 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:
+ *
+ */
+ 
+
+#ifndef USBUINOTIF_HRH
+#define USBUINOTIF_HRH
+
+// DATA TYPES
+
+enum TUSBUINotifCommands
+    {
+    EUSBUICmdDiscreetTapped = 1  
+    };
+
+
+
+
+#endif      // USBCLASSCHANGEUIPLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotifdebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2005, 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 defines logging macros for USB UI Notifiers
+*
+*/
+
+
+#ifndef USBUINOTIFDEBUG_H
+#define USBUINOTIFDEBUG_H
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"usbuinotiflog.txt");
+_LIT(KLogDir,"USBUI");
+
+// 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);
+    }
+
+
+// ===========================================================================
+#else               // Target HW
+// ===========================================================================
+
+// ===========================================================================
+#ifdef _USBUINOTIF_FILE_LOGGING_ // File logging for target HW
+// ===========================================================================
+
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"usbuinotiflog.txt");
+_LIT(KLogDir,"USBUI");
+
+// 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);
+    }
+
+// ===========================================================================
+#else    // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+//Declare the FPrint function with variable number of arguments.
+inline void FPrint(const TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    TInt tmpInt = VA_ARG(list, TInt);
+    TInt tmpInt2 = VA_ARG(list, TInt);
+    TInt tmpInt3 = VA_ARG(list, TInt);
+    VA_END(list);
+    RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
+    }
+
+//Declare the FPrint function with variable number of arguments.
+inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+    {
+
+    VA_LIST list;
+    VA_START(list, aFmt);
+    TBuf8<256> buf8;
+    buf8.AppendFormatList(aFmt, list);
+
+    TBuf16<256> buf16(buf8.Length());
+    buf16.Copy(buf8);
+
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+    }
+#endif //_USBUINOTIF_FILE_LOGGING_    
+#endif // __WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // USBUINOTIFDEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotifmsmmerror.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* 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:  Declares USB UI Queries notifier.
+ *
+*/
+
+
+#ifndef USBUINOTIFMSMMERROR_H
+#define USBUINOTIFMSMMERROR_H
+
+// INCLUDES
+
+#include "usbnotifier.h"      // Base class
+#include <AknQueryDialog.h>   // AVKON component
+#define KUsbUiNotifOtgGeneralQueryGranularity 3
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show general USB query.
+ *  Asynchronous call is required.
+ *
+ *  @lib
+ */
+NONSHARABLE_CLASS(CUsbUiNotifMSMMError) : public CUSBUINotifierBase
+    {
+public:
+
+/**
+ * Possible parameter values for KUsbUiNotifMSMMError
+ */
+enum TUsbUiNotifMSMMError
+    {
+    EUsbMSMMGeneralError,	
+    EUsbMSMMUnknownFileSystem,
+    EUsbMSMMOutOfMemory
+    };
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbUiNotifMSMMError* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbUiNotifMSMMError();
+
+protected:
+
+    /**
+     * Second phase contructor
+     */
+    void ConstructL();
+
+private:
+    // Functions from base class
+
+    /**
+     * From CUSBUINotifierBase Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase Gets called when a request completes.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot A reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+private:
+
+    /**
+     *  C++ default constructor.
+     */
+    CUsbUiNotifMSMMError();
+
+private:
+    // New functions
+
+    /**
+     * Show query dialog     
+     * @return KErrNone - accepted, KErrCancel - Cancel or End call key
+     */
+    TInt QueryUserResponseL();
+
+private:
+    // Data
+    /**
+     *  Query
+     *  Not own, destroys self when lauched.
+     */
+    CAknQueryDialog* iQuery; 
+    RArray<TInt> iStringIds;
+    TInt iErrorId;
+    };
+#endif // USBUINOTIFMSMMERROR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotifotgerror.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* 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:  Declares USB UI Queries notifier.
+ *
+*/
+
+
+#ifndef USBUINOTIFOTGERROR_H
+#define USBUINOTIFOTGERROR_H
+
+// INCLUDES
+
+#include "usbnotifier.h"      // Base class
+#include <AknQueryDialog.h>   // AVKON component
+#define KUsbUiNotifOtgGeneralQueryGranularity 3
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show general USB query.
+ *  Asynchronous call is required.
+ *
+ *  @lib
+ */
+NONSHARABLE_CLASS(CUsbUiNotifOtgError) : public CUSBUINotifierBase
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbUiNotifOtgError* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbUiNotifOtgError();
+
+protected:
+
+    /**
+     * Second phase contructor
+     */
+    void ConstructL();
+
+private:
+    // Functions from base class
+
+    /**
+     * From CUSBUINotifierBase Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase Gets called when a request completes.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot A reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+private:
+
+    /**
+     *  C++ default constructor.
+     */
+    CUsbUiNotifOtgError();
+
+private:
+    // New functions
+
+    /**
+     * Show query dialog     
+     * @return KErrNone - accepted, KErrCancel - Cancel or End call key
+     */
+    TInt QueryUserResponseL();
+
+private:
+    // Data
+    /**
+     *  Query
+     *  Not own, destroys self when lauched.
+     */
+    CAknQueryDialog* iQuery; 
+    RArray<TInt> iStringIds;
+    TInt iErrorId;
+    };
+#endif // USBUINOTIFOTGERROR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotifotgwarning.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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:  Declares USB UI connection notifier.
+ *
+*/
+
+
+#ifndef USBUINOTIFOTGWARNING_H
+#define USBUINOTIFOTGWARNING_H
+
+// INCLUDES
+#include <aknnotewrappers.h>
+#include <usbuinotif.h>
+
+#include "usbnotifier.h"   // Base class
+#define KUsbUiNotifOtgGeneralNoteGranularity 1
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show general USB note.
+ *  Synchronous call is enouph.
+ * 
+ */
+NONSHARABLE_CLASS(CUsbUiNotifOtgWarning) : public CUSBUINotifierBase
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUsbUiNotifOtgWarning* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUsbUiNotifOtgWarning();
+
+protected:
+
+    /**
+     * Second phase contructor
+     */
+    void ConstructL();
+
+private:
+    // Functions from base class
+
+
+    /**
+     * From CUSBUINotifierBase. Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase. Gets called when a request completes.
+     * @param None.
+     * @return None.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase. Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot A reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return None.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+private:
+
+    /**
+     *  C++ default constructor.
+     */
+    CUsbUiNotifOtgWarning();
+
+    /**
+     * Publish the dialog to the cover UI
+     * The cover UI may use the personality ID or the localized
+     * personality name e.g. "Mass storage". 
+     * @param aNote           The dialog to be published.
+     * @param aPersonalityId  The personality ID.
+     * @param aLocalizedPersonalityDescriptor The personality as a string.
+     */
+    void
+            PublishToCoverUiL(CAknResourceNoteDialog* aNote,
+                    TInt aPersonalityId,
+                    const HBufC* aLocalizedPersonalityDescriptor);
+
+private:
+    // data
+    RArray<TInt> iStringIds;
+
+    //Own
+    CAknResourceNoteDialog* iNote;
+
+    TInt iNoteId;
+    };
+#endif // USBUINOTIFOTGWARNING_H
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinqueriesnotifier.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2005-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:  Declares USB UI Queries notifier.
+ *
+ */
+
+#ifndef USBUINQUERIESNOTIFIER_H
+#define USBUINQUERIESNOTIFIER_H
+
+// INCLUDES
+
+#include "usbnotifier.h"      // Base class
+#include <AknQueryDialog.h>   // AVKON component
+
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show USB query dialogs.
+ *
+ *  @lib
+ */
+NONSHARABLE_CLASS(CUSBUIQueriesNotifier) : public CUSBUINotifierBase
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUSBUIQueriesNotifier* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUSBUIQueriesNotifier();
+
+
+private:
+    // Functions from base class
+
+    /**
+     * From CUSBUINotifierBase Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     * @param None.
+     * @return None.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase Gets called when a request completes.
+     * @param None.
+     * @return None.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot A reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return None.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+private:
+
+    /**
+     *  C++ default constructor.
+     */
+    CUSBUIQueriesNotifier();
+
+private:
+    // New functions
+
+
+    /**
+     * Show query dialog 
+     * @param aStringHolder   The string for the query. 
+     * @param aCoverDialogId  The dialog ID for the cover UI.
+     * @param aIsCancelKey    Does the dialog show Cancel key.
+     * @return KErrNone - accepted, KErrCancel - Cancel or End call key
+     */
+    TInt QueryUserResponseL(const TDesC& aStringHolder, TInt aCoverDialogId,
+            TBool aIsCancelKey);
+
+    /**
+     * Get attributes for the query dialog
+     * The query type is idenfied by the member variable iQueryType.
+     * The caller should pop and destroy the returned heap descriptor 
+     * when it is no longer needed.
+     * @param aCoverDialogId  Returned dialog ID for the cover UI.
+     * @param aIsCancelKey    Returned info about showing the Cancel key.
+     * @return                The string holder for the query. 
+     */
+    HBufC* GetQueryAttributesLC(TInt& aCoverDialogId, TBool& aIsCancelKey);
+
+private:
+    // Data
+    /**
+     * Query
+     * Not own, destroys self when lauched.
+     */
+    CAknQueryDialog* iUSBQueryDlg;  
+    TUSBUIQueries iQueryType; // To store the type of the query
+    TInt iDriveLetter; // For MMC locked case
+
+    };
+#endif // USBUINQUERIESNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,132 @@
+/*
+ * 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:  Declares USB UI Queries notifier.
+ *
+ */
+
+#ifndef USBUINQUERIESNOTIFIER_H
+#define USBUINQUERIESNOTIFIER_H
+
+// INCLUDES
+
+#include "usbnotifier.h"      // Base class
+#include <AknQueryDialog.h>   // AVKON component
+// CLASS DECLARATION
+
+/**
+ *  This class is used to show USB query dialogs.
+ *
+ *  @lib 
+ *  @since S60 3.0
+ */
+NONSHARABLE_CLASS(CUSBUIQueriesNotifier) : public CUSBUINotifierBase
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUSBUIQueriesNotifier* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUSBUIQueriesNotifier();
+
+private:
+    // Functions from base class
+
+    /**
+     * From CUSBUINotifierBase Called when a notifier is first loaded.        
+     * @param None.
+     * @return A structure containing priority and channel info.
+     */
+    TNotifierInfo RegisterL();
+
+    /**
+     * From CUSBUINotifierBase The notifier has been deactivated 
+     * so resources can be freed and outstanding messages completed.
+     * @param None.
+     * @return None.
+     */
+    void Cancel();
+
+    /**
+     * From CUSBUINotifierBase Gets called when a request completes.
+     * @param None.
+     * @return None.
+     */
+    void RunL();
+
+    /**
+     * From CUSBUINotifierBase Used in asynchronous notifier launch to 
+     * store received parameters into members variables and 
+     * make needed initializations.
+     * @param aBuffer A buffer containing received parameters
+     * @param aReplySlot A reply slot.
+     * @param aMessage Should be completed when the notifier is deactivated.
+     * @return None.
+     */
+    void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+            const RMessagePtr2& aMessage);
+
+private:
+    /*
+     * From MEikSrvNotifierBase2 Synchronic notifier launch.        
+     * @param aBuffer Received parameter data.
+     * @return A pointer to return value.
+     */
+    virtual TPtrC8 StartL(const TDesC8& aBuffer);
+
+    /**
+     *  C++ default constructor.
+     */
+    CUSBUIQueriesNotifier();
+
+private:
+    // New functions
+
+    /**
+     * Show query dialog 
+     * @param aStringHolder   The string for the query. 
+     * @param aCoverDialogId  The dialog ID for the cover UI.
+     * @param aIsCancelKey    Does the dialog show Cancel key.
+     * @return KErrNone - accepted, KErrCancel - Cancel or End call key
+     */
+    TInt QueryUserResponseL(const TDesC& aStringHolder, TInt aCoverDialogId,
+            TBool aIsCancelKey, TBool aIsErrorQuery);
+
+    /**
+     * Get attributes for the query dialog
+     * The query type is idenfied by the member variable iQueryType.
+     * The caller should pop and destroy the returned heap descriptor 
+     * when it is no longer needed.
+     * @param aCoverDialogId  Returned dialog ID for the cover UI.
+     * @param aIsCancelKey    Returned info about showing the Cancel key.
+     * @return                The string holder for the query. 
+     */
+    HBufC* GetQueryAttributesLC(TInt& aCoverDialogId, TBool& aIsCancelKey, TBool& aIsErrorQuery);
+
+private:
+    // Data
+    
+    /**
+    * Not own, destroys self when lauched.
+    */
+    CAknQueryDialog* iUSBQueryDlg;
+    TUSBUIQueries iQueryType; // To store the type of the query
+
+    };
+#endif // USBUINQUERIESNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/loc/usbuinotif.loc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* 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:  This is a localisation file for usbuinotif. 
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+// *** STRINGS FOR CONFIRMATION QUERIES ***
+
+//d: Memory card needs to be unlocked before it can be used
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_usb_mode_note_memory_card_locked "Memory card needs to be unlocked"
+
+//d: Mass storage memory is not accessible because it cannot be unmounted for some reason
+//d: Softkey "OK" is shown. 
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_usb_mode_note_storage_media_failure "Storage media not accessible"
+
+//d: User disconnects the cable without disconnecting or unmounting it from the PC
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_usb_mode_note_cable_unsafely_removed "Data loss may have occurred. In future, stop file transfers before removing the cable"
+
+//d: While in file transfer mode, the phone receives a card eject event
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_usb_mode_note_mmc_unsafely_removed "Data loss may have occurred. In future, stop file transfers before removing the memory card"
+
+//d: User changes the mode to something from Mass storage mode. Memory card
+//d: might corrupt here so asking for confirmation. Note that the soft keys 
+//d: are labeled as "OK" and "Cancel". 
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_usb_mode_query_change_from_mass_storage "Change USB mode? Storage media may be corrupted if file transfer is ongoing."
+
+
+//d: User tries to use MTP personality without memory card. Since that can be 
+//d: the only media shared via this personality, the connection may be partly 
+//d: or fully unusable. 
+//d: Softkey "OK" is shown. 
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_usb_mode_query_no_memory_card "Memory card is not present. The connection may not work as expected."
+
+//d: The header for USB connected pop-up
+//l: popup_discreet_window_t1
+//r: 5.2
+#define qtn_usb_mode_msg_header "USB Connected"
+
+//d: Too much power error in USB OTG during operating, cable disconnect required
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_current_limit "Error in USB connection. Disconnect device."
+
+//d: Too much power error in USB OTG during enumerating, cable disconnect required
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_too_much_current_required "Unsupported USB device. Disconnect device."
+
+
+//d: Unsupported device error in USB OTG, cable disconnect required
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_unsupported "Unsupported USB device. Disconnect device."
+
+//d: USB hubs are not supported.
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_hub "Hubs are not supported. Disconnect USB cable."
+
+//d: Connection error in USB OTG, cable disconnect required
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_unrecoverable "Error in USB connection. Disconnect cable."
+
+//d: Partially supported warning in USB OTG.
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_warning_partial_support "Partially supported USB device connected. All functionality might not work."
+
+
+//d: Emptry cable error in USB OTG.
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_cable "Remove USB cable or connect a device."
+
+//d: Unknown mass storage  filesystem, disconnect device.
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_error_unsupported_filesystem "Unknown file system. Disconnect device."
+
+//d: General Mass storage error in USB OTG.
+//l: popup_note_window
+//w:
+//r: 5.2
+//
+#define qtn_usb_otg_general_mass_storage_error "General Mass storage error"
+
+//d: Memory not enough or full error
+//l: popup_note_window
+//r: 5.2
+#define qtn_usb_error_memory_not_enough "Memory full. Close some applications and try to connect USB cable again"
+
+// End of USB_OTG
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/rom/usbuinotif.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* 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: usbnotifier iby file
+*
+*/
+#ifndef __USBUINOTIF_IBY__
+#define __USBUINOTIF_IBY__
+
+REM USB UI notifiers ecom plug-in
+
+#ifdef __USB_MULTIPERSONALITY 
+
+ECOM_PLUGIN(usbuinotif.dll, 102068DC.rsc)  
+
+#endif //__USB_MULTIPERSONALITY
+#endif //__USBUINOTIF_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/rom/usbuinotifresources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* 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 __USBUINOTIFRESOURCES_IBY__
+#define __USBUINOTIFRESOURCES_IBY__
+
+REM USB UI notifiers resources
+
+#ifdef __USB_MULTIPERSONALITY 
+
+data=DATAZ_\RESOURCE_FILES_DIR\usbuinotif.rsc    RESOURCE_FILES_DIR\usbuinotif.rsc
+
+#endif // __USB_MULTIPERSONALITY
+#endif // __USBUINOTIFRESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbnotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,318 @@
+/*
+ * 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:  Declares USB UI notifiers base class.
+ *
+ */
+
+// INCLUDE FILES
+#include <eikenv.h>          // Eikon environment
+#include <bautils.h>         // BAFL utils (for language file)
+#include <StringLoader.h>    // Localisation stringloader
+#include <centralrepository.h> 
+#include <coreapplicationuisdomainpskeys.h>
+#include <data_caging_path_literals.hrh> 
+#include <featmgr.h>
+#include <AknNotiferAppServerApplication.h>
+
+#include "usbnotifier.h"     // Own class 
+#include "usbuinotifdebug.h"
+#include "aknkeylock.h" //RAknKeyLock
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::CBTNotifierBase
+// C++ default constructor can NOT contain any code, that
+// might leave. Sets the AOs priority and puts
+// itself to the active scheduler stack.
+// ----------------------------------------------------------------------------
+//
+CUSBUINotifierBase::CUSBUINotifierBase() :
+    CActive( EPriorityStandard )
+    {
+        FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Default constructor()"));
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::ConstructL
+// Symbian 2nd phase constructor can leave.
+// Create registry object and open resource file.
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::ConstructL()
+    {
+    iEikEnv = CEikonEnv::Static();
+    iAppsKeyBlocked = EFalse;
+    iKeylockChanged = EFalse;
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL()"));
+    TFileName filename;
+
+    const TDriveNumber KStoreDrive = EDriveZ;
+    TDriveUnit driveUnit( KStoreDrive );
+    TDriveName drive = driveUnit.Name();
+    filename.Insert( 0, drive );
+
+    filename += KDC_RESOURCE_FILES_DIR; // From data_caging_path_literals.hrh
+    filename += KResourceFileName;
+    BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename );
+    iResourceFileFlag = iEikEnv->AddResourceFileL( filename );
+
+    FeatureManager::InitializeLibL();
+    iCoverDisplaySupported = FeatureManager::FeatureSupported(
+            KFeatureIdCoverDisplay );
+    FeatureManager::UnInitializeLib();
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CUSBUINotifierBase::~CUSBUINotifierBase()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor"));
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to the local CUSBUINotifierBase::Cancel, 
+    //not to any possibly derived class implementation. 
+    Cancel();
+    iEikEnv->DeleteResourceFile( iResourceFileFlag );
+
+    // Complete the RMessage2 if needed
+    //
+    CompleteMessage( KErrDied );
+
+    // Activate apps -key again (if not previously activated yet)
+    SuppressAppSwitching( EFalse );
+
+    // Restore the keylock if not restored before (caused by Leave).
+    // If the Keylock is restored already, the function does nothing.
+    RestoreKeylock();
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::Release
+// Release itself. Call to destructor.
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::Release()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Release()"));
+    delete this;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::Info
+// Return registered information.
+// ----------------------------------------------------------------------------
+//
+CUSBUINotifierBase::TNotifierInfo CUSBUINotifierBase::Info() const
+    {
+    FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::Info() id %d channel %d priority %d"), iInfo.iUid, iInfo.iChannel, iInfo.iPriority ));
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::StartL
+// Synchronic notifier launch. Does nothing
+// ----------------------------------------------------------------------------
+//
+TPtrC8 CUSBUINotifierBase::StartL(const TDesC8& /*aBuffer*/)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL()"));
+
+    TPtrC8 ret( KNullDesC8 );
+    return (ret);
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::StartL
+// Asynchronic notifier launch.
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot,
+        const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL()"));
+    TRAPD( err, GetParamsL( aBuffer, aReplySlot, aMessage ));
+    if (err)
+        {
+        aMessage.Complete( err );
+        iNeedToCompleteMessage = EFalse;
+        User::Leave( err );
+        }
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL completed()"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::Cancel
+// Cancelling method.
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel()"));
+    CActive::Cancel();
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel completed()"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::UpdateL
+// Notifier update. Not supported.
+// ----------------------------------------------------------------------------
+//
+TPtrC8 CUSBUINotifierBase::UpdateL(const TDesC8& /*aBuffer*/)
+    {
+    TPtrC8 ret( KNullDesC8 );
+    return (ret);
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::DoCancel
+// This method will be called by framework (CActive)
+// if active object is still active.
+// Does nothing here.
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::DoCancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DoCancel()"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::RunError
+// This method is called if any leaving has been occured
+// during RunL. Optional method for CActive derived objects.
+// ----------------------------------------------------------------------------
+//
+TInt CUSBUINotifierBase::RunError(TInt aError)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError()"));
+
+    // Activate apps -key again (if not previously activated yet)
+    //
+    SuppressAppSwitching( EFalse );
+
+    // Write error message to caller
+    //
+    CompleteMessage( aError );
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError() completed"));
+
+    return aError;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::SuppressAppSwitching
+// 
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::SuppressAppSwitching(TBool aEnable)
+    {
+    FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() %d"), aEnable));
+
+    if (iAppsKeyBlocked != aEnable)
+        {
+        TInt err = iAknServer.ConnectAndSendAppsKeySuppress( aEnable ); // error is stored only for logging purposes
+        iAppsKeyBlocked = aEnable;
+        FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() ConnectAndSendAppsKeySuppress returned %d"), err ));
+        }
+
+    if (!iAppsKeyBlocked)
+        {
+        iAknServer.Close(); // close the connection once we have re-enabled swithcing
+        }
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::CompleteMessage
+// Check if message needs to be completed and complete it. 
+// ----------------------------------------------------------------------------
+//
+void CUSBUINotifierBase::CompleteMessage(TInt aReason)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::CompleteMessage()"));
+    if (iNeedToCompleteMessage)
+        {
+        iMessage.Complete( aReason );
+        iNeedToCompleteMessage = EFalse;
+        }
+    iReplySlot = 0;
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::CompleteMessage() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::DisableKeylock
+// ----------------------------------------------------------------------------
+// Turn off the keyguard if it was on.
+//
+void CUSBUINotifierBase::DisableKeylock()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock()"));
+    RAknKeylock2 keylock;
+    iKeylockChanged = EFalse;
+    if (KErrNone == keylock.Connect())
+        {
+        if (keylock.IsKeyLockEnabled()) //Check and save the keylock status
+            {
+            keylock.DisableWithoutNote();// Unlock
+            iKeylockChanged = ETrue;
+            }
+        keylock.Close();
+        }
+    else
+        {
+        FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() fail caused by RAknKeylock2::Connect()") );
+        }
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUINotifierBase::RestoreKeylock
+// ----------------------------------------------------------------------------
+// Restore the keyguard on.
+//
+void CUSBUINotifierBase::RestoreKeylock()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock()"));
+    if (iKeylockChanged)
+        {
+        FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): iKeylockChanged true"));
+        RAknKeylock2 keylock;
+        FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2 initialized"));
+        if (KErrNone == keylock.Connect())
+            {
+            FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Connect() complete"));
+            keylock.EnableWithoutNote();// Lock back
+            FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::EnableWithoutNote() complete"));
+            keylock.Close();
+            FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Close() complete"));
+            iKeylockChanged = EFalse;
+            }
+        else
+            {
+            FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() fail caused by RAknKeylock2::Connect()") );
+            }
+        }
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() completed"));
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,344 @@
+/*
+ * 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:  USB Cable Connected notifier class.
+ *
+ */
+// INCLUDE FILES
+#include <eikenv.h>          // Eikon environment
+#include <bautils.h>         // BAFL utils (for language file)
+#include <aknlists.h>
+#include <aknPopup.h> 
+#include <StringLoader.h>    // Localisation stringloader
+#include <utf.h>             // Unicode character conversion utilities
+#include <usbman.h>
+#include <usbuinotif.rsg>                   // Own resources
+#include <centralrepository.h> 
+#include <e32property.h>
+#include <e32uid.h> // KExecutableImageUid
+#include "usbuincableconnectednotifier.h"   // Own class definition
+#include "usbuinotifdebug.h"                // Debugging macros
+#include "UsbWatcherInternalCRKeys.h"
+#include "usbuinotif.hrh"
+
+// Literals
+
+_LIT(KUSBExe, "usbapplication.exe");
+const TInt KUSBUIUid = 0x2002BCA3;
+_LIT(KFileDrive,"z:");
+_LIT(KUSBUIconFileName, "usbui.mif");
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUSBUICableConnectedNotifier* CUSBUICableConnectedNotifier::NewL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::NewL"));
+    CUSBUICableConnectedNotifier* self =
+            new (ELeave) CUSBUICableConnectedNotifier();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::NewL completed"));
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::default constructor"));
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUSBUICableConnectedNotifier::~CUSBUICableConnectedNotifier()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::destructor"));
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to the local CUSBUICableConnectedNotifier::
+    //Cancel, not to any possibly derived class implementation. 
+    Cancel();
+    delete iDialog;
+         
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::destructor completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::RegisterL
+// Register notifier.
+// ----------------------------------------------------------------------------
+//
+CUSBUICableConnectedNotifier::TNotifierInfo CUSBUICableConnectedNotifier::RegisterL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RegisterL"));
+    iInfo.iUid = KCableConnectedNotifierUid;
+    iInfo.iChannel = KQueriesNotifier; // work in the same channel with the other 
+    // queries so that we can use priorities
+    iInfo.iPriority = ENotifierPriorityLow; // must be smaller than queries notifier
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RegisterL completed"));
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::GetParamsL
+//  Jump to RunL as soon as possible.
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::GetParamsL(const TDesC8& /*aBuffer*/,
+        TInt aReplySlot, const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetParamsL"));
+    if ( iReplySlot != 0 || iNeedToCompleteMessage)
+        {
+        User::Leave(KErrInUse);
+        }
+
+    iMessage = aMessage;
+    iNeedToCompleteMessage = ETrue;
+    iReplySlot = aReplySlot;
+
+    // Call SetActive() so RunL() will be called by the active scheduler
+    //
+    iStatus = KRequestPending;
+    TRequestStatus* stat = &iStatus;
+    SetActive();
+    User::RequestComplete(stat, KErrNone);
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetParamsL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::RunL
+// Ask user response and return it to caller.
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::RunL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunL"));
+
+    DisableKeylock();
+    SuppressAppSwitching(ETrue);
+    RunQueryL();
+    SuppressAppSwitching(EFalse);
+    RestoreKeylock();
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::Cancel()
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::Cancel() "));
+
+    iDialog->Cancel(); // cancel the dialog, if it is active
+    CompleteMessage(KErrCancel);
+    CUSBUINotifierBase::Cancel();
+
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::Cancel() completed"));
+    }
+
+// -----------------------------------------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::GetPersonalityStringL
+// Get the strings for ask on connection message query 
+// -----------------------------------------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::GetPersonalityStringLC(
+       HBufC*& aHeader,HBufC*& aDescription )
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetPersonalityStringL"));
+    TInt CurrentPersonalityID = 0; // The ID of current USB mode
+    GetCurrentIdL(CurrentPersonalityID);
+    RUsb usbman;
+    User::LeaveIfError(usbman.Connect());
+    CleanupClosePushL(usbman);
+    User::LeaveIfError(usbman.GetDescription(CurrentPersonalityID,
+            aDescription));
+    CleanupStack::PopAndDestroy(&usbman);
+    CleanupStack::PushL(aDescription);
+    aHeader = StringLoader::LoadL(R_USB_MODE_MSG_HEADER);
+    CleanupStack::PushL(aHeader);
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetPersonalityStringL completed"));
+    }
+
+// -----------------------------------------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::RunQueryL
+// Run the ask on connection message query
+// -----------------------------------------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::RunQueryL()
+    {
+    FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL()"));
+ 
+    _LIT(KNotificationType,"com.nokia.hb.devicenotificationdialog/1.0");
+    _LIT(KTouchActivation, "touchActivation");
+    _LIT(KIconName, "iconName");
+    _LIT(KTitle, "title");
+    _LIT(KText, "text");
+
+    HBufC* header = NULL;
+    HBufC* description =NULL;   
+    GetPersonalityStringLC(header, description);
+   
+    TFileName usbUiIconFilename( KFileDrive );
+    usbUiIconFilename += KDC_APP_BITMAP_DIR;
+    usbUiIconFilename += KUSBUIconFileName;
+    if( iDialog )
+        {
+        delete iDialog;
+        iDialog = NULL;
+        }
+    iDialog = CHbDeviceDialogSymbian::NewL();
+    CHbSymbianVariantMap *parameters =CHbSymbianVariantMap::NewL();
+    CleanupStack::PushL(parameters);
+
+    AddParameterL(parameters, KTitle, header, CHbSymbianVariant::EDes);
+    AddParameterL(parameters, KText, description, CHbSymbianVariant::EDes);
+    AddParameterL(parameters, KIconName, &usbUiIconFilename, CHbSymbianVariant::EDes);
+    TBool activation=ETrue;
+    AddParameterL(parameters, KTouchActivation, &activation, CHbSymbianVariant::EBool);
+
+    FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL() show") );     
+    TBool error = iDialog->Show(KNotificationType ,*parameters, this);
+    FTRACE( FPrint(
+        _L( "[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL() error = %d" ),
+        error ) );
+
+    CleanupStack::PopAndDestroy(parameters);    
+    CleanupStack::PopAndDestroy(header);
+    CleanupStack::PopAndDestroy(description);
+    
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL completed"));
+    }
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::GetCurrentIdL
+// get the current personality id
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::GetCurrentIdL(TInt& aCurrentPersonality)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetCurrentIdL"));
+    // Connecting and initialization:
+    CRepository* repository = CRepository::NewL(KCRUidUsbWatcher);
+    CleanupStack::PushL(repository);
+    // Get the current USB mode
+    TInt ret = repository->Get(KUsbWatcherPersonality, aCurrentPersonality);
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\t CUSBUICableConnectedNotifier::GetCurrentIdL() ret = %d" ),
+        ret ) );    
+    CleanupStack::PopAndDestroy(repository);
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetCurrentIdL completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::DataReceived
+// launches the QT usb ui setting
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::DataReceived(CHbSymbianVariantMap& aData)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::DataReceived"));
+    _LIT(KResult, "result");
+    _LIT(KActivated, "activated");
+    TInt result = 0;
+    MDesCArray& keys = aData.Keys();
+    HBufC* key = NULL;
+    for(TInt i = 0; i < keys.MdcaCount(); i++)
+        {
+        result = keys.MdcaPoint(i).Compare(KResult); 
+        if (result == 0)
+            {        
+            key = HBufC::New(KResult().Length());
+            if (key)
+                {
+                *key = KResult;            
+                const CHbSymbianVariant* variant = aData.Get(*key);
+                delete key;
+                HBufC* value = static_cast<HBufC*>(variant->Data());
+                result = value->Des().Compare(KActivated);
+                if (result == 0)
+                    {
+                    TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00),
+                            TUid::Uid(KUSBUIUid));
+                    LaunchApplication(KUSBExe(), uidtype);
+                    }
+                break;
+                }
+            }            
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::DeviceDialogClosed
+// ----------------------------------------------------------------------------
+//      
+ void CUSBUICableConnectedNotifier::DeviceDialogClosed(TInt aCompletionCode)
+     {
+     FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::DeviceDialogClosed()"));
+     CompleteMessage(aCompletionCode);  
+     }
+      
+// ---------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::LaunchApplication()
+// launches the application 
+// ---------------------------------------------------------------------------
+//  
+void CUSBUICableConnectedNotifier::LaunchApplication(const TDesC & aProcessName, 
+        const TUidType & aUidType) const
+    {                 
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication()"));
+    RProcess usbUiProcess;                
+    TInt result = usbUiProcess.Create(aProcessName, KNullDesC, aUidType);
+    FTRACE( FPrint(
+        _L( "[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication() result = %d" ),
+        result ) );    
+    usbUiProcess.Resume();
+    usbUiProcess.Close();                     
+    FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication() completed"));             
+    }
+    
+// ---------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::AddParameter()
+// Adds a string parameter to the dialog parameters.
+// ---------------------------------------------------------------------------
+//  
+void CUSBUICableConnectedNotifier::AddParameterL(
+        CHbSymbianVariantMap* aParameters,
+        const TDesC& aKey,
+        const TAny* aData,
+        CHbSymbianVariant::TType aDataType)
+    {
+    FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::AddStringParameter()") );
+    FTRACE( FPrint(
+        _L( "[USBWATCHER]\t CUSBUICableConnectedNotifier::RunQueryL() aKey = %S" ),
+        &aKey ) );
+    CHbSymbianVariant* variant = CHbSymbianVariant::NewL(aData, aDataType);
+    //aParameters takes variant ownership
+    User::LeaveIfError(aParameters->Add(aKey, variant));
+    FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::AddStringParameter() completed") );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinmain.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2005-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:  Methods for USB UI notifiers
+ *
+ */
+
+// INCLUDE FILES
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include <eiknotapi.h>
+#include <eikenv.h>
+
+#include "usbuincableconnectednotifier.h"
+#include "usbuinqueriesnotifier.h"
+#include "usbuinotifdebug.h"
+#include "usbuinotifotgwarning.h"    
+#include "usbuinotifotgerror.h"    
+#include "usbuinotifmsmmerror.h" 
+
+// CONSTANTS
+const TInt KUSBUINotifierArrayIncrement = 5;
+
+// ================= EXPORTED FUNCTIONS =======================================
+// ----------------------------------------------------------------------------
+//
+// Instantiate notifiers
+//
+// ----------------------------------------------------------------------------
+
+void CreateUSBUINotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
+    {
+    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
+
+    CUSBUICableConnectedNotifier* cableConnectedNotifier =
+        CUSBUICableConnectedNotifier::NewL();
+    CleanupStack::PushL( cableConnectedNotifier );
+    aNotifiers->AppendL( cableConnectedNotifier );
+    CleanupStack::Pop( cableConnectedNotifier );
+
+    CUSBUIQueriesNotifier* queriesNotifier = CUSBUIQueriesNotifier::NewL();
+    CleanupStack::PushL( queriesNotifier );
+    aNotifiers->AppendL( queriesNotifier );
+    CleanupStack::Pop( queriesNotifier );
+
+    CUsbUiNotifOtgWarning* generalNote = CUsbUiNotifOtgWarning::NewL();
+    CleanupStack::PushL( generalNote );
+    aNotifiers->AppendL( generalNote );
+    CleanupStack::Pop( generalNote );
+
+    CUsbUiNotifOtgError* generalQuery = CUsbUiNotifOtgError::NewL();
+    CleanupStack::PushL( generalQuery );
+    aNotifiers->AppendL( generalQuery );
+    CleanupStack::Pop( generalQuery );
+    
+    CUsbUiNotifMSMMError* msmmerrorQuery = CUsbUiNotifMSMMError::NewL();
+    CleanupStack::PushL( msmmerrorQuery );
+    aNotifiers->AppendL( msmmerrorQuery );
+    CleanupStack::Pop( msmmerrorQuery );
+
+    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// Creates a notifiers array.
+// ----------------------------------------------------------------------------
+CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
+    {
+    FLOG(_L("[USBUINOTIF]\t NotifierArray"));
+
+    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
+    TRAPD( err, notifiers =
+            new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(
+                    KUSBUINotifierArrayIncrement ));
+
+    if (err == KErrNone)
+        {
+        if (notifiers)
+            {
+            TRAPD( errCreate, CreateUSBUINotifiersL( notifiers ));
+            if (errCreate)
+                {
+                TInt count = notifiers->Count();
+                while (count--)
+                    {
+                    (*notifiers)[count]->Release();
+                    }
+                delete notifiers;
+                notifiers = NULL;
+                }
+
+            FLOG(_L("[USBUINOTIF]\t NotifierArray completed"));
+            }
+        }
+    else
+        {
+        FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!"));
+        }
+
+    return notifiers;
+    }
+
+// ----------------------------------------------------------------------------
+// ECOM 
+// ----------------------------------------------------------------------------
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x10281F23, NotifierArray )
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+        TInt& aTableCount)
+    {
+    FLOG(_L("[USBUINOTIF]\t ImplementationGroupProxy"));
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,207 @@
+/*
+* 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:  USB UI queries notifier class.
+ *
+*/
+
+
+// INCLUDE FILES
+#include <eikenv.h>          // Eikon environment
+#include <bautils.h>         // BAFL utils (for language file)
+#include <utf.h>             // Unicode character conversion utilities
+#include <StringLoader.h>    // Localisation stringloader
+#include <AknQueryDialog.h> 
+#include <aknnotewrappers.h>
+#include <usb/hostms/srverr.h> 
+
+#include <usbuinotif.h>                     // pck
+#include <usbuinotif.rsg>                   // Own resources
+#include "usbuinotifmsmmerror.h"             // Own class definition
+#include "usbuinotifdebug.h"                // Debugging macros
+#include "usbuinotifsecondarydisplay.h"     // Dialog index for cover UI
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifMSMMError* CUsbUiNotifMSMMError::NewL()
+    {
+    CUsbUiNotifMSMMError* self = new (ELeave) CUsbUiNotifMSMMError();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::CUsbUiNotifMSMMError
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifMSMMError::CUsbUiNotifMSMMError() :
+    iStringIds( KUsbUiNotifOtgGeneralQueryGranularity)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifMSMMError::~CUsbUiNotifMSMMError()
+    {
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, 
+    //not to any possibly derived class implementation. 
+    Cancel();
+    }
+
+void CUsbUiNotifMSMMError::ConstructL()
+    {
+    CUSBUINotifierBase::ConstructL();
+    iStringIds.AppendL( R_USB_MSMM_ERROR_GENERAL_MASS_STORAGE_ERROR);
+    iStringIds.AppendL( R_USB_MSMM_ERROR_UNKNOWN_FILESYSTEM);
+    iStringIds.AppendL( R_USB_MSMM_ERROR_OUT_OF_MEMORY);  
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::RegisterL
+// Register notifier.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifMSMMError::TNotifierInfo CUsbUiNotifMSMMError::RegisterL()
+    {
+    iInfo.iUid = KUsbUiNotifMsmmError;
+    iInfo.iChannel = KUsbUiNotifMsmmError;
+    iInfo.iPriority = ENotifierPriorityVHigh;
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::GetParamsL
+//  Jump to RunL as soon as possible.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifMSMMError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+        const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL"));
+    if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage)
+        {
+        User::Leave( KErrInUse );
+        }
+
+    iMessage = aMessage;
+    iNeedToCompleteMessage = ETrue;
+    iReplySlot = aReplySlot;
+
+    // Get parameters 
+    //    
+    THostMsErrData error;
+    TPckgC<THostMsErrData> pckg( error);
+    pckg.Set( aBuffer );
+    switch (pckg().iError)
+        {
+        case  EHostMsErrUnknownFileSystem:
+            iErrorId = EUsbMSMMUnknownFileSystem;
+            break;        
+        case  EHostMsErrOutOfMemory:
+            iErrorId = EUsbMSMMOutOfMemory;
+            break;        
+        default:
+            iErrorId = EUsbMSMMGeneralError;
+        }
+
+    SetActive();
+    iStatus = KRequestPending;
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, KErrNone );
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::RunL
+// Ask user response and return it to caller.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifMSMMError::RunL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL"));
+    TInt returnValue = KErrNone;
+
+    DisableKeylock();
+    SuppressAppSwitching( ETrue );
+
+    //Excute dialog and check return value
+    returnValue = QueryUserResponseL();
+
+    SuppressAppSwitching( EFalse );
+    RestoreKeylock();
+    CompleteMessage( returnValue );
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::Cancel
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifMSMMError::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel"));
+    if (iQuery)
+        {
+        delete iQuery;
+        iQuery = NULL;
+        }
+    CompleteMessage( KErrCancel );
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifMSMMError::QueryUserResponseL
+// Show query dialog. 
+// ----------------------------------------------------------------------------
+//
+TInt CUsbUiNotifMSMMError::QueryUserResponseL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL"));
+    TInt returnValue = KErrNone;
+    TInt resourceId = R_USB_QUERY_OTG_ERROR;
+
+    iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
+
+    if (iCoverDisplaySupported)
+        {
+        iQuery->PublishDialogL( iErrorId, KUsbUiNotifMsmmError );
+        }
+    HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] );
+
+    TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder );
+
+    CleanupStack::PopAndDestroy( stringHolder );
+
+    iQuery = NULL; // Dialog destroyed
+
+    returnValue = keypress ? KErrNone : KErrCancel; //OK?
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL completed"));
+    return returnValue;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinotifotgerror.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,206 @@
+/*
+* 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:  USB UI queries notifier class.
+ *
+*/
+
+
+// INCLUDE FILES
+#include <eikenv.h>          // Eikon environment
+#include <bautils.h>         // BAFL utils (for language file)
+#include <utf.h>             // Unicode character conversion utilities
+#include <StringLoader.h>    // Localisation stringloader
+#include <AknQueryDialog.h> 
+#include <aknnotewrappers.h>
+
+#include <usbuinotif.h>                     // pck
+#include <usbuinotif.rsg>                   // Own resources
+#include "usbuinotifotgerror.h"             // Own class definition
+#include "usbuinotifdebug.h"                // Debugging macros
+#include "usbuinotifsecondarydisplay.h"     // Dialog index for cover UI
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgError* CUsbUiNotifOtgError::NewL()
+    {
+    CUsbUiNotifOtgError* self = new (ELeave) CUsbUiNotifOtgError();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::CUsbUiNotifOtgError
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgError::CUsbUiNotifOtgError() :
+    iStringIds( KUsbUiNotifOtgGeneralQueryGranularity)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgError::~CUsbUiNotifOtgError()
+    {
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to local CUsbUiNotifOtgError::Cancel, 
+    //not to any possibly derived class implementation. 
+    Cancel();
+    }
+
+void CUsbUiNotifOtgError::ConstructL()
+    {
+    CUSBUINotifierBase::ConstructL();
+    iStringIds.AppendL( R_USB_OTG_ERROR_CURRENT_LIMIT);
+    iStringIds.AppendL( R_USB_OTG_ERROR_TOO_MUCH_CURRENT_REQUIRED);
+    iStringIds.AppendL( R_USB_OTG_ERROR_UNSUPPORTED);
+    iStringIds.AppendL( R_USB_OTG_ERROR_HUB_UNSUPPORTED);
+    iStringIds.AppendL( R_USB_OTG_ERROR_UNRECOVERABLE);
+    iStringIds.AppendL( R_USB_OTG_ERROR_ATTACH_TIMEDOUT);
+    iStringIds.AppendL( R_USB_ERROR_MEMORY_NOT_ENOUGH);
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::RegisterL
+// Register notifier.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgError::TNotifierInfo CUsbUiNotifOtgError::RegisterL()
+    {
+    iInfo.iUid = KUsbUiNotifOtgError;
+    iInfo.iChannel = KUsbUiNotifOtgError;
+    iInfo.iPriority = ENotifierPriorityVHigh;
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::GetParamsL
+//  Jump to RunL as soon as possible.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+        const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL"));
+    if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage)
+        {
+        User::Leave( KErrInUse );
+        }
+        
+    // Get parameters 
+    //
+    
+    TPckgC<TInt> pckg( iErrorId );
+    pckg.Set( aBuffer );
+    iErrorId = pckg();
+    
+    FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), iErrorId ));  
+    if ( iErrorId < 0 || iErrorId >= iStringIds.Count() )
+        {        
+        User::Leave( KErrArgument);        
+        }    
+        
+    iMessage = aMessage;
+    iNeedToCompleteMessage = ETrue;
+    iReplySlot = aReplySlot;  
+	  
+    SetActive();
+    iStatus = KRequestPending;
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, KErrNone );
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::RunL
+// Ask user response and return it to caller.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgError::RunL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL"));
+    TInt returnValue = KErrNone;
+
+    DisableKeylock();
+    SuppressAppSwitching( ETrue );
+
+    //Excute dialog and check return value
+    returnValue = QueryUserResponseL();
+
+    SuppressAppSwitching( EFalse );
+    RestoreKeylock();
+    CompleteMessage( returnValue );
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::Cancel
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgError::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel"));
+    if (iQuery)
+        {
+        delete iQuery;
+        iQuery = NULL;
+        }
+    CompleteMessage( KErrCancel );
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::QueryUserResponseL
+// Show query dialog. 
+// ----------------------------------------------------------------------------
+//
+TInt CUsbUiNotifOtgError::QueryUserResponseL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL"));
+    TInt returnValue = KErrNone;
+    TInt resourceId = R_USB_QUERY_OTG_ERROR;
+
+    iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
+
+    if (iCoverDisplaySupported)
+        {
+        iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError );
+        }
+    HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] );
+
+    TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder );
+
+    CleanupStack::PopAndDestroy( stringHolder );
+
+    iQuery = NULL; // Dialog destroyed
+
+    returnValue = keypress ? KErrNone : KErrCancel; //OK?
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL completed"));
+    return returnValue;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinotifotgwarning.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,182 @@
+/*
+* 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:  USB UI notes notifier class.
+ *
+*/
+
+
+// INCLUDE FILES
+#include <eikenv.h>             // Eikon environment
+#include <aknnotedialog.h>
+#include <bautils.h>            // BAFL utils (for language file)
+#include <StringLoader.h>       // Localisation stringloader
+#include <AknMediatorFacade.h>  // for cover display support
+#include <usbuinotif.rsg>       // Own resources
+#include "usbuinotifotgwarning.h"        // Own class definition
+#include "usbuinotifdebug.h"                // Debugging macros
+#include "usbuinotifsecondarydisplay.h"     // Dialog index for cover UI
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgWarning* CUsbUiNotifOtgWarning::NewL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::NewL()"));
+    CUsbUiNotifOtgWarning* self = new (ELeave) CUsbUiNotifOtgWarning();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::NewL completed()"));
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning() :
+    iStringIds( KUsbUiNotifOtgGeneralNoteGranularity), iNote( NULL)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::constructor()"));
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgWarning::~CUsbUiNotifOtgWarning()
+    {
+        FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()"));
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, 
+    //not to any possibly derived class implementation. 
+    Cancel();
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()"));
+    }
+
+void CUsbUiNotifOtgWarning::ConstructL()
+    {
+    CUSBUINotifierBase::ConstructL();
+    iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORT);
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::RegisterL
+// Register notifier.
+// ----------------------------------------------------------------------------
+//
+CUsbUiNotifOtgWarning::TNotifierInfo CUsbUiNotifOtgWarning::RegisterL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RegisterL"));
+    iInfo.iUid = KUsbUiNotifOtgWarning;
+    iInfo.iChannel = KUsbUiNotifOtgWarning;
+    iInfo.iPriority = ENotifierPriorityVHigh;
+        FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RegisterL completed()"));
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::Cancel
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgWarning::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel"));
+    if (iNote)
+        {
+        FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote"));
+        delete iNote;
+        iNote = NULL;
+        }
+    CompleteMessage( KErrNone );
+
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::GetParamsL
+// Mandatory for USB UI Notifiers when using asynchronous launch. 
+// This notifier is synchronous so this function is not used.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgWarning::GetParamsL(const TDesC8& aBuffer,
+        TInt aReplySlot, const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL"));
+    if (iNote || iReplySlot != 0 || iNeedToCompleteMessage)
+        {
+        User::Leave( KErrInUse );
+        }    
+
+    // Get parameters 
+    //    
+    TPckgC<TInt> pckg( iNoteId );
+    pckg.Set( aBuffer );
+    iNoteId = pckg();
+    
+    FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId ));  
+    if ( iNoteId < 0 || iNoteId >= iStringIds.Count() )
+        {        
+        User::Leave( KErrArgument);        
+        }   
+
+    iMessage = aMessage;
+    iNeedToCompleteMessage = ETrue;
+    iReplySlot = aReplySlot;
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, KErrNone );
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgWarning::RunL
+// Mandatory for Active Objects. This notifier is synchronous 
+// so this function is not used.
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgWarning::RunL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL"));
+
+    // Create confirmation note
+    //    
+    HBufC* str = StringLoader::LoadL( iStringIds[iNoteId] );
+    CleanupStack::PushL( str );
+    iNote = new (ELeave) CAknWarningNote( ETrue );
+
+    iNote->SetTimeout( CAknNoteDialog::ENoTimeout );
+
+    if (iCoverDisplaySupported)
+        {
+        iNote->PublishDialogL( iNoteId, KUsbUiNotifOtgWarning );
+        }
+
+    TInt t = iNote->ExecuteLD( *str );
+    iNote = NULL;
+    CleanupStack::PopAndDestroy( str );
+
+    CompleteMessage( KErrNone );
+  FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL() completed"));
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,331 @@
+/*
+ * 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:  USB UI queries notifier class.
+ *
+ */
+
+// INCLUDE FILES
+#include <eikenv.h>          // Eikon environment
+#include <bautils.h>         // BAFL utils (for language file)
+#include <utf.h>             // Unicode character conversion utilities
+#include <StringLoader.h>    // Localisation stringloader
+#include <AknQueryDialog.h> 
+#include <aknnotewrappers.h>
+
+#include <usbuinotif.h>                     // pck
+#include <usbuinotif.rsg>                   // Own resources
+#include "usbuinqueriesnotifiermdrv.h"      // Own class definition
+#include "usbuinotifdebug.h"                // Debugging macros
+#include <SecondaryDisplay/usbuinotifsecondarydisplay.h>     // Dialog index for cover UI
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUSBUIQueriesNotifier* CUSBUIQueriesNotifier::NewL()
+    {
+        FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::NewL"));
+    CUSBUIQueriesNotifier* self = new (ELeave) CUSBUIQueriesNotifier();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::CUSBUIQueriesNotifier
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CUSBUIQueriesNotifier::CUSBUIQueriesNotifier()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CUSBUIQueriesNotifier::~CUSBUIQueriesNotifier()
+    {
+    //Make sure that the request is completed. Note that inside the destructor,
+    //this virtual function call is to local CUSBUIQueriesNotifier::Cancel, 
+    //not to any possibly derived class implementation. 
+    Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::RegisterL
+// Register notifier.
+// ----------------------------------------------------------------------------
+//
+CUSBUIQueriesNotifier::TNotifierInfo CUSBUIQueriesNotifier::RegisterL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RegisterL"));
+    iInfo.iUid = KQueriesNotifier;
+    iInfo.iChannel = KQueriesNotifier;
+    iInfo.iPriority = ENotifierPriorityVHigh; // must be higher than the one 
+        // in cableconnected notifier
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RegisterL completed"));
+    return iInfo;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::StartL
+// Synchronic notifier launch. 
+// ----------------------------------------------------------------------------
+//
+TPtrC8 CUSBUIQueriesNotifier::StartL(const TDesC8& aBuffer)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartL()"));
+
+    TUSBQueriesNotiferParams params; //stores parameters from aBuffef
+    TPckgC<TUSBQueriesNotiferParams> pckg( params );
+    pckg.Set( aBuffer );
+    // Save the type of the query for later use (dialog selection)
+    //
+
+    if (pckg().iQuery == EUSBNoMemoryCard)
+        {
+        TRAPD( err, GetParamsL( aBuffer, 0, iMessage ));
+        if (err)
+            {
+            iNeedToCompleteMessage = EFalse;
+            User::Leave( err );
+            }
+        }
+
+    TPtrC8 ret( KNullDesC8 );
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartL() completed"));
+    return (ret);
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::GetParamsL
+//  Jump to RunL as soon as possible.
+// ----------------------------------------------------------------------------
+//
+void CUSBUIQueriesNotifier::GetParamsL(const TDesC8& aBuffer,
+        TInt aReplySlot, const RMessagePtr2& aMessage)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetParamsL"));
+    if (iUSBQueryDlg || iReplySlot != 0 || iNeedToCompleteMessage)
+        {
+        User::Leave( KErrInUse );
+        }
+
+    iMessage = aMessage;
+    iNeedToCompleteMessage = ETrue;
+    iReplySlot = aReplySlot;
+
+    // Get parameters 
+    //
+    TUSBQueriesNotiferParams params; //stores parameters from aBuffer
+    TPckgC<TUSBQueriesNotiferParams> pckg( params );
+    pckg.Set( aBuffer );
+    // Save the type of the query for later use (dialog selection)
+    //
+    iQueryType = pckg().iQuery;
+    if (iQueryType == EUSBNoMemoryCard)
+        {
+        iNeedToCompleteMessage = EFalse;
+        }
+    // Call SetActive() so RunL() will be called by the active scheduler
+    //
+    SetActive();
+    iStatus = KRequestPending;
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, KErrNone );
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetParamsL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::RunL
+// Ask user response and return it to caller.
+// ----------------------------------------------------------------------------
+//
+void CUSBUIQueriesNotifier::RunL()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RunL"));
+
+    TBool isCancelKey = EFalse;
+    TBool isErrorQuery = EFalse;
+    TInt returnValue = KErrNone;
+    // for cover display support
+    TInt coverDialogId = EUSBCoverInvalidDialogId;
+
+    // Choose text and other query attributes
+    //
+    HBufC* stringHolder = GetQueryAttributesLC( coverDialogId, isCancelKey, isErrorQuery );
+
+    //check if query text string loading was successful
+    if (NULL != stringHolder)
+        {
+        DisableKeylock();
+        SuppressAppSwitching( ETrue );
+        returnValue = QueryUserResponseL( *stringHolder, coverDialogId,
+                isCancelKey, isErrorQuery );
+        SuppressAppSwitching( EFalse );
+        RestoreKeylock();
+        CleanupStack::PopAndDestroy( stringHolder );
+        }
+    else
+        {
+        returnValue = KErrUnknown;
+        }
+
+    CompleteMessage( returnValue );
+    // cancelling the notifier so that next one on the queue can be displayed.
+    // it may be that the client calls cancel too, but it is ok
+    iManager->CancelNotifier( iInfo.iUid );
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RunL() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::Cancel
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUSBUIQueriesNotifier::Cancel()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::Cancel"));
+    if (iUSBQueryDlg)
+        {
+        delete iUSBQueryDlg;
+        iUSBQueryDlg = NULL;
+        }
+    CompleteMessage( KErrCancel );
+
+    CUSBUINotifierBase::Cancel();
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::Cancel() completed"));
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::QueryUserResponseL
+// Show query dialog. 
+// ----------------------------------------------------------------------------
+//
+TInt CUSBUIQueriesNotifier::QueryUserResponseL(const TDesC& aStringHolder,
+        TInt aCoverDialogId, TBool aIsCancelKey, TBool aIsErrorQuery)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL"));
+    TInt returnValue = KErrNone;
+
+    iUSBQueryDlg = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
+
+    // Show dialog with or without the Cancel
+    //
+    if (aIsErrorQuery) 
+        {
+        // aIsErrorQuery flag is set in GetQueryAttributesLC()
+        // there is no defined QueryDialogError in resources so QueryOTGerror is used (contains Stop icon)
+        iUSBQueryDlg->PrepareLC( R_USB_QUERY_OTG_ERROR );
+        }
+    else if (aIsCancelKey)
+        {
+        iUSBQueryDlg->PrepareLC( R_USB_QUERY_WITH_CANCEL );
+        }
+    else
+        {
+        iUSBQueryDlg->PrepareLC( R_USB_QUERY_WITHOUT_CANCEL );
+        }
+
+    if (iCoverDisplaySupported)
+        {
+        iUSBQueryDlg->PublishDialogL( aCoverDialogId, KUSBUINotifCategory );
+        }
+
+    iUSBQueryDlg->SetPromptL( aStringHolder );
+    iUSBQueryDlg->SetFocus( ETrue );
+        FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL calling RunLD"));
+    TInt keypress = iUSBQueryDlg->RunLD();
+
+    iUSBQueryDlg = NULL;
+
+    if (keypress) // User has accepted the dialog
+        {
+        returnValue = KErrNone;
+            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL keypress"));
+        }
+    else
+        {
+        returnValue = KErrCancel;
+            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL NO keypress"));
+        }
+
+        FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL completed"));
+    return returnValue;
+    }
+
+// ----------------------------------------------------------------------------
+// CUSBUIQueriesNotifier::GetQueryAttributesLC
+// Get query text and the other attributes for the query dialog. 
+// ----------------------------------------------------------------------------
+//
+HBufC* CUSBUIQueriesNotifier::GetQueryAttributesLC(TInt& aCoverDialogId,
+        TBool& aIsCancelKey, TBool& aIsErrorQuery)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC"));
+    HBufC* stringHolder = NULL; // The text for the query
+    aIsCancelKey = EFalse;
+    aIsErrorQuery = EFalse;
+    switch (iQueryType)
+        {
+        case EUSBStorageMediaFailure:
+            {
+                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBStorageMediaFailure"));
+            stringHolder = StringLoader::LoadLC( R_USB_STORAGE_MEDIA_FAILURE );
+            aCoverDialogId = EUSBCoverStorageMediaFailure;
+            break;
+            }
+        case EUSBChangeFromMassStorage:
+            {
+                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBChangeFromMassStorage"));
+            stringHolder = StringLoader::LoadLC(
+                    R_USB_CHANGE_FROM_MASS_STORAGE );
+            aIsCancelKey = ETrue;
+            aCoverDialogId = EUSBCoverChangeFromMassStorage;
+            break;
+            }
+        case EUSBNoMemoryCard:
+            {
+                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBNoMemoryCard"));
+            stringHolder = StringLoader::LoadLC( R_USB_NO_MEMORY_CARD );
+            aCoverDialogId = EUSBCoverNoMemoryCard;
+            break;
+            } 
+        case EUSBNotEnoughRam:
+          	{
+            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBNotEnoughRam"));
+            stringHolder = StringLoader::LoadLC( R_USB_ERROR_MEMORY_NOT_ENOUGH );
+            aCoverDialogId = EUSBCoverNoMemoryCard;
+            //set flag to change the icon of querydialog (see QueryUserResponseL())
+            aIsErrorQuery = ETrue;
+            break;
+            }
+        default:
+            {
+                FTRACE( FPrint(
+                                _L( "[USBUINOTIF]\t CUSBUIQueriesNotifier::ERROR! Unknown query type: %d" ),
+                                iQueryType ) );
+            }
+        }
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC completed"));
+    return stringHolder;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/bmarm/usbuinotifapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/bwins/usbuinotifapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -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/usbuis/usbuinotif/tsrc/usbuinotifapitest/conf/ui_usbuinotifapitest.cfg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,230 @@
+/*
+* 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
+*
+*/
+
+// UsbUiNotifApiTest Module - total 21 tc
+
+// UsbUiNotifApiTest Api Tests (... tc)
+
+// Cable connected notifier tests (3)
+
+[Test]
+title USB Ovi Suite Personality Info (Cable Connected Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock CableConnectedNotifierTest PCSUITEMTP
+pause 4000
+delete tester
+[Endtest]
+	
+[Test]
+title USB MS Personality Info (Cable Connected Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock CableConnectedNotifierTest MS
+pause 4000
+delete tester
+[Endtest] 
+			
+[Test]
+title USB MTP Personality Info (Cable Connected Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock CableConnectedNotifierTest MTP
+pause 4000
+delete tester
+[Endtest]
+
+	
+[Test]
+title USB No Memory Card Query Accepted (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBNoMemoryCard
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest]
+
+[Test]
+title USB Storage Media Failure Query Accepted/Device Key Enter Pressed (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBStorageMediaFailure
+pause 3000
+presskey global EKeyEnter
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test] 
+title USB Storage Media Failure Query Accepted/Device Key 0 Pressed (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBStorageMediaFailure
+pause 1000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title USB Change From Mass Storage Query Accepted/Device Key Enter Pressed (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage
+pause 3000
+presskey global EKeyEnter
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest]
+
+[Test]
+title USB Change From Mass Storage Query Accepted/Device Key 0 Pressed (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title USB Change From Mass Storage Query Cancelled (USB Queries Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage
+pause 3000
+presskey global EKeyDevice1
+tester ExecuteApiTestBlock FinishQuery CANCEL
+delete tester
+[Endtest]  
+
+
+[Test]
+title OTG Error too much power (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgTooMuchPower
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Error too much power (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgTooMuchPowerRequired
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Error unsupported device (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgUnsupportedDevice
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Error Hub not supported device (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgHubUnsupported
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Error error in connection (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgErrorInConnection
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Attach timed out (Otg Error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgErrorAttachTimedOut
+pause 3000
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title OTG Partially supported device (Otg Warning Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbOTGWarningNotifierTests EUsbOtgPartiallySupportedDevice
+pause 500
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title Load and Unload notifiers
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock LoadNotifiers
+pause 500
+tester ExecuteApiTestBlock UnLoadNotifiers
+delete tester
+[Endtest] 
+
+[Test]
+title MSMM error test (MSMM error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMGeneralError
+pause 500
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title MSMM error test (MSMM error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMUnknownFileSystem
+pause 500
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+[Test]
+title MSMM error test (MSMM error Notifier Test)
+create UsbUiNotifApiTest tester
+tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMOutOfMemory
+pause 500
+presskey global EKeyDevice0
+tester ExecuteApiTestBlock FinishQuery ACCEPT
+delete tester
+[Endtest] 
+
+// Add new api tests here
+// ...
+
+
+// UsbUiNotifApiTest Module Tests (... tc)
+
+// Add new module tests here
+// ...
+
+
+// UsbUiNotifApiTest Branch Tests (... tc)
+
+// Add new branch tests here
+// ...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/eabi/usbuinotifapitestu.def	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/bld.inf	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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
+usbuinotifapitest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_ats.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -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 usbuinotifapitest.pkg
+call signsis usbuinotifapitest.sis usbuinotifapitest.sisx x:\rd.cer x:\rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_phone.bat	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,24 @@
+@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
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis usbuinotifapitest_phone.pkg
+call signsis usbuinotifapitest_phone.sis usbuinotifapitest_phone.sisx x:\rd.cer x:\rd-key.pem
+call pause
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.mmp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:  TYPE TESTSCRIPT
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          usbuinotifapitest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         usbuinotifapitest.def
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE	../inc 
+USERINCLUDE	../../../inc
+
+SOURCEPATH      ../src
+SOURCE          usbuinotifapitest.cpp
+SOURCE          usbuinotifapitestblocks.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY 		centralrepository.lib
+LIBRARY 		usbman.lib
+LIBRARY 		usbwatcher.lib
+LIBRARY     	ecom.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+;
+; 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.2
+[0x20022E6D], 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/usbuinotifapitest.dll"-"c:/sys/bin/usbuinotifapitest.dll"
+
+"../init/usbuinotifapitest.ini"-"e:/testing/init/usbuinotifapitest.ini"
+"../conf/ui_usbuinotifapitest.cfg"-"e:/testing/conf/ui_usbuinotifapitest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest_phone.pkg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,62 @@
+;
+; 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.2
+[0x20022E6D], 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/usbuinotifapitest.dll"-"c:/sys/bin/usbuinotifapitest.dll"
+
+"../init/usbuinotifapitest_phone.ini"-"c:/testframework/testframework.ini"
+"../conf/ui_usbuinotifapitest.cfg"-"c:/testframework/ui_usbuinotifapitest.cfg"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitest.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,273 @@
+/*
+* 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 USBUINOTIFAPITEST_H
+#define USBUINOTIFAPITEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include <usbuinotif.h>
+#include <usbpersonalityids.h>
+#include <centralrepository.h>
+#include <UsbWatcherInternalCRKeys.h>
+#include <usbman.h>
+#include <usbwatcher.h>
+#include <usb/hostms/srverr.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
+
+// Logging path
+//_LIT( KUsbUiNotifApiTestLogPath, "\\logs\\testframework\\UsbUiNotifApiTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+_LIT( KUsbUiNotifApiTestLogPath, "e:\\testing\\stiflogs\\" ); 
+
+// Log file
+_LIT( KUsbUiNotifApiTestLogFile, "UsbUiNotifApiTest.txt" ); 
+_LIT( KUsbUiNotifApiTestLogFileWithTitle, "UsbUiNotifApiTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CUsbUiNotifApiTest;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TUsbUiNotifApiTestResult
+    {
+    ETestCasePassed,
+    ETestCaseFailed
+    };
+
+enum TTestOption
+    {
+    EQueryDiscarded = 0,
+    EQueryAccepted,
+    EQueryCanceled
+    };
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( TUsbUiNotifApiTestBlockParams )
+    {
+    public:
+        TPtrC iTestBlockName;
+        
+        TPtrC iTestOption1;
+        TPtrC iTestOption2;
+        TPtrC iTestOption3;
+        
+        TInt iTestIntOption1;
+        TInt iTestIntOption2;
+        
+        TChar iTestCharOption1;
+        TChar iTestCharOption2;
+    };
+
+/**
+*  CUsbUiNotifApiTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS( CUsbUiNotifApiTest ) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CUsbUiNotifApiTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUsbUiNotifApiTest();
+
+    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.
+        */
+        CUsbUiNotifApiTest( 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, TUsbUiNotifApiTestResult& aTestResult );    	
+    	void DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult );    
+    	void DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult );
+    	
+        void ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+                 TInt aTestIntOption, TInt aTestCharOption, TUsbUiNotifApiTestResult& aTestResult );
+
+        void CableConnectedNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void ConnectionNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        TInt FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult );
+        void UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult );
+        void Update( TUsbUiNotifApiTestResult& aTestResult );
+        //void Cancelnotifier( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); 
+        void Notifierstart( TUsbUiNotifApiTestResult& aTestResult );
+        //void AsyncConnectionNotifier ( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+        void UsbMSMMNotifierTests ( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult );
+
+        TInt GetTestOption( TPtrC aOptionString, TTestOption& aOption );
+        TInt GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId );
+        TInt GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType );        
+        TInt GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType );
+        TInt GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType );
+        TInt GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType );
+
+        inline void Trace(TRefByValue<const TDesC8> aFmt, ...);
+        inline void Trace(TRefByValue<const TDesC16> aFmt, ...);
+	
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        TUsbUiNotifApiTestBlockParams iTestBlockParams;
+
+        RNotifier *iNotifier;
+        RUsbWatcher* iUsbWatcher;
+ 
+        CRepository* iRepository;
+        
+        TUSBConnectionNotifierParamsPckg iConnectionNotifierResponseParamsPckg;
+        TRequestStatus iReqStatus;
+        TInt iPersonalityIdBackup;
+        TBool iCompleteQuery;        
+        TPckg<TInt> iRes;
+        CArrayPtr<MEikSrvNotifierBase2>* iNotifierArray;
+        TUid iInstanceUid;
+        THostMsErrData iErrData;
+        THostMsErrorDataPckg iErrPckg ;
+
+        // 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;
+        
+    };
+
+#include "UsbUiNotifApiTestDebug.inl"
+
+#endif      // USBUINOTIFAPITEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitestdebug.inl	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* 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 <e32debug.h>
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/) {}
+    }; 
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/) {}
+    };
+
+
+_LIT8(KStifTestPrefix8, "[STIF_LOG] ");
+_LIT(KStifTestPrefix, "[STIF_LOG] ");
+
+const TInt KMaxLogLineLength = 512;
+
+#define TRACE_INFO(p) { Trace p; }
+
+void CUsbUiNotifApiTest::Trace(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TOverflowTruncate8 overflow;        
+	RBuf8 buf8;
+	buf8.Create( KMaxLogLineLength );
+	buf8.Append( KStifTestPrefix8 );
+	buf8.AppendFormatList(aFmt, list, &overflow);
+			
+	RBuf16 buf16;
+	buf16.Create( KMaxLogLineLength );
+	buf16.Copy(buf8);    
+	TRefByValue<const TDesC> tmpFmt(_L("%S"));
+	RDebug::Print(tmpFmt, &buf16);
+	iLog->Log(tmpFmt, &buf16);
+	buf8.Close();         
+	buf16.Close();
+	};
+
+void CUsbUiNotifApiTest::Trace(TRefByValue<const TDesC16> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list,aFmt);
+	RBuf16 theFinalString;
+	theFinalString.Create( KMaxLogLineLength );
+	theFinalString.Append( KStifTestPrefix );
+	TOverflowTruncate16 overflow;
+	theFinalString.AppendFormatList(aFmt,list,&overflow);
+	RDebug::Print(theFinalString);
+	iLog->Log(theFinalString);
+	theFinalString.Close(); 
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -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= UsbUiNotifApiTest_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= UsbUiNotifApiTestUsbUiNotifApiTestUsbUiNotifApiTest
+# 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\ui_USBUiNotifApiTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbUiNotifApiTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbUiNotifApiTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUsbUiNotifApiTest 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/usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest_phone.ini	Fri Jun 04 10:27:39 2010 +0100
@@ -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\UsbUiNotifApiTest\
+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= UsbUiNotifApiTestUsbUiNotifApiTestUsbUiNotifApiTest
+# 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\ui_UsbUiNotifApiTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbUiNotifApiTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbUiNotifApiTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUsbUiNotifApiTest 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/usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitest.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,207 @@
+/*
+* 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 "UsbUiNotifApiTest.h"
+#include <SettingServerClient.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::CUsbUiNotifApiTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUsbUiNotifApiTest::CUsbUiNotifApiTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf ),
+        iRes(0)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUsbUiNotifApiTest::ConstructL()
+    {
+    //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(KUsbUiNotifApiTestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KUsbUiNotifApiTestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KUsbUiNotifApiTestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    SendTestClassVersion();
+
+    iNotifier = new ( ELeave ) RNotifier();
+    iUsbWatcher = new ( ELeave ) RUsbWatcher();
+    iRepository = CRepository::NewL( KCRUidUsbWatcher );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbUiNotifApiTest* CUsbUiNotifApiTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CUsbUiNotifApiTest* self = new (ELeave) CUsbUiNotifApiTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CUsbUiNotifApiTest::~CUsbUiNotifApiTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+//-----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CUsbUiNotifApiTest::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("UsbUiNotifApiTest.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* ) CUsbUiNotifApiTest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitestblocks.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,976 @@
+/*
+* 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 <ecom/ecom.h>
+#include <Stiftestinterface.h>
+#include "UsbUiNotifApiTest.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CUsbUiNotifApiTest::Delete() 
+	{
+    iNotifier -> Close();
+    delete iNotifier;
+    iNotifier = NULL;
+    iUsbWatcher -> Close();
+    delete iUsbWatcher;
+    iUsbWatcher = NULL;
+    delete iRepository;
+    iRepository = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CUsbUiNotifApiTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+		ENTRY( "ExecuteApiTestBlock", CUsbUiNotifApiTest::ExecuteApiTestBlock ),
+        ENTRY( "ExecuteModuleTestBlock", CUsbUiNotifApiTest::ExecuteModuleTestBlock ),
+        ENTRY( "ExecuteBranchTestBlock", CUsbUiNotifApiTest::ExecuteBranchTestBlock ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetTestBlockParamsL
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::GetTestBlockParamsL( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>> 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( "CableConnectedNotifierTest" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) )
+		{                           
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) )
+		{                      
+		}
+	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) )
+		{                      
+		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+		}
+    else
+        {
+        TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    TRACE_INFO( _L("<<< GetTestBlockParamsL") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::ExecuteApiTestBlock
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::ExecuteApiTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>> ExecuteApiTestBlock") );
+	
+	TInt res;
+    TUsbUiNotifApiTestResult testResult = ETestCaseFailed;
+	
+    TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    
+    TRACE_INFO( _L("<<< ExecuteApiTestBlock") );
+	
+    return KErrNone;
+    }
+	
+	
+void CUsbUiNotifApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") );
+
+	User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) );
+        TRACE_INFO( (_L("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 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) )
+        {      
+        CableConnectedNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
+        {      
+        UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) )
+        {      
+        FinishQuery( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
+        {      
+        UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
+        {      
+        UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
+        {      
+        UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) )
+        {      
+        UsbOTGErrorNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) )
+        {      
+        UsbOTGWarningNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) )
+        {      
+        LoadNotifiersL( aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) )
+        {      
+        UnLoadNotifiers( aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) )
+        {      
+        UsbMSMMNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else
+        {
+    TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+	
+    TRACE_INFO( _L("<<<DoExecuteApiTestBlockL") );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::ExecuteModuleTestBlock
+// -----------------------------------------------------------------------------	
+
+TInt CUsbUiNotifApiTest::ExecuteModuleTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>>ExecuteModuleTestBlock") );
+	
+    TInt res;
+    TUsbUiNotifApiTestResult testResult;
+    
+    TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    TRACE_INFO( _L("<<<ExecuteModuleTestBlock") );
+    return KErrNone;
+    }	
+	
+	
+void CUsbUiNotifApiTest::DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteModuleTestBlockL") );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    TRACE_INFO( (_L("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
+        {
+    TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    
+    TRACE_INFO( _L("<<<DoExecuteModuleTestBlockL") );
+    }
+	
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::ExecuteBranchTestBlock
+// -----------------------------------------------------------------------------
+	
+TInt CUsbUiNotifApiTest::ExecuteBranchTestBlock( CStifItemParser& aItem )
+    {
+    TRACE_INFO( _L(">>>ExecuteBranchTestBlock") );
+	
+    TInt res;
+    TUsbUiNotifApiTestResult testResult;
+    
+    TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) );
+        return res;
+        }   
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    TRACE_INFO( _L("Test case passed") );
+    TRACE_INFO( _L("<<<ExecuteBranchTestBlock") );
+    return KErrNone;
+    }
+
+	
+void CUsbUiNotifApiTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>DoExecuteBranchTestBlockL") );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    TRACE_INFO( (_L("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
+        {
+    TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") );
+        User::Leave( KErrNotFound );
+        }
+    
+    TRACE_INFO( _L("<<<DoExecuteBranchTestBlockL") );
+    }
+
+// Add test block methods implementation here
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::ExampleTestL
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+        TInt aTestIntOption, TInt aTestCharOption, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO( _L(">>>ExampleTestL") );
+    
+    if ( !aTestOption.Compare( _L( "API" ) ) )
+        {
+    TRACE_INFO( (_L("Api test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Api test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Api test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Api test char option: %c"), aTestCharOption) );
+        }
+    else if ( !aTestOption.Compare( _L( "MODULE" ) ) )
+        {
+    TRACE_INFO( (_L("Module test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Module test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Module test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Module test char option: %c"), aTestCharOption) );
+        }
+    else if ( !aTestOption.Compare( _L( "BRANCH" ) ) )
+        {
+    TRACE_INFO( (_L("Branch test option: %S"), &aTestOption) );
+    TRACE_INFO( (_L("Branch test sub-option: %S"), &aTestSubOption) );
+    TRACE_INFO( (_L("Branch test int option: %d"), aTestIntOption) );
+    TRACE_INFO( (_L("Branch test char option: %c"), aTestCharOption) );
+        }
+    else
+        {
+        TRACE_INFO( _L("Invalid test parameter") );
+        User::Leave( KErrNotFound );
+        }
+    
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO( _L("<<<ExampleTestL") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::CableConnectedNotifierTest
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::CableConnectedNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>CableConnectedNotifierTest") );
+    
+    TInt res;
+    TUSBConnectionNotifierParamsPckg emptyNotifierInputPckg;
+    TPtrC displayedUsbPersonalityName( KNullDesC );
+    TInt displayedUsbPersonalityId;
+    
+    res = GetPersonalityIdFromString( aTestSubOption, displayedUsbPersonalityId );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("GetPersonalityIdFromString failed with value: %d"), res) );
+        return;
+        }
+    
+    res = iRepository -> Get( KUsbWatcherPersonality, iPersonalityIdBackup );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Personality backup failed with value (cenrep): %d"), res) );
+        return;
+        }
+    
+    res = iUsbWatcher -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect UsbWatcher with value: %d"), res) );
+        return;
+        }   
+    TRACE_INFO(  _L("UsbWatcher connected") );
+        
+    iUsbWatcher -> SetPersonality( iReqStatus, displayedUsbPersonalityId, ETrue, ETrue );
+    User::WaitForRequest( iReqStatus );
+    if ( iReqStatus.Int() != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to set usb personality with value: %d"), iReqStatus.Int()) );
+        iUsbWatcher -> Close();
+        return;
+        }   
+    
+    res = iNotifier -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
+        iUsbWatcher -> Close();
+        return;
+        }   
+    TRACE_INFO(  _L("RNotifier connected") );
+
+    iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, emptyNotifierInputPckg, iConnectionNotifierResponseParamsPckg );    
+    User::WaitForRequest( iReqStatus );
+    
+    TRACE_INFO((_L("StartNotifierAndGetResponse Status: %d, expected: %d"), iReqStatus.Int(), KErrCancel));
+    if(iReqStatus.Int() == KErrCancel)
+    	aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<CableConnectedNotifierTest") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::UsbQueriesNotifierTest
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>UsbQueriesNotifierTest") );
+    TInt res;    
+    TUSBUIQueries usbQueryType;
+    
+    
+    res = GetQueryType( aTestSubOption, usbQueryType );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("GetQueryType failed with value: %d"), res) );
+        return;
+        }
+    
+    TUSBQueriesNotiferParams notifierParams;
+    notifierParams.iDrive = 'c';
+    notifierParams.iQuery = usbQueryType;
+    TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams );
+    TPckgBuf<TBool> output;
+    
+    res = iNotifier -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
+        return;
+        }   
+    TRACE_INFO(  _L("RNotifier connected") );
+    
+    switch( usbQueryType )
+        {
+        case EUSBNoMemoryCard:
+            iCompleteQuery = ETrue;
+            break;
+        case EUSBStorageMediaFailure:
+        case EUSBChangeFromMassStorage:
+            iCompleteQuery = EFalse;
+            break;
+        default:
+            break; 
+        }
+    
+    iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, notifierParamsPckg, output ); 
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<UsbQueriesNotifierTest") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::UsbOTGErrorNotifierTests
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>UsbOTGErrorNotifierTests") );
+    
+    TInt res;    
+    TUsbUiNotifOtgError usbOTGErrorType;
+        
+    res = GetOTGErrorType( aTestSubOption, usbOTGErrorType );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("usbOTGErrorType failed with value: %d"), res) );
+        return;
+        }    
+    
+    res = iNotifier -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
+        return;
+        }   
+    TRACE_INFO(  _L("RNotifier connected") );
+    
+    TPckgBuf<TInt> notifierParamsPckg;
+    notifierParamsPckg() = usbOTGErrorType;
+    iCompleteQuery = EFalse;
+
+    iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, notifierParamsPckg, iRes ); 
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<UsbOTGErrorNotifierTests") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::UsbOTGWarningNotifierTests
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {        
+    TRACE_INFO(  _L(">>>UsbOTGWarningNotifierTests") );
+    
+    TInt res;    
+    TUsbUiNotifOtgWarning usbOTGWarningType;
+    
+    
+    res = GetOTGWarningType( aTestSubOption, usbOTGWarningType );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("usbOTGErrorType failed with value: %d"), res) );
+        return;
+        }    
+    
+    res = iNotifier -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
+        return;
+        }   
+    TRACE_INFO(  _L("RNotifier connected") );
+    
+    TPckgBuf<TInt> notifierParamsPckg;
+    notifierParamsPckg() = usbOTGWarningType;
+    iCompleteQuery = EFalse;
+
+    iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); 
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<UsbOTGWarningNotifierTests") ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::UsbMSMMNotifierTests
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::UsbMSMMNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {        
+    TRACE_INFO(  _L(">>>UsbMSMMNotifierTests") );
+    
+    TInt res;    
+    THostMsErrCode usbMSMMNErrorType;
+    
+    res = GetMSMMrrorType( aTestSubOption, usbMSMMNErrorType );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("MSMMrrorType failed with value: %d"), res) );
+        return;
+        }    
+    iErrData.iError=usbMSMMNErrorType;
+    iErrPckg = iErrData;
+    res = iNotifier -> Connect();
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
+        return;
+        }   
+    TRACE_INFO(  _L("RNotifier connected") );
+    
+    TPckgBuf<TInt> notifierParamsPckg;
+    notifierParamsPckg() = usbMSMMNErrorType;
+    iCompleteQuery = EFalse;
+
+    iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); 
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<UsbMSMMNotifierTests") ); 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::FinishQuery
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>FinishQuery") ); 
+    
+    TInt res;
+    TTestOption option;
+    
+    if ( iCompleteQuery )
+        {
+        TRequestStatus* statPtr = &iReqStatus;
+        User::RequestComplete( statPtr, KErrNone );
+        }    
+    
+    res = GetTestOption( aTestSubOption, option );
+    if ( res != KErrNone )
+        {
+        TRACE_INFO(  (_L("GetTestOption failed with value: %d"), res) );
+        iNotifier -> Close();
+        return res;
+        }
+    
+    User::WaitForRequest( iReqStatus );   
+    iNotifier -> Close();
+    
+    switch( option )
+        {
+        case EQueryAccepted:
+            TRACE_INFO(  (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone) );
+            STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
+            break;
+        case EQueryCanceled:
+            TRACE_INFO(  (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel) );
+            STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
+            break;
+        default:
+            return KErrNotFound;
+        }
+    
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<FinishQuery") ); 
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::LoadNotifiersL
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>LoadNotifiersL") );
+    
+    iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>(
+												REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid));
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<LoadNotifiersL") ); 	
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::UnLoadNotifiers
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>UnLoadNotifiers") );
+    
+    TInt count = iNotifierArray->Count();
+    TInt i=0;
+    for (i=0; i<count; i++)
+        {
+        iNotifierArray->At(i)->Release();        
+        }
+    iNotifierArray->Reset();    
+    delete iNotifierArray;
+    REComSession::DestroyedImplementation(iInstanceUid);    
+
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<UnLoadNotifiers") ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::Update
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::Update( TUsbUiNotifApiTestResult& aTestResult  )
+    {
+    TRACE_INFO(  _L(">>>Update") );
+    TInt count = iNotifierArray->Count();
+    TInt i=0;    
+    _LIT8(test, "test");
+    TBuf8<32> buf(test);
+    for (i=0; i<count; i++)
+        {
+        iNotifierArray->At(i)->UpdateL(buf);        
+        }    
+    
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<Update") );
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::Notifierstart
+// -----------------------------------------------------------------------------
+
+void CUsbUiNotifApiTest::Notifierstart( TUsbUiNotifApiTestResult& aTestResult )
+    {
+    TRACE_INFO(  _L(">>>Notifierstart") );
+    TInt count = iNotifierArray->Count();
+    TInt i=0;    
+    _LIT8(test, "test");
+    TBuf8<32> buf(test);
+    for (i=0; i<count; i++)
+        {
+        iNotifierArray->At(i)->StartL(buf);        
+        }
+    
+    aTestResult = ETestCasePassed;
+    
+    TRACE_INFO(  _L("<<<Notifierstart") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetQueryType
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType )
+    {
+    TRACE_INFO(  _L(">>>GetQueryType") );
+    if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) )
+        {
+        aQueryType = EUSBNoMemoryCard;
+        TRACE_INFO(  _L("Query type: EUSBNoMemoryCard") );
+        }
+    else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) )
+        {
+        aQueryType = EUSBStorageMediaFailure;
+        TRACE_INFO(  _L("Query type: EUSBStorageMediaFailure") );
+        }
+    else if ( !aTypeString.Compare( _L( "EUSBChangeFromMassStorage" ) ) )
+        {
+        aQueryType = EUSBChangeFromMassStorage;
+        TRACE_INFO(  _L("Query type: EUSBChangeFromMassStorage") );
+        }    
+    else
+        {
+        TRACE_INFO(  _L("Query type: not supported") );
+        return KErrNotFound;
+        }
+    TRACE_INFO(  _L("<<<GetQueryType") );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetOTGErrorType
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType )
+    {
+    TRACE_INFO(  _L(">>>GetOTGErrorType") );
+    
+    if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) )
+        {
+        aQueryType = EUsbOtgTooMuchPower;
+        TRACE_INFO(  _L("Query type: EUsbOtgTooMuchPower") );
+        }    
+    else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) )
+        {
+        aQueryType = EUsbOtgTooMuchPowerRequired;
+        TRACE_INFO(  _L("Query type: EUsbOtgTooMuchPowerRequired") );
+        }    
+    else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) )
+        {
+        aQueryType = EUsbOtgUnsupportedDevice;
+        TRACE_INFO(  _L("Query type: EUsbOtgUnsupportedDevice") );
+        }        
+    else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) )
+        {
+        aQueryType = EUsbOtgHubUnsupported;
+        TRACE_INFO(  _L("Query type: EUsbOtgHubUnsupported") );
+        }            
+    else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) )
+        {
+        aQueryType = EUsbOtgErrorInConnection;
+        TRACE_INFO(  _L("Query type: EUsbOtgErrorInConnection") );
+        }                
+    else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) )
+        {
+        aQueryType = EUsbOtgErrorAttachTimedOut;
+        TRACE_INFO(  _L("Query type: EUsbOtgErrorAttachTimedOut") );
+        }                    
+    else
+        {
+        TRACE_INFO(  _L("Query type: not supported") );
+        return KErrNotFound;
+        } 
+    
+    TRACE_INFO(  _L("<<<GetOTGErrorType") );
+    return KErrNone;    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetOTGWarningType
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType )
+    {        
+    TRACE_INFO(  _L(">>>GetOTGWarningType") );
+    
+    if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) )
+        {            
+        aQueryType = EUsbOtgPartiallySupportedDevice;
+        TRACE_INFO(  _L("Query type: EUsbOtgPartiallySupportedDevice;") );
+        }    
+    else
+        {
+        TRACE_INFO(  _L("Query type: not supported") );
+        return KErrNotFound;
+        }
+
+    TRACE_INFO(  _L("<<<GetOTGWarningType") );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetMSMMrrorType
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType )
+    {        
+    TRACE_INFO(  _L(">>>GetMSMMrrorType") );
+    if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) )
+        {            
+        aQueryType = EHostMsErrGeneral;
+        TRACE_INFO(  _L("Query type: EUsbOtgPartiallySupportedDevice;") );
+        }    
+    else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) )
+        {
+        aQueryType = EHostMsErrUnknownFileSystem;
+        TRACE_INFO(  _L("Query type: EUsbMSMMUnknownFileSystem") );
+        }         
+    else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) )
+        {
+        aQueryType = EHostMsErrOutOfMemory;
+        TRACE_INFO(  _L("Query type: EUsbMSMMOutOfMemory") );
+        }     
+    else
+        {
+        TRACE_INFO(  _L("Query type: not supported") );
+        return KErrNotFound;
+        }
+
+    TRACE_INFO(  _L("<<<GetMSMMrrorType") );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetTestOption
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption )
+    {    
+    if ( !aOptionString.Compare( _L( "DISCARD" ) ) )
+        {
+        aOption = EQueryDiscarded;
+        TRACE_INFO(  _L("Test type: EQueryDiscarded") );
+        }
+    else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) )
+        {
+        aOption = EQueryAccepted;
+        TRACE_INFO(  _L("Test type: EQueryAccepted") );
+        }
+    else if ( !aOptionString.Compare( _L( "CANCEL" ) ) )
+        {
+        aOption = EQueryCanceled;
+        TRACE_INFO(  _L("Test type: EQueryCanceled") );
+        }
+    else
+        {
+        TRACE_INFO(  _L("Test type: not supported") );
+        return KErrNotFound;
+        }
+ 
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUsbUiNotifApiTest::GetPersonalityIdFromString
+// -----------------------------------------------------------------------------
+
+TInt CUsbUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId )
+    {    
+    if ( !aOptionString.Compare( _L( "MS" ) ) )
+        {
+        aPersonalityId = KUsbPersonalityIdMS;
+        TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdMS") );
+        }
+    else if ( !aOptionString.Compare( _L( "PCSUITE" ) ) )
+        {
+        aPersonalityId = KUsbPersonalityIdPCSuite;
+        TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdPCSuite") );
+        }
+    else if ( !aOptionString.Compare( _L( "MTP" ) ) )
+        {
+        aPersonalityId = KUsbPersonalityIdMTP;
+        TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdMTP") );
+        }
+    else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) )
+        {
+        aPersonalityId = KUsbPersonalityIdPCSuiteMTP;
+        TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") );
+        }
+    else
+        {
+        TRACE_INFO(  _L("Usb personality type: not found") );
+        return KErrNotFound;  
+        }
+ 
+    return KErrNone;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/icons/usb_icon_mode_2.svg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="42" height="36" viewBox="-0.014 0.037 42 36">
+<rect fill="none" height="36" width="42" x="-0.014" y="0.037"/>
+<linearGradient id="SVGID_1" gradientUnits="userSpaceOnUse" x1="18.75" y1="11.54" x2="24.96" y2="27.67">
+<stop stop-color="#AABBD7" offset="0"/>
+<stop stop-color="#92A5CC" offset="0.26"/>
+<stop stop-color="#6C83BB" offset="0.71"/>
+<stop stop-color="#637DB5" offset="0.76"/>
+<stop stop-color="#4C6EA4" offset="0.83"/>
+<stop stop-color="#265689" offset="0.91"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<path d="M18.823,33.49c-0.028-0.01-0.053-0.021-0.077-0.037l0,0L8.569,28.85 c-0.093-0.043-0.157-0.125-0.171-0.225l0,0L7.83,25.033c-0.012-0.076,0.006-0.154,0.05-0.217l0,0l2.553-3.664l-0.393-3.671 c-0.01-0.082,0.016-0.164,0.068-0.226l0,0l9.84-11.568c1.962-1.956,4.492-2.737,6.807-2.735l0,0c0.896,0,1.76,0.117,2.553,0.329l0,0 c1.481,0.4,2.965,1.106,3.795,2.34l0,0c0.041,0.019,0.078,0.046,0.107,0.081l0,0c0.023,0.029,1.199,1.456,1.201,3.82l0,0 c0,0.34-0.022,0.699-0.078,1.077l0,0c-0.18,1.202-0.634,2.678-0.921,3.342l0,0l-7.986,14.282c-0.018,0.072-0.062,0.135-0.124,0.178 l0,0c-0.053,0.033-0.115,0.051-0.176,0.049l0,0c-0.025,0-0.05-0.004-0.074-0.01l0,0c-0.035-0.008-0.067-0.023-0.096-0.043l0,0 l-1.992-0.879l-3.774,5.799c-0.023,0.059-0.065,0.107-0.119,0.141l0,0c-0.034,0.02-0.07,0.033-0.107,0.039l0,0 c-0.001,0.002-0.003,0.002-0.004,0.002l0,0c-0.002,0-0.004,0-0.006,0l0,0c-0.015,0.002-0.03,0.004-0.045,0.004l0,0 C18.879,33.502,18.851,33.498,18.823,33.49L18.823,33.49z M32.753,6.081l0.179-0.148L32.753,6.081L32.753,6.081z" fill="url(#SVGID_1)"/>
+<linearGradient id="SVGID_2" gradientUnits="userSpaceOnUse" x1="27.94" y1="30.01" x2="8.42" y2="15.5">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#E0EAF3" offset="0.11"/>
+<stop stop-color="#A2C2DD" offset="0.35"/>
+<stop stop-color="#8CA9CF" offset="0.48"/>
+<stop stop-color="#6C83BB" offset="0.7"/>
+<stop stop-color="#637DB5" offset="0.75"/>
+<stop stop-color="#4C6EA4" offset="0.82"/>
+<stop stop-color="#265689" offset="0.91"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<polygon fill="url(#SVGID_2)" points="25.137,28.184 10.806,21.869 10.334,17.479 25.108,23.307 "/>
+<linearGradient id="SVGID_3" gradientUnits="userSpaceOnUse" x1="35.78" y1="4.5" x2="22.33" y2="31.13">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#E0EAF3" offset="0.11"/>
+<stop stop-color="#A2C2DD" offset="0.35"/>
+<stop stop-color="#8CA9CF" offset="0.48"/>
+<stop stop-color="#6C83BB" offset="0.7"/>
+<stop stop-color="#637DB5" offset="0.75"/>
+<stop stop-color="#4C6EA4" offset="0.82"/>
+<stop stop-color="#265689" offset="0.91"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<path d="M25.117,23.307l7.864-17.383c0,0,1.487,1.795,1.058,4.664c-0.174,1.164-0.627,2.644-0.887,3.241 l-8.027,14.355L25.117,23.307z" fill="url(#SVGID_3)"/>
+<linearGradient id="SVGID_4" gradientUnits="userSpaceOnUse" x1="15.76" y1="-3.13" x2="28.63" y2="29.22">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#F4F8FB" offset="0.19"/>
+<stop stop-color="#D6E4F0" offset="0.52"/>
+<stop stop-color="#A7C5DF" offset="0.96"/>
+<stop stop-color="#A2C2DD" offset="1"/>
+</linearGradient>
+<path d="M29.23,3.599c-2.747-0.735-6.439-0.292-9.072,2.331l-9.825,11.549l14.774,5.828l7.753-13.183 C34.642,6.166,31.987,4.338,29.23,3.599z" fill="url(#SVGID_4)"/>
+<linearGradient id="SVGID_5" gradientUnits="userSpaceOnUse" x1="25.22" y1="23.12" x2="19.08" y2="11.35">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#C6DCC1" offset="0.08"/>
+<stop stop-color="#91C06F" offset="0.21"/>
+<stop stop-color="#6BAB33" offset="0.32"/>
+<stop stop-color="#539E0E" offset="0.4"/>
+<stop stop-color="#4A9900" offset="0.44"/>
+<stop stop-color="#398419" offset="0.55"/>
+<stop stop-color="#22663B" offset="0.71"/>
+<stop stop-color="#135550" offset="0.85"/>
+<stop stop-color="#0E4E58" offset="0.94"/>
+</linearGradient>
+<path d="M22.05,10.979l-0.616,0.813l3.756,1.229l-2.353,3.107l1.332,0.439l0.696-0.922l2.916,0.965 l-2.067,2.724l-2.899-0.958l0.688-0.923l-6.795-2.236l-0.678,0.935c-0.483-0.736-1.019-1.479-1.515-2.136 c1.078-0.14,2.283-0.313,3.448-0.509l-0.601,0.818l4.521,1.486l1.672-2.219l-2.791-0.916l-0.61,0.814 c-0.477-0.732-1.006-1.473-1.5-2.13C19.741,11.225,20.968,11.053,22.05,10.979z" fill="url(#SVGID_5)"/>
+<linearGradient id="SVGID_6" gradientUnits="userSpaceOnUse" x1="19.37" y1="27.94" x2="-19.75" y2="-11.18">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#000000" offset="1"/>
+</linearGradient>
+<polygon fill="url(#SVGID_6)" points="23.084,23.328 18.86,29.619 8.123,25.02 12.285,19.045 "/>
+<polygon fill="#4D4D4D" points="14.777,23.287 13.833,24.76 11.07,23.572 12.019,22.139 "/>
+<polygon fill="#4D4D4D" points="20.001,25.482 19.064,27.021 16.364,25.848 17.304,24.344 "/>
+<linearGradient id="SVGID_7" gradientUnits="userSpaceOnUse" x1="17.97" y1="37.85" x2="26.77" y2="9.05">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#000000" offset="1"/>
+</linearGradient>
+<polygon fill="url(#SVGID_7)" points="18.873,29.617 23.084,23.328 22.852,27.178 18.908,33.236 "/>
+<linearGradient id="SVGID_8" gradientUnits="userSpaceOnUse" x1="18.44" y1="33.76" x2="-1.24" y2="14.08">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#000000" offset="1"/>
+</linearGradient>
+<polygon fill="url(#SVGID_8)" points="18.915,33.236 8.691,28.611 8.123,25.02 18.879,29.602 "/>
+<polygon fill="#FFFFFF" points="18.23,32.199 9.25,28.139 9.049,27.063 18.177,31.076 "/>
+<linearGradient id="SVGID_9" gradientUnits="userSpaceOnUse" x1="19.28" y1="1.82" x2="32.69" y2="8.11">
+<stop stop-color="#A2C2DD" offset="0.1"/>
+<stop stop-color="#6C83BB" offset="0.71"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<path d="M24.564,5.472l6.489,1.948c0,0,0.749-1.301-2.161-2.179C25.981,4.364,24.564,5.472,24.564,5.472z" fill="url(#SVGID_9)"/>
+</svg>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/icons/usb_icon_mode_4.svg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="42" height="36" viewBox="0 0 42 36">
+<rect fill="none" height="36" width="42"/>
+<linearGradient id="SVGID_1" gradientUnits="userSpaceOnUse" x1="4.34" y1="18" x2="37.66" y2="18">
+<stop stop-color="#A1C1DC" offset="0.1"/>
+<stop stop-color="#6C82B9" offset="0.71"/>
+<stop stop-color="#173F6C" offset="0.99"/>
+</linearGradient>
+<path d="M12.842,34.012l-0.057-0.078l-6.937-9.3l-0.042-0.059l-1.405-1.881L4.37,22.653v-0.052l-0.027-0.858 L4.34,21.59l0.149-0.015c1.725-0.188,3.256-0.634,4.676-1.372c0.68-1.623,2.405-2.95,4.057-3.121 c0.235-0.238,0.481-0.492,0.747-0.774L11.079,2.388L11.044,2.23l0.157-0.033l0.762-0.172l0.159-0.036l0.037,0.159 c0.482,2.094,1.557,2.859,2.694,3.67l0.098,0.07c0.172,0.12,0.348,0.243,0.523,0.364c1.704,1.185,3.464,2.408,3.86,5.01 c1.691-1.087,3.54-1.699,5.645-1.868l0.047-0.002l0.042,0.024l1.62,0.889l0.319,0.174l0.527,0.289l1.251,0.686l8.768,4.814 l0.106,0.057l-0.018,0.131l-0.219,1.099l-0.022,0.118l-0.125,0.013c-5.685,0.518-8.448,3.993-11.377,7.671 c-3.057,3.844-6.22,7.818-12.963,8.643L12.842,34.012L12.842,34.012z M13.666,8.596L15,15.196c0.997-1.081,2.029-2.183,3.198-3.116 C17.83,10.181,16.425,9.099,13.666,8.596L13.666,8.596z" fill="url(#SVGID_1)"/>
+<linearGradient id="SVGID_2" gradientUnits="userSpaceOnUse" x1="25.09" y1="3.25" x2="18.28" y2="29.64">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#486EA2" offset="0.71"/>
+<stop stop-color="#225487" offset="0.99"/>
+</linearGradient>
+<path d="M4.504,21.748c10.374-1.113,10.566-11.391,20.483-12.18l12.506,6.863 c-12.585,1.681-11.545,14.341-24.322,16.136L4.504,21.748z" fill="url(#SVGID_2)"/>
+<linearGradient id="SVGID_3" gradientUnits="userSpaceOnUse" x1="11.67" y1="27.2" x2="22.42" y2="12.96">
+<stop stop-color="#DEE8F1" offset="0"/>
+<stop stop-color="#225487" offset="1"/>
+</linearGradient>
+<path d="M6.254,23.966c1.579-0.102,5.475-0.806,8.816-4.604l6.127,5.619c-2.307,2.884-6.286,5.21-9.765,5.507 L6.254,23.966z" fill="url(#SVGID_3)"/>
+<linearGradient id="SVGID_4" gradientUnits="userSpaceOnUse" x1="22.63" y1="18.3" x2="16.39" y2="28">
+<stop stop-color="#DEE8F1" offset="0"/>
+<stop stop-color="#225487" offset="1"/>
+</linearGradient>
+<path d="M15.837,18.577c1.691-1.97,3.833-4.857,7.662-6.644l7.04,4.334c-2.24,1.156-4.458,2.596-8.474,7.792 L15.837,18.577z" fill="url(#SVGID_4)"/>
+<path d="M24.679,11.449c0,0,2.42-0.559,2.777-0.528l7.598,4.183c0,0-1.459-0.021-3.218,0.643L24.679,11.449z" fill="#D6E3F1"/>
+<polygon fill="#FFFFFF" points="5.01,22.433 6.175,22.295 6.975,23.324 5.913,23.549 "/>
+<polygon fill="#FFFFFF" points="7.375,21.997 8.266,23.043 9.482,22.64 8.574,21.615 "/>
+<polygon fill="#FFFFFF" points="9.574,21.165 10.499,22.191 11.537,21.608 10.586,20.609 "/>
+<polygon fill="#FFFFFF" points="11.421,20.037 12.384,21.011 13.269,20.314 12.271,19.342 "/>
+<polygon fill="#FFFFFF" points="13.02,18.701 14.011,19.635 14.791,18.83 13.778,17.914 "/>
+<polygon fill="#FFFFFF" points="14.442,17.202 15.475,18.118 16.197,17.266 15.179,16.398 "/>
+<polygon fill="#FFFFFF" points="15.844,15.668 16.866,16.522 17.604,15.706 16.559,14.862 "/>
+<polygon fill="#FFFFFF" points="17.244,14.166 18.299,14.983 19.106,14.222 18.006,13.415 "/>
+<polygon fill="#FFFFFF" points="18.777,12.774 19.879,13.55 20.761,12.867 19.676,12.108 "/>
+<polygon fill="#FFFFFF" points="20.562,11.561 21.648,12.29 22.73,11.758 21.609,11.037 "/>
+<polygon fill="#FFFFFF" points="22.604,10.648 23.753,11.323 25.063,10.971 23.888,10.287 "/>
+<polygon fill="#FFFFFF" points="25.024,10.068 26.227,10.754 26.93,10.631 25.677,9.949 "/>
+<polygon fill="#FFFFFF" points="11.811,30.928 13.116,30.698 13.985,31.78 12.649,32.004 "/>
+<polygon fill="#FFFFFF" points="14.498,30.351 15.391,31.409 16.816,30.875 15.881,29.832 "/>
+<polygon fill="#FFFFFF" points="17.029,29.287 18.192,28.574 19.174,29.579 17.976,30.306 "/>
+<polygon fill="#FFFFFF" points="19.158,27.871 20.135,28.861 21.14,27.983 20.148,27.013 "/>
+<polygon fill="#FFFFFF" points="20.978,26.184 21.984,27.14 22.859,26.174 21.842,25.253 "/>
+<polygon fill="#FFFFFF" points="22.612,24.36 23.645,25.271 24.468,24.251 23.416,23.373 "/>
+<polygon fill="#FFFFFF" points="24.171,22.477 25.218,23.341 26.04,22.319 24.979,21.479 "/>
+<polygon fill="#FFFFFF" points="25.762,20.613 26.828,21.433 27.736,20.487 26.656,19.675 "/>
+<polygon fill="#FFFFFF" points="27.506,18.885 28.624,19.658 29.642,18.824 28.518,18.066 "/>
+<polygon fill="#FFFFFF" points="29.538,17.391 30.671,18.123 31.874,17.434 30.726,16.714 "/>
+<polygon fill="#FFFFFF" points="31.916,16.199 33.104,16.899 34.571,16.434 33.386,15.741 "/>
+<polygon fill="#FFFFFF" points="34.844,15.44 36.06,16.109 36.745,16.033 35.5,15.349 "/>
+<linearGradient id="SVGID_5" gradientUnits="userSpaceOnUse" x1="14.3" y1="2.22" x2="26.79" y2="28.48">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#486EA2" offset="0.71"/>
+<stop stop-color="#225487" offset="0.99"/>
+</linearGradient>
+<path d="M13.232,32.458c12.06-1.605,12.525-15.277,24.25-16.038l-0.223,1.113 C25.511,18.605,26.003,32.25,12.916,33.847L13.232,32.458z" fill="url(#SVGID_5)"/>
+<polygon fill="url(#SVGID_2)" points="13.232,32.458 4.504,21.748 4.532,22.606 12.916,33.847 "/>
+<polygon fill="#7D96C5" points="12.839,31.979 12.556,33.363 11.799,32.325 11.973,30.891 "/>
+<polygon fill="#7D96C5" points="5.063,22.42 5.147,23.398 5.977,24.548 5.953,23.545 "/>
+<linearGradient id="SVGID_7" gradientUnits="userSpaceOnUse" x1="12.63" y1="30.81" x2="13.51" y2="19.84">
+<stop stop-color="#FFFFFF" offset="0.05"/>
+<stop stop-color="#A1C1DC" offset="1"/>
+</linearGradient>
+<path d="M16.126,24.422c-0.565,1.555-2.365,2.897-4.022,3.002c-1.654,0.103-2.539-1.072-1.975-2.624 c0.563-1.555,2.364-2.897,4.021-3.004C15.805,21.694,16.689,22.867,16.126,24.422z" fill="url(#SVGID_7)"/>
+<path d="M14.487,18.025l-3.252-15.66l0.762-0.171c0.51,2.215,1.676,2.994,2.856,3.836 c2.69,1.907,5.913,3.547,3.617,10.54l-0.544-0.218c1.583-5.44-0.518-7.292-4.471-7.949l2.114,10.467L14.487,18.025z" fill="#6D5723"/>
+<radialGradient id="SVGID_8" gradientUnits="userSpaceOnUse" cx="13.33" cy="18.95" fx="12.7" fy="19.13" r="2.87">
+<stop stop-color="#E6EDF3" offset="0"/>
+<stop stop-color="#A2762B" offset="0.44"/>
+<stop stop-color="#474219" offset="0.94"/>
+</radialGradient>
+<path d="M15.434,20.15c-0.58,1.712-2.439,3.188-4.158,3.292c-1.717,0.11-2.644-1.193-2.063-2.906 c0.578-1.709,2.438-3.184,4.158-3.292C15.087,17.136,16.014,18.437,15.434,20.15z" fill="url(#SVGID_8)"/>
+</svg>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/icons/usb_icon_mode_5.svg	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="42" height="36" viewBox="0 0 42 36">
+<rect fill="none" height="36" width="42"/>
+<linearGradient id="SVGID_1" gradientUnits="userSpaceOnUse" x1="-0.54" y1="15.57" x2="35.4" y2="15.57">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#A1C1DC" offset="0.35"/>
+<stop stop-color="#6C82B9" offset="0.7"/>
+<stop stop-color="#173F6C" offset="1"/>
+</linearGradient>
+<path d="M24.067,29.803c-0.456,0-0.918-0.07-1.381-0.207l-12.552-3.74c-2.362-0.703-3.827-2.558-3.919-4.957 L5.74,8.165C5.673,6.397,6.431,4.892,7.82,4.036c1.797-1.579,3.234-2.693,5.342-2.693c0.377,0,0.778,0.038,1.19,0.114l11.474,1.836 c3.21,0.579,5.817,3.865,5.817,7.33l-0.161,12.044c0,3.272-2.31,4.707-4.984,6.37c-0.135,0.096-0.275,0.184-0.425,0.265 l-0.009,0.008l-0.15,0.092l-0.018,0.011l-0.014-0.013C25.321,29.666,24.71,29.803,24.067,29.803L24.067,29.803z" fill="url(#SVGID_1)"/>
+<linearGradient id="SVGID_2" gradientUnits="userSpaceOnUse" x1="19.15" y1="2.32" x2="19.15" y2="26.35">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#A1C1DC" offset="0.35"/>
+<stop stop-color="#6C82B9" offset="0.7"/>
+<stop stop-color="#173F6C" offset="1"/>
+</linearGradient>
+<path d="M25.729,29.107c2.868-1.805,5.439-3.154,5.439-6.506l0.161-12.039c0-3.337-2.497-6.497-5.583-7.052 L14.27,1.672c-3.083-0.557-4.703,1.116-7.302,3.402l6.56,0.938l11.324,2.309l1.155,12.016L25.729,29.107z" fill="url(#SVGID_2)"/>
+<linearGradient id="SVGID_3" gradientUnits="userSpaceOnUse" x1="6.6" y1="5.55" x2="28.55" y2="27.5">
+<stop stop-color="#FFFFFF" offset="0.05"/>
+<stop stop-color="#A1C1DC" offset="1"/>
+</linearGradient>
+<path d="M22.733,29.269c2.822,0.841,5.375-1.101,5.375-4.449V12.715c0-3.336-2.498-6.496-5.58-7.052 L11.366,3.65C8.277,3.094,5.871,5.092,5.986,8.095L6.461,20.83c0.084,2.214,1.425,4.015,3.72,4.696L22.733,29.269z" fill="url(#SVGID_3)"/>
+<linearGradient id="SVGID_4" gradientUnits="userSpaceOnUse" x1="12.92" y1="1.63" x2="32.49" y2="21.2">
+<stop stop-color="#E6EDF3" offset="0"/>
+<stop stop-color="#ADCEB3" offset="0.14"/>
+<stop stop-color="#78B277" offset="0.28"/>
+<stop stop-color="#57A052" offset="0.39"/>
+<stop stop-color="#4A9944" offset="0.44"/>
+<stop stop-color="#428E47" offset="0.5"/>
+<stop stop-color="#286C50" offset="0.68"/>
+<stop stop-color="#185756" offset="0.84"/>
+<stop stop-color="#124F58" offset="0.94"/>
+</linearGradient>
+<path d="M21.698,10.582c0.828,0.164,1.505,1.017,1.511,1.903l0.024,4.707l3.752,0.795v-4.86 c0-2.416-1.466-4.727-3.488-5.776c-0.465-0.24-0.96-0.414-1.471-0.506l-3.731-0.671v3.73L21.698,10.582z" fill="url(#SVGID_4)"/>
+<linearGradient id="SVGID_5" gradientUnits="userSpaceOnUse" x1="2.57" y1="1.96" x2="33.99" y2="39.18">
+<stop stop-color="#E6EDF3" offset="0"/>
+<stop stop-color="#B8CAE2" offset="0.11"/>
+<stop stop-color="#7C9DCD" offset="0.27"/>
+<stop stop-color="#5782BF" offset="0.38"/>
+<stop stop-color="#4977BA" offset="0.44"/>
+<stop stop-color="#3F6CAB" offset="0.51"/>
+<stop stop-color="#295489" offset="0.69"/>
+<stop stop-color="#1C4474" offset="0.84"/>
+<stop stop-color="#173F6C" offset="0.94"/>
+</linearGradient>
+<path d="M23.261,22.141c0.014,1.256-0.801,1.385-1.456,1.206l-9.833-2.939c-0.59-0.401-0.48-1.005-0.5-1.546 c-0.018-0.545-0.231-8.875-0.231-8.875c-0.023-0.829,0.626-1.365,1.458-1.197l5.035,1.004V6.072l-5.656-1.02 C9.324,4.556,7.178,6.336,7.281,9.014l0.423,11.352c0.075,1.974,1.269,3.58,3.314,4.187l11.191,3.335 c2.514,0.751,4.791-0.979,4.791-3.965v-5.36l-3.764-0.797L23.261,22.141z" fill="url(#SVGID_5)"/>
+<linearGradient id="SVGID_6" gradientUnits="userSpaceOnUse" x1="11.3" y1="22.66" x2="36.26" y2="22.66">
+<stop stop-color="#A1C1DC" offset="0.1"/>
+<stop stop-color="#6C82B9" offset="0.71"/>
+<stop stop-color="#173F6C" offset="0.99"/>
+</linearGradient>
+<path d="M17.672,34.657l-0.042-0.057l-5.196-6.966l-0.033-0.045l-1.052-1.408l-0.023-0.031v-0.039 l-0.021-0.645l-0.002-0.111l0.111-0.013c1.292-0.14,2.439-0.475,3.503-1.025c0.51-1.218,1.801-2.212,3.04-2.341 c0.176-0.176,0.36-0.367,0.559-0.578l-2.166-10.429l-0.025-0.118l0.118-0.026l0.57-0.128l0.119-0.026l0.027,0.119 c0.361,1.568,1.168,2.142,2.019,2.75l0.073,0.051c0.129,0.091,0.261,0.183,0.392,0.273c1.278,0.887,2.598,1.803,2.894,3.753 c1.265-0.815,2.649-1.272,4.229-1.399l0.034-0.001l0.032,0.017l1.212,0.667l0.24,0.129l0.395,0.216l0.938,0.515l6.568,3.605 l0.079,0.043l-0.013,0.099l-0.166,0.823l-0.016,0.09l-0.092,0.008c-4.26,0.389-6.33,2.992-8.523,5.748 c-2.289,2.879-4.659,5.857-9.711,6.474L17.672,34.657L17.672,34.657z M18.289,15.62l1,4.945c0.747-0.811,1.52-1.635,2.396-2.335 C21.408,16.807,20.356,15.997,18.289,15.62L18.289,15.62z" fill="url(#SVGID_6)"/>
+<linearGradient id="SVGID_7" gradientUnits="userSpaceOnUse" x1="26.85" y1="11.62" x2="21.75" y2="31.39">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#486EA2" offset="0.71"/>
+<stop stop-color="#225487" offset="0.99"/>
+</linearGradient>
+<path d="M11.427,25.473c7.77-0.837,7.915-8.534,15.346-9.126l9.365,5.143 c-9.428,1.259-8.646,10.743-18.22,12.087L11.427,25.473z" fill="url(#SVGID_7)"/>
+<linearGradient id="SVGID_8" gradientUnits="userSpaceOnUse" x1="16.79" y1="29.56" x2="24.85" y2="18.89">
+<stop stop-color="#DEE8F1" offset="0"/>
+<stop stop-color="#225487" offset="1"/>
+</linearGradient>
+<path d="M12.737,27.133c1.182-0.074,4.101-0.602,6.604-3.449l4.59,4.212 c-1.728,2.159-4.709,3.901-7.315,4.124L12.737,27.133z" fill="url(#SVGID_8)"/>
+<linearGradient id="SVGID_9" gradientUnits="userSpaceOnUse" x1="25" y1="22.89" x2="20.33" y2="30.15">
+<stop stop-color="#DEE8F1" offset="0"/>
+<stop stop-color="#225487" offset="1"/>
+</linearGradient>
+<path d="M19.915,23.097c1.268-1.476,2.872-3.64,5.741-4.977l5.272,3.245 c-1.678,0.867-3.339,1.945-6.347,5.839L19.915,23.097z" fill="url(#SVGID_9)"/>
+<path d="M26.538,17.757c0,0,1.814-0.419,2.082-0.396l5.691,3.135c0,0-1.094-0.018-2.411,0.48L26.538,17.757z" fill="#D6E3F1"/>
+<polygon fill="#FFFFFF" points="11.806,25.985 12.678,25.883 13.278,26.651 12.481,26.82 "/>
+<polygon fill="#FFFFFF" points="13.576,25.66 14.246,26.442 15.155,26.141 14.475,25.371 "/>
+<polygon fill="#FFFFFF" points="15.224,25.035 15.917,25.804 16.695,25.367 15.982,24.619 "/>
+<polygon fill="#FFFFFF" points="16.608,24.189 17.33,24.92 17.991,24.398 17.245,23.671 "/>
+<polygon fill="#FFFFFF" points="17.805,23.189 18.548,23.891 19.132,23.285 18.373,22.6 "/>
+<polygon fill="#FFFFFF" points="18.871,22.067 19.646,22.753 20.185,22.115 19.422,21.465 "/>
+<polygon fill="#FFFFFF" points="19.922,20.918 20.687,21.559 21.24,20.945 20.457,20.313 "/>
+<polygon fill="#FFFFFF" points="20.969,19.792 21.76,20.404 22.364,19.834 21.541,19.23 "/>
+<polygon fill="#FFFFFF" points="22.118,18.75 22.944,19.331 23.603,18.82 22.793,18.25 "/>
+<polygon fill="#FFFFFF" points="23.455,17.841 24.271,18.387 25.08,17.988 24.239,17.447 "/>
+<polygon fill="#FFFFFF" points="24.985,17.157 25.847,17.663 26.827,17.399 25.946,16.886 "/>
+<polygon fill="#FFFFFF" points="26.8,16.723 27.699,17.236 28.225,17.144 27.287,16.633 "/>
+<polygon fill="#FFFFFF" points="16.898,32.349 17.878,32.177 18.529,32.987 17.528,33.154 "/>
+<polygon fill="#FFFFFF" points="18.911,31.916 19.581,32.709 20.65,32.309 19.949,31.528 "/>
+<polygon fill="#FFFFFF" points="20.808,31.118 21.681,30.585 22.415,31.339 21.518,31.885 "/>
+<polygon fill="#FFFFFF" points="22.404,30.058 23.138,30.801 23.888,30.143 23.146,29.416 "/>
+<polygon fill="#FFFFFF" points="23.767,28.795 24.522,29.512 25.178,28.787 24.414,28.098 "/>
+<polygon fill="#FFFFFF" points="24.992,27.429 25.765,28.111 26.38,27.348 25.595,26.689 "/>
+<polygon fill="#FFFFFF" points="26.159,26.018 26.943,26.666 27.558,25.899 26.766,25.271 "/>
+<polygon fill="#FFFFFF" points="27.351,24.623 28.149,25.235 28.829,24.527 28.021,23.921 "/>
+<polygon fill="#FFFFFF" points="28.657,23.328 29.494,23.908 30.257,23.281 29.415,22.713 "/>
+<polygon fill="#FFFFFF" points="30.181,22.209 31.028,22.756 31.93,22.24 31.069,21.701 "/>
+<polygon fill="#FFFFFF" points="31.96,21.314 32.851,21.84 33.95,21.492 33.063,20.973 "/>
+<polygon fill="#FFFFFF" points="34.155,20.746 35.064,21.25 35.579,21.19 34.646,20.68 "/>
+<linearGradient id="SVGID_10" gradientUnits="userSpaceOnUse" x1="18.78" y1="10.86" x2="28.12" y2="30.5">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#486EA2" offset="0.71"/>
+<stop stop-color="#225487" offset="0.99"/>
+</linearGradient>
+<path d="M17.964,33.494c9.035-1.201,9.381-11.443,18.168-12.012l-0.169,0.832 c-8.802,0.803-8.433,11.025-18.236,12.22L17.964,33.494z" fill="url(#SVGID_10)"/>
+<polygon fill="url(#SVGID_7)" points="17.964,33.494 11.427,25.473 11.446,26.115 17.727,34.534 "/>
+<polygon fill="#7D96C5" points="17.669,33.137 17.458,34.173 16.892,33.395 17.022,32.322 "/>
+<polygon fill="#7D96C5" points="11.844,25.977 11.908,26.709 12.529,27.569 12.512,26.818 "/>
+<linearGradient id="SVGID_12" gradientUnits="userSpaceOnUse" x1="17.52" y1="32.26" x2="18.17" y2="24.05">
+<stop stop-color="#FFFFFF" offset="0.05"/>
+<stop stop-color="#A1C1DC" offset="1"/>
+</linearGradient>
+<path d="M20.134,27.476c-0.425,1.165-1.773,2.171-3.014,2.247c-1.239,0.079-1.903-0.801-1.48-1.965 c0.421-1.164,1.771-2.172,3.012-2.25C19.891,25.431,20.554,26.31,20.134,27.476z" fill="url(#SVGID_12)"/>
+<path d="M18.905,22.685l-2.436-11.732l0.57-0.127c0.382,1.659,1.256,2.242,2.14,2.874 c2.016,1.427,4.429,2.657,2.709,7.895l-0.407-0.162c1.186-4.076-0.389-5.463-3.35-5.955l1.583,7.84L18.905,22.685z" fill="#6D5723"/>
+<radialGradient id="SVGID_13" gradientUnits="userSpaceOnUse" cx="18.04" cy="23.37" fx="17.57" fy="23.5" r="2.14">
+<stop stop-color="#E6EDF3" offset="0"/>
+<stop stop-color="#A2762B" offset="0.44"/>
+<stop stop-color="#474219" offset="0.94"/>
+</radialGradient>
+<path d="M19.613,24.275c-0.434,1.281-1.827,2.387-3.115,2.466c-1.285,0.083-1.98-0.895-1.544-2.177 c0.433-1.28,1.827-2.386,3.114-2.467C19.354,22.018,20.048,22.99,19.613,24.275z" fill="url(#SVGID_13)"/>
+</svg>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/inc/mydebug.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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 MYDEBUG_H
+#define MYDEBUG_H
+
+#include <QtDebug>
+
+#if defined(_DEBUG)
+    inline QDebug myDebug()
+    {
+        return qDebug();
+    }
+#else
+    inline QNoDebug myDebug()
+    {
+        return QNoDebug();
+    }
+#endif
+
+
+#endif // MYDEBUG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/inc/usbmainview.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* 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 USBMAINVIEW_H
+#define USBMAINVIEW_H
+
+#include <hbview.h>
+#include <QObject>
+
+class UsbUiSettingModel;
+class QGraphicsLinearLayout;
+class HbListWidgetItem;
+class HbListWidget;
+class HbTextEdit;
+class HbRadioButtonList;
+
+class UsbMainView : public HbView
+{
+    Q_OBJECT
+    friend class TestUsbUiModelActive;
+
+public:
+    explicit UsbMainView( QObject *parent = 0 );
+    virtual ~UsbMainView();
+    
+public slots: 
+    /**
+     * Update view item(s) between the selected rows.
+     * @param topLeft The top row index
+     * @param bottomRight The bottom row index
+     */
+    void updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+    
+    /*
+     * Set the personality user has selected in the radio button list
+     * @param personalityIndex The selection index in the radio button list
+     */
+    void setPersonality( int personalityIndex );
+
+signals:
+    
+private:
+    /*
+     * creates the main view window row by row
+     */
+    void createMainView();
+    /*
+     * creates the first row in the view containing an icon and a mode name
+     * @param  localPropertiesGroup main view layout
+     */
+    void createIconNameRow(QGraphicsLinearLayout *localPropertiesGroup);
+    /*
+     * creates the second row from the view containing the description of the selected mode
+     * @param  localPropertiesGroup main view layout
+     */
+    void createDescriptionArea(QGraphicsLinearLayout *localPropertiesGroup);
+    /*
+     * creates the third row from the view containing the radio button list of the existing usb modes
+     * @param  localPropertiesGroup main view layout
+     */
+    void createRadioButtonArea(QGraphicsLinearLayout *localPropertiesGroup);
+       
+private:
+    // main view layout owned by this class
+    QGraphicsLinearLayout *mMainLayout; 
+    // setting model not owned by the view,
+    // has to be deleted
+    UsbUiSettingModel *mModel;
+    //owned by the view
+    HbListWidgetItem *mListItem;
+    // owned by the view
+    HbListWidget *mlist;
+    // owned by the view
+    HbTextEdit *mlabel;
+    // owned by the view
+    HbRadioButtonList *mradio;
+    // not owned by the view
+    // need to be deleted
+    HbIcon *mIcon ;
+};
+
+#endif /* USBMAINVIEW_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/inc/usbuimodelactive.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,121 @@
+/*
+* 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 USBUIMODELACTIVE_H
+#define USBUIMODELACTIVE_H
+
+#include <QObject>
+#include <e32base.h>
+#include <usbwatcher.h>
+
+class UsbUiModelActivePrivate;
+
+/*!
+    \class UsbUiModelActive
+    \brief Helper class for using active objects in Qt classes.
+
+    UsbUiModelActive is a helper class for using active objects 
+    from any Qt class. It wraps a CActive-derived class in an interface
+    that uses Qt's signal-slot mechanism for communicating status changes 
+    of the active object.
+
+ */
+class UsbUiModelActive : public QObject
+{
+    Q_OBJECT
+    friend class UsbUiModelActivePrivate;
+
+public:
+    explicit UsbUiModelActive( int priority = CActive::EPriorityStandard, 
+            QObject *parent = NULL );
+    ~UsbUiModelActive();
+
+    inline TRequestStatus &RequestStatus();
+    inline void SetActive();
+    inline void Cancel();
+    inline bool IsActive();
+    
+public:
+    int SetUsbPersonality(int personality);
+    void CancelSetPersonality();
+    
+signals:
+    void requestCompleted( int status );
+
+private:
+   /*!
+    * emits a signal when the request is completed
+    * @param status is the error
+    */
+    void emitRequestCompleted( int status );
+
+private:
+    UsbUiModelActivePrivate *d;
+     
+    /** Handle to USBWatcher for setting the personality */
+    RUsbWatcher iUsbWatcher; 
+};
+
+
+/*!
+    \class UsbUiModelActivePrivate
+    \brief Private class of UsbUiModelActive, for using active objects in Qt classes.
+
+    UsbUiModelActivePrivate is a helper class for using active objects 
+    from any Qt class. It derives from CActive and allows other classes to use 
+    it for passing to asynchronous function calls through its RequestStatus method.
+
+ */
+class UsbUiModelActivePrivate : public CActive
+{
+    friend class UsbUiModelActive;
+
+public:
+    explicit UsbUiModelActivePrivate( UsbUiModelActive *parent, int priority );
+    ~UsbUiModelActivePrivate();
+
+private:
+    virtual void RunL();
+    virtual void DoCancel();
+    virtual TInt RunError( TInt aError );
+
+private:
+    UsbUiModelActive *q;
+
+};
+
+inline bool UsbUiModelActive::IsActive()
+{
+    return d->IsActive();
+}
+
+inline TRequestStatus &UsbUiModelActive::RequestStatus()
+{
+    return d->iStatus;
+}
+
+inline void UsbUiModelActive::SetActive()
+{
+    d->SetActive();
+}
+
+inline void UsbUiModelActive::Cancel()
+{
+    d->Cancel();
+}
+
+#endif /* USBUIMODELACTIVE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/inc/usbuisettingmodel.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,168 @@
+/*
+* 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 USBUISETTINGMODEL_H
+#define USBUISETTINGMODEL_H
+
+
+#include <e32base.h>
+#include <e32property.h>
+#include <QStringList>
+#include <QAbstractItemModel>
+#include <XQSettingsManager>
+
+const int KDefaultColumn = 0;
+typedef QList< QMap< int, QVariant > > UsbUiModelDataSource;
+
+class RUsb;
+class UsbUiModelActive;
+
+class UsbUiSettingModel : public QAbstractItemModel
+{
+    Q_OBJECT
+    friend class TestUsbUiModelActive;
+ 
+public:
+enum usbSettingsIndex {
+        DefaultMode,
+        Description,
+        UsbModeList,
+        EndOfSettings
+    };
+enum SettingsRoleValues {
+        SettingType = Qt::UserRole,
+        SettingsModeNameList,
+    };
+public:
+    UsbUiSettingModel( QObject *parent = 0 );
+    virtual ~UsbUiSettingModel();
+
+    /*
+     *  Returns the index of the item in the model specified by the given row, column and parent index.
+     *  @param row is the row number of the specified item
+     *  @param column is the column number of the specified item
+     *  @param parent QModelIndex parent
+     */   
+    virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
+    /*
+     * Returns QModelIndex() because this model item has no parent
+     * @param child is the index of item model, the parent of which is going to be returned
+     * @param child is not used in here
+     */
+    virtual QModelIndex parent( const QModelIndex &child ) const;
+    /*
+     * Returns the number of rows under the given parent
+     * @param parent QModelIndex parent
+     */
+    virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
+    /*
+     * Returns the number of columns for the children of the given parent.
+     * @param parent QModelIndex parent
+     */
+    virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
+    /*
+     *Returns the data stored under the given role for the item referred to by the index. 
+     */
+    virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
+    /*
+     * Sets the role data for the item at index to value. Returns true if successful; otherwise returns false.
+     */
+    virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
+
+    const QModelIndex* sourceData() const;
+
+public slots:
+    /*
+     * Provides notification of changes in selected usb mode
+     * @param key is not used 
+     * @param value is the value read from cenrep key 
+     */
+    void usbModeChanged( const XQSettingsKey &key, const QVariant &value );
+    /*
+     * it checks the response from usbwatcher to see if the new mode change has been successful
+     * it will go back to the previous personality if it has not been successfull
+     * @param status is the error code returned from usbwatcher
+     */
+    void setPersonalityCompleted (int status );
+    
+private:
+	/*
+	 * creats the logical name of the modename string for the list
+	 * @param modeId is the usb personality id
+	 */   
+    QString modeListName( int modeId );
+    /*
+     * Get the current USB personality ID
+     * Returns 0, if the key is missing or the value cannot be converted 
+     * to integer.
+     * @return The current personality id
+     */
+    int currentMode(); 
+    /*
+     * sets the value to different roles of the model's first row
+     */
+    void setDefaultModeSetting();
+    /*
+     * sets the value to different roles of the model's description row
+     */
+    void setDescriptionSetting();
+    /**
+     * Set the USB mode list and the current selection in the list.
+     * The personality IDs are stored to mPersonalityIds and the personality names
+     * to mSettingsList.
+     * @param modeId The current mode ID
+     */
+    bool setUsbModelistSetting( int modeId );
+    /**
+     * calls the model's set functions
+     * @param modeId The current mode ID
+     */
+    void setUsbSettings( int modeId );
+    /**
+     * updates the model rows and emits signal datachanged
+     * @param newPersonality is the new personality id
+     */
+    void setNewUsbMode(int newPersonality);
+	
+    /**
+     * Check from the USB Manager if the USB personality is hidden.
+     * @param usbman Already opened USB Manager session
+     * @param personalityId The ID of the personality to be checked.
+     * @return For hidden personality, true is returned.
+     */
+    bool isPersonalityHidden(RUsb &usbman, TInt personalityId);
+    
+    /**
+     * Check if the USB personality is hidden.
+     * The personality is hidden, if it does not exist in mPersonalityIds.
+     * @param personalityId The ID of the personality to be checked.
+     * @return For hidden personality, true is returned.
+     */
+    bool isPersonalityHidden(TInt personalityId);
+ private:
+    
+    UsbUiModelDataSource mSettingsList;
+    int mCurrentMode;
+    // stored, so that we can show the correct personality when it fails to set the new one
+    int mPreviousMode; 
+    
+    XQSettingsManager mSettingsManager;
+    QList<int> mPersonalityIds;
+    UsbUiModelActive *mModelActive;
+};
+
+#endif // USBUISETTINGMODEL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/inc/usbviewmanager.h	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* 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 USBVIEWMANAGER_H
+#define USBVIEWMANAGER_H
+
+#include "usbmainview.h"
+
+
+class HbMainWindow;
+
+class UsbViewManager : public QObject
+    {
+    Q_OBJECT
+
+public:
+    explicit UsbViewManager(HbMainWindow* mainWindow, QObject *parent = 0 );
+    ~UsbViewManager();
+    
+    void addView();
+
+private: 
+    HbMainWindow* mWindow;
+    UsbMainView* mMainView; // owned
+
+    };
+
+
+#endif /* USBVIEWMANAGER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/rom/usbsettings.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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 USBSETTING_IBY
+#define USBSETTING_IBY
+// Use standard macros
+#include <data_caging_paths_for_iby.hrh>
+
+file=/epoc32/release/armv5/urel/usbapplication.exe      PROGRAMS_DIR/usbapplication.exe
+data=/epoc32/data/z/private/10003a3f/import/apps/usbapplication_reg.rsc /private/10003a3f/import/apps/usbapplication_reg.rsc
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/rom/usbsettingsresources.iby	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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: 
+*
+*/
+
+#ifndef USBSETTINGRESOURCES_IBY
+#define USBSETTINGRESOURCES_IBY
+// Use standard macros
+#include <data_caging_paths_for_iby.hrh>
+
+data=/epoc32/data/z/resource/apps/usbapplication.rsc    APP_RESOURCE_DIR/usbapplication.rsc
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/main.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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: 
+*
+*/
+
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+#include <QTranslator>
+#include <eikenv.h>
+#include "usbviewmanager.h"
+
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+
+    // add translator for application library
+    QString locale = QLocale::system().name();
+    QTranslator translator;
+    QString filename = QString("usbapplication_") + locale;
+#ifdef Q_OS_SYMBIAN    
+    // TRAP is must here, otherwise it crashes
+TRAP_IGNORE(
+    bool loaded(false);
+    loaded = translator.load( filename, QString("z:/resource/qt/translations") );
+    if (!loaded)
+        translator.load(filename, QString("c:/resource/qt/translations") );
+);
+#else
+    translator.load(filename, QString("resource") );
+#endif //Q_OS_SYMBIAN    
+    app.installTranslator(&translator);
+    
+    HbMainWindow mainWindow;
+
+    // create the view manager, which handles 3 HbViews and add into mainWindow.
+    UsbViewManager* mViewManager = new UsbViewManager( &mainWindow, &app );
+    mViewManager->addView();
+    
+    mainWindow.show();
+    return app.exec();
+}
Binary file usbuis/usbuiqt/src/usbapplication.qm has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbapplication.qrc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RCC>
+    <qresource prefix="/xml">
+        <file>usbview.docml</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbapplication.ts	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="3.0" language="en_GB" sourcelanguage="en_GB">
+<context>
+<message numerus="no" id="txt_usb_description_5">
+    <comment>Description for USB Ovi Suite personality. This gives user help about the selected personality.</comment>        
+    <source>Manage your phone with Ovi Suite and sync your media content.</source>
+    <translation variants="no">Manage your phone with Ovi Suite and sync your media content.</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>Text ID</extra-loc-viewid>
+    <extra-loc-positionid>description</extra-loc-positionid>
+    <extra-loc-feature>Te</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modelistname_5">
+    <comment>USB mode name for Ovi Suite personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_5.</comment>        
+    <source>Ovi Suite</source>
+    <translation variants="no">Ovi Suite</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>Comment</extra-loc-viewid>
+    <extra-loc-positionid>modelistname</extra-loc-positionid>
+    <extra-loc-feature>Co</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modelistname_2">
+    <comment>USB mode name for Mass storage personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_2.</comment>        
+    <source>Mass storage</source>
+    <translation variants="no">Mass storage</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>Layout ID</extra-loc-viewid>
+    <extra-loc-positionid>modelistname</extra-loc-positionid>
+    <extra-loc-feature>La</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modename_2">
+    <comment>USB mode name for Mass storage personality. This is used in USB application as the default (selected) mode.</comment>        
+    <source>Mass storage</source>
+    <translation variants="no">Mass storage</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>View ID (draft)</extra-loc-viewid>
+    <extra-loc-positionid>modename</extra-loc-positionid>
+    <extra-loc-feature>Vi</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modelistname_6">
+    <comment>USB mode name for Phone as modem personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_6.</comment>        
+    <source>Connect PC to Web</source>
+    <translation variants="no">Connect PC to Web</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>modelistname</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_description_2">
+    <comment>Description for USB Mass storage personality. This gives user help about the selected personality.</comment>        
+    <source>Access your phoneÂ’s memory card from the device you are connected to.</source>
+    <translation variants="no">Access your phoneÂ’s memory card from the device you are connected to.</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>Position ID</extra-loc-viewid>
+    <extra-loc-positionid>description</extra-loc-positionid>
+    <extra-loc-feature>Po</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modelistname_4">
+    <comment>USB mode name for MTP personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_4.</comment>        
+    <source>Media transfer</source>
+    <translation variants="no">Media transfer</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>modelistname</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modename_5">
+    <comment>USB mode name for Ovi Suite personality. This is used in USB application as the default (selected) mode.</comment>        
+    <source>Ovi Suite</source>
+    <translation variants="no">Ovi Suite</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid>File name</extra-loc-viewid>
+    <extra-loc-positionid>modename</extra-loc-positionid>
+    <extra-loc-feature>Fi</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_description_6">
+    <comment>Description for USB Phone as Modem personality. This gives user help about the selected personality.</comment>        
+    <source>Use your mobile phone as a modem</source>
+    <translation variants="no">Use your mobile phone as a modem</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>description</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_description_4">
+    <comment>Description for USB MTP personality. This gives user help about the selected personality.</comment>        
+    <source>Sync your media content with Windows Media Player or Nokia Ovi Player, or connect to compatible stereos.</source>
+    <translation variants="no">Sync your media content with Windows Media Player or Nokia Ovi Player, or connect to compatible stereos.</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>description</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modename_6">
+    <comment>USB mode name for Phone as Modem personality. This is used in USB application as the default (selected) mode.</comment>        
+    <source>Connect PC to Web</source>
+    <translation variants="no">Connect PC to Web</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>modename</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_usb_modename_4">
+    <comment>USB mode name for MTP personality. This is used in USB application as the default (selected) mode.</comment>        
+    <source>Media transfer</source>
+    <translation variants="no">Media transfer</translation>
+    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-viewid></extra-loc-viewid>
+    <extra-loc-positionid>modename</extra-loc-positionid>
+    <extra-loc-feature></extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+</context>
+</TS>
Binary file usbuis/usbuiqt/src/usbapplication.xls has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbapplication_reg.rss	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,18 @@
+// ============================================================================
+// * Generated by qmake (2.01a) (Qt 4.6.0) on: 2009-12-16T13:39:42
+// * This file is generated by qmake and should not be modified by the
+// * user.
+// ============================================================================
+
+#include <usbapplication.rsg>
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0xECD2B4FE
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file="usbapplication";
+	localisable_resource_file="\\resource\\apps\\usbapplication";
+
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbicons.qrc	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,7 @@
+<RCC>
+    <qresource prefix="/" >
+        <file>../icons/usb_icon_mode_2.svg</file>
+        <file>../icons/usb_icon_mode_4.svg</file>
+        <file>../icons/usb_icon_mode_5.svg</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbmainview.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,180 @@
+/*
+* 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: 
+*
+*/
+#include "usbmainview.h"
+#include <QModelIndex>
+#include <QtGui/QGraphicsLinearLayout>
+#include <hblistwidget.h>
+#include <hblistwidgetitem.h>
+#include <hbradiobuttonlist.h>
+#include <hbtextedit.h>
+
+#include "usbuisettingmodel.h"
+#include "mydebug.h"
+/*!
+ * default constructor
+ */
+UsbMainView::UsbMainView( QObject *parent )
+:   HbView(), mModel(NULL)
+{
+    myDebug() << ">>> UsbMainView::UsbMainView";
+    setParent( parent );    
+    setTitle( qtTrId("USB") ); 
+    mMainLayout = new QGraphicsLinearLayout( Qt::Vertical, this );
+    mModel = new UsbUiSettingModel();
+    createMainView();
+    setLayout( mMainLayout );
+    myDebug() << "<<< UsbMainView::UsbMainView";      
+}
+
+/*!
+ * creates the main view
+ */
+void UsbMainView::createMainView()
+{
+    myDebug() << ">>> UsbMainView::createMainView";
+    QGraphicsLinearLayout *mainViewLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout );
+    mListItem = NULL;
+    mlist = NULL;
+    mlabel = NULL;
+    mradio = NULL;
+    mIcon = NULL;
+    createIconNameRow( mainViewLayout );
+    createDescriptionArea( mainViewLayout );
+    createRadioButtonArea( mainViewLayout );
+    mMainLayout->addItem( mainViewLayout );
+    bool connected = connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), 
+            this, SLOT( updateSettingItems( QModelIndex, QModelIndex ) ) );
+    myDebug() << "<<< UsbMainView::createMainView model connected=" << connected;
+    connected = connect(mradio, SIGNAL( itemSelected( int ) ), 
+            this, SLOT( setPersonality( int ) ) );
+    myDebug() << "<<< UsbMainView::createMainView mradio connected=" << connected;
+    myDebug() << "<<< UsbMainView::createMainView";
+}  
+/*!
+ * creating the creates the first row in the view containing an icon and a mode name 
+ */
+void UsbMainView::createIconNameRow( QGraphicsLinearLayout *aLocalPropertiesGroup )
+{
+    myDebug() << ">>> UsbMainView::createIconNameRow";
+    QGraphicsLinearLayout *listLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout );
+    mlist = new HbListWidget( this );
+    mlist->setMaximumSize( 300, 50 ); //todo
+    mListItem= new HbListWidgetItem();
+    QModelIndex index = mModel->index( UsbUiSettingModel::DefaultMode, KDefaultColumn );
+  //  QVariant iconName = mModel->data( index, Qt::DecorationRole );
+    mIcon = new HbIcon( mModel->data( index, Qt::DecorationRole ).toString() );
+    mListItem->setIcon( *mIcon );
+    mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() );
+    mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() );        
+    mlist->insertItem( 1, mListItem ); 
+    listLayout->addItem( mlist );
+    aLocalPropertiesGroup->addItem( listLayout );
+    myDebug() << "<<< UsbMainView::createIconNameRow";      
+}
+/*!
+ * creates the second row from the view containing the description of the selected mode
+ */
+void UsbMainView::createDescriptionArea( QGraphicsLinearLayout *aLocalPropertiesGroup )
+{ 
+    myDebug() << ">>> UsbMainView::createDescriptionArea";
+    QGraphicsLinearLayout *desLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); 
+    QModelIndex index = mModel->index( UsbUiSettingModel::Description, KDefaultColumn );
+    mlabel = new HbTextEdit( mModel->data( index, Qt::DisplayRole ).toString() );
+    mlabel->setReadOnly( true );
+    mlabel->setCursorVisibility( Hb::TextCursorHidden );
+    desLayout->addItem( mlabel );
+    desLayout->setAlignment( mlabel, Qt::AlignTop );
+    aLocalPropertiesGroup->addItem( desLayout );
+    myDebug() << "<<< UsbMainView::createDescriptionArea";      
+}
+
+/*!
+ * creates the third row from the view containing the radio button list of the existing usb modes
+ */
+void UsbMainView::createRadioButtonArea(QGraphicsLinearLayout *aLocalPropertiesGroup)
+{
+    myDebug() << ">>> UsbMainView::createRadioButtonArea";
+    QGraphicsLinearLayout *radioLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); 
+    QModelIndex index = mModel->index( UsbUiSettingModel::UsbModeList, KDefaultColumn );
+    QStringList radioList = mModel->data( index, UsbUiSettingModel::SettingsModeNameList ).toStringList();
+    int selectedIndex = mModel->data( index, Qt::EditRole ).toInt();
+    mradio = new HbRadioButtonList( radioList, selectedIndex );
+    radioLayout->addItem( mradio );
+    radioLayout->setAlignment( mradio, Qt::AlignBottom );
+    aLocalPropertiesGroup->addItem(radioLayout); 
+    myDebug() << "<<< UsbMainView::createRadioButtonArea";      
+}
+
+/*!
+    Slot for receiving notification of data changes from the model.
+    Identify the setting changed and update the corresponding UI item.
+ */
+void UsbMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{   
+    myDebug() << ">>> UsbMainView::updateSettingItems";
+    // update only the part of the view specified by the model row(s)
+    for ( int row = topLeft.row(); row <= bottomRight.row(); row++ ) {
+        myDebug() << "    UsbMainView::updateSettingItems row=" << row;
+        QModelIndex index = mModel->index( row, KDefaultColumn );
+        // Distinguish which setting value is changed.
+        switch ( row ) {
+        case UsbUiSettingModel::DefaultMode :
+            // set the selected personality icon and name
+            mIcon->setIconName( mModel->data( index, Qt::DecorationRole ).toString() );
+            mListItem->setIcon( *mIcon );
+            mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() );            
+            break;
+        case UsbUiSettingModel::Description :
+            // set the description of the selected personality.
+            mlabel->setPlainText( mModel->data( index, Qt::DisplayRole ).toString() );
+            mlabel->setReadOnly( true );
+            mlabel->setCursorVisibility( Hb::TextCursorHidden );            
+            break;
+        case UsbUiSettingModel::UsbModeList :
+            // only the selection can change, no changes in the list of personalities
+            mradio->setSelected( mModel->data( index, Qt::EditRole ).toInt() );
+            break;
+        default :
+            myDebug() << "    UsbMainView::updateSettingItems unknown row " << row;
+            break;
+        }
+    }
+    myDebug() << "<<< UsbMainView::updateSettingItems";
+}
+
+/*
+ * Slot for receiving notification from the change in radio button list
+ */
+void UsbMainView::setPersonality( int personalityIndex )
+{
+    myDebug() << ">>> UsbMainView::setPersonality";
+    QModelIndex index = mModel->index( UsbUiSettingModel::UsbModeList, KDefaultColumn );
+    mModel->setData( index, personalityIndex, Qt::EditRole );
+    myDebug() << "<<< UsbMainView::setPersonality";
+}
+
+/*!
+ * Destructor
+ * destructs the items which are not owned by this class
+ */
+UsbMainView::~UsbMainView()
+{ 
+    myDebug() << ">>> UsbMainView::~UsbMainView";
+    delete mModel;
+    delete mIcon;
+    myDebug() << "<<< UsbMainView::~UsbMainView";   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbuimodelactive.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,136 @@
+/*
+* 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: 
+*
+*/
+
+#include "usbuimodelactive.h"
+#include "mydebug.h"
+
+//const ?type ?constant_var = ?constant;
+
+
+/*!
+    Constructor.
+ */
+UsbUiModelActive::UsbUiModelActive( int priority, QObject *parent )
+:   QObject( parent )
+{
+    myDebug() << ">>> UsbUiModelActive::UsbUiModelActive";
+    d = new UsbUiModelActivePrivate( this, priority );
+    int err= iUsbWatcher.Connect();    
+    myDebug() << "iUsbWatcher.Connect() returned ";
+    myDebug() << err;  
+    myDebug() << "<<< UsbUiModelActive::UsbUiModelActive";
+}
+
+/*!
+    Destructor.
+ */
+UsbUiModelActive::~UsbUiModelActive()
+{        
+    myDebug() << ">>> UsbUiModelActive::~UsbUiModelActive";
+    delete d;
+    iUsbWatcher.Close(); 
+    myDebug() << "<<< UsbUiModelActive::~UsbUiModelActive";
+}
+/*!
+ * emits a signal when the request is completed
+ */
+void UsbUiModelActive::emitRequestCompleted( int status )
+{
+    myDebug() << ">>> UsbUiModelActive::emitRequestCompleted status: ";
+    myDebug() << status; 
+    emit requestCompleted( status );
+    myDebug() << "<<< UsbUiModelActive::emitRequestCompleted";
+}
+
+/*!
+ * UsbUiModelActive::SetUSBModeL
+ * Sets the Central Repository key to the parameter.
+ */
+int UsbUiModelActive::SetUsbPersonality(int personality)
+    {
+    myDebug() << ">>> UsbUiModelActive::SetUsbPersonality";
+    myDebug() << "requested personality is ";
+    myDebug() << personality;   
+    // Change the personality asynchrously, result checked in RunL()
+    if( IsActive() ) 
+        {
+        Cancel();
+        }
+    myDebug() << "setting new personality";    
+    iUsbWatcher.SetPersonality(RequestStatus(), personality);
+    SetActive();
+    myDebug() << "<<< UsbUiModelActive::SetUsbPersonality, returns 0";
+    return 0;
+    }
+/*!
+ * cancles the personality set in usbwatcher
+ */
+void UsbUiModelActive::CancelSetPersonality()
+    {
+    iUsbWatcher.CancelSetPersonality();    
+    }
+
+/*!
+    Constructor.
+ */
+UsbUiModelActivePrivate::UsbUiModelActivePrivate( 
+        UsbUiModelActive *parent, int priority )
+:   CActive( (TInt) priority ), q( parent )
+{
+    myDebug() << ">>> UsbUiModelActivePrivate::UsbUiModelActivePrivate";
+    CActiveScheduler::Add( this );
+    myDebug() << "<<< UsbUiModelActivePrivate::UsbUiModelActivePrivate";
+}
+
+
+/*!
+    Destructor.
+ */
+UsbUiModelActivePrivate::~UsbUiModelActivePrivate()
+{
+    Cancel();
+}
+
+
+/*!
+ *  Called by the active scheduler when the request has been completed.
+ */
+void UsbUiModelActivePrivate::RunL()
+{
+    myDebug() << ">>> UsbUiModelActivePrivate::RunL";
+    q->emitRequestCompleted( iStatus.Int() );
+    myDebug() << "<<< UsbUiModelActivePrivate::RunL";
+}
+
+
+/*!
+    Called by the active scheduler when the request has been cancelled.
+ */
+void UsbUiModelActivePrivate::DoCancel()
+{
+    q->CancelSetPersonality();
+}
+
+
+/*!
+    Called by the active scheduler when an error in RunL has occurred.
+ */
+TInt UsbUiModelActivePrivate::RunError( TInt aError )
+{
+    q->emitRequestCompleted( aError );
+    return KErrNone;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbuisettingmodel.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,362 @@
+/*
+* 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: 
+*
+*/
+
+#include "usbuisettingmodel.h"
+#include "usbuimodelactive.h"
+#include "mydebug.h"
+#include <QStringList>
+#include <UsbWatcherInternalCRKeys.h>
+#include <XQSettingsKey>
+#include <usbman.h>
+
+const QString TextIdPrefix = ("txt_usb_");
+const QString ModeIconNamePrefix = (":/icons/usb_icon_mode_");
+
+/*!
+    Constructor.
+ */
+UsbUiSettingModel::UsbUiSettingModel( QObject *parent )
+    : QAbstractItemModel( parent )
+{
+    mModelActive = new UsbUiModelActive();
+    
+    for ( int i = 0; i < UsbUiSettingModel::EndOfSettings; i++ ) {
+        // Initialize the list with empty values.
+        mSettingsList.append( QMap< int, QVariant >() );
+    }
+    
+    mCurrentMode = currentMode();
+    mPreviousMode = mCurrentMode;
+    setUsbSettings(mCurrentMode);
+  	bool ret = mSettingsManager.startMonitoring( 
+   	        XQSettingsKey( XQSettingsKey::TargetCentralRepository, 
+   	                KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) );
+    myDebug() << ">>> UsbUiSettingModel::startMonitoring value=" 
+              << ret; 
+                              
+   	// signal: personality changed in the central repository                
+   	connect( &mSettingsManager, 
+   	        SIGNAL( valueChanged( const XQSettingsKey&, const QVariant& ) ), 
+   	        this, 
+   	        SLOT( usbModeChanged( const XQSettingsKey&, const QVariant& ) ) );
+   	        
+   // signal: response from usbwatcher to our attempt to set the personality 	        
+   	connect( mModelActive, 
+   	        SIGNAL( requestCompleted( int status ) ), 
+   	        this, 
+   	        SLOT( setPersonalityCompleted (int status )));
+
+}
+/*!
+ * calls the model's set functions to initialize the model's data
+ */
+void UsbUiSettingModel::setUsbSettings( int aModeId )
+    {
+    setUsbModelistSetting( aModeId ); 
+    setDefaultModeSetting();
+    setDescriptionSetting();
+    }
+
+/*!
+    Destructor.
+ */
+UsbUiSettingModel::~UsbUiSettingModel()
+{
+    myDebug() << ">>> UsbUiSettingModel::~UsbUiSettingModel";
+    mSettingsManager.stopMonitoring( 
+            XQSettingsKey( XQSettingsKey::TargetCentralRepository, 
+                    KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) );
+    delete mModelActive;
+    myDebug() << "<<< UsbUiSettingModel::~UsbUiSettingModel";
+}
+
+/*!
+    Provides notification of changes in selected usb mode
+ */
+void UsbUiSettingModel::usbModeChanged( const XQSettingsKey &key,  
+        const QVariant &value )  
+{
+Q_UNUSED(key);
+    myDebug() << ">>> UsbUiSettingModel::usbModeChanged";
+    // key is not checked, as we monitor only one key
+ 
+    setNewUsbMode(value.toInt());
+                                  
+    myDebug() << "<<< UsbUiSettingModel::usbModeChanged"; 
+}
+/*!
+ * updates the model rows and emits signal datachanged
+ */
+void UsbUiSettingModel::setNewUsbMode(int newPersonality)
+    
+    {
+    myDebug() << ">>> UsbUiSettingModel::setNewUsbMode value=" 
+            << newPersonality; 
+            
+    mCurrentMode = newPersonality;
+    setUsbSettings(mCurrentMode);
+   	
+    emit dataChanged( createIndex( DefaultMode, KDefaultColumn ), 
+            createIndex( UsbModeList, KDefaultColumn ) );   
+         
+    myDebug() << "<<< UsbUiSettingModel::setNewUsbMode"; 
+    }
+/*!
+ * Returns the index of the item in the model specified by the given row, column and parent index.
+ */
+QModelIndex UsbUiSettingModel::index( int row, int column, const QModelIndex &parent ) const
+{
+    return hasIndex( row, column, parent ) ? createIndex( row, column ) : QModelIndex();
+}
+
+
+/*
+    This model does not support hierarchy, so this returns an empty model index. 
+ */
+QModelIndex UsbUiSettingModel::parent( const QModelIndex &child ) const
+{
+    Q_UNUSED( child );
+    return QModelIndex();
+}
+/*!
+ * Returns the number of rows under the given parent
+ */
+int UsbUiSettingModel::rowCount( const QModelIndex &parent ) const
+{
+    Q_UNUSED( parent );
+    return mSettingsList.count();
+}
+
+
+/*!
+ * Returns the number of columns for the children of the given parent.
+ * This model is one-dimensional, so this returns 1.
+ */
+int UsbUiSettingModel::columnCount( const QModelIndex &parent ) const
+{
+    Q_UNUSED( parent );
+    return 1;
+}
+/*!
+ * Returns the data stored under the given role for the item referred to by the index.
+ */
+QVariant UsbUiSettingModel::data( const QModelIndex &index, int role ) const
+{
+    return mSettingsList.value( index.row() ).value( role );
+}
+
+
+/*!
+ * This is called when usb mode is changed, it only sets the personality when the given role is EditRole 
+ */
+bool UsbUiSettingModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+    myDebug() << ">>>  UsbUiSettingModel::setData";
+    bool success = false;
+    if ( role == Qt::EditRole ) {
+        // Only allow changes on the value with role EditRole. Others are managed here.
+        switch ( index.row() ) {
+        case UsbModeList: {            
+            mModelActive->SetUsbPersonality( mPersonalityIds.at( value.toInt() ) );
+            success = true;
+            // also update the rest of the model with the about to be selected mode right away
+            setNewUsbMode(mPersonalityIds.at( value.toInt() ));
+            break;
+            }
+        case DefaultMode:
+            //no break
+        case Description:
+            //no break
+        default:
+            myDebug() << "    UsbUiSettingModel::setData not supported row " << index.row();
+            break;
+        } 
+    }   
+    myDebug() << "<<<  UsbUiSettingModel::setData return " << success;
+    return success;
+}
+
+/*!
+ * Getter for the source data.
+ */
+const QModelIndex* UsbUiSettingModel::sourceData() const
+{
+    return new QModelIndex( createIndex( 0, 0 ) );
+}
+
+/*!
+ * creats the logical name of the modename string for the list
+ */
+QString UsbUiSettingModel::modeListName( int modeId )
+{
+    QString textId = TextIdPrefix + "modelistname_" + QString::number( modeId );
+    QString modeName = qtTrId( textId.toAscii() );
+    return modeName;
+}
+
+/*!
+ * Get the current USB mode (personality) ID
+ */
+int UsbUiSettingModel::currentMode()
+{
+    myDebug() << ">>>  UsbUiSettingModel::CurrentMode";
+    int currentMode = mSettingsManager.readItemValue(
+                XQSettingsKey( XQSettingsKey::TargetCentralRepository, 
+                KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ).toInt();
+    myDebug() << "<<< UsbUiSettingModel::CurrentMode " << currentMode;
+    return currentMode;
+}
+
+/*!
+ * sets the value to different roles of the model's first row
+ */
+void UsbUiSettingModel::setDefaultModeSetting()
+{    
+    QString iconName;
+    QString modeName;
+    //empty iconName and modeName are used for a hidden personality
+    if ( !isPersonalityHidden(mCurrentMode) ) {
+        iconName = ModeIconNamePrefix + QString::number( mCurrentMode ) + ".svg";
+        QString textId = TextIdPrefix + "modename_" + QString::number( mCurrentMode );
+        modeName = qtTrId( textId.toAscii() );
+    }
+
+    myDebug() << ">>> UsbUiSettingModel::setDefaultModeSetting iconName=" 
+            << iconName << " modeName=" << modeName;
+    QMap< int, QVariant > val = mSettingsList.at( DefaultMode );
+    if ( val.isEmpty() ) {
+        val[ SettingType ] = QVariant( DefaultMode );
+    }    
+    val[ Qt::DecorationRole ] = QVariant(iconName) ;
+    val[ Qt::DisplayRole ]= QVariant(modeName) ;
+    mSettingsList.replace( DefaultMode, val );
+    myDebug() << "<<< UsbUiSettingModel::setDefaultModeSetting";
+}
+
+/*!
+    Updates all values related to the mode description.
+ */
+void UsbUiSettingModel::setDescriptionSetting()
+{
+    QString description;
+    //the description will be empty for a hidden personality
+    if ( !isPersonalityHidden(mCurrentMode) ) {
+        QString textId = TextIdPrefix + "description_" 
+                + QString::number( mCurrentMode );
+        description = qtTrId( textId.toAscii() );
+    }
+    myDebug() << ">>> UsbUiSettingModel::setDescriptionSetting description=" 
+            << description;
+    QMap< int, QVariant > val = mSettingsList.at( Description );
+    if ( val.isEmpty() ) {
+       
+        val[ SettingType ] = QVariant( Description );
+     
+    }
+    // The display role stores the string representation of the actual value.
+    val[ Qt::DisplayRole ] = QVariant( description );
+    	 mSettingsList.replace( Description, val );
+    myDebug() << "<<< UsbUiSettingModel::setDescriptionSetting";     
+}
+
+/*!
+    Updates all values related to the visibility setting.
+    Updates the selectable USB modes only in the 1st call.
+ */
+bool UsbUiSettingModel::setUsbModelistSetting( int aModeId )
+{
+    myDebug() << ">>> UsbUiSettingModel::setUsbModelistSetting aModeIndex="
+            << aModeId;
+   bool ret = true;
+    QMap< int, QVariant > val = mSettingsList.at(UsbModeList);
+    if ( val.isEmpty() ) {
+        val[ SettingType ] = QVariant( UsbModeList );
+
+        RUsb iUsbman;
+        if ( iUsbman.Connect() == KErrNone ) {
+            
+            RArray<TInt> personalityIds;
+            mPersonalityIds.clear();
+            if ( iUsbman.GetPersonalityIds( personalityIds ) == KErrNone ) {
+                QStringList modeList;
+                for ( int i = 0; i < personalityIds.Count(); i++ ) {
+                    if ( !isPersonalityHidden(iUsbman, personalityIds[i]) ) {
+                        mPersonalityIds.append( personalityIds[i] );
+                        modeList.append( modeListName( mPersonalityIds[i] ) );                    
+                    }
+                }
+                val[ SettingsModeNameList ] = QVariant( modeList ); 
+            }
+        }
+        else{
+        ret = false;
+        }
+        iUsbman.Close();
+    }
+    //index will be -1 for hidden personality
+    val[ Qt::EditRole ] = QVariant( mPersonalityIds.indexOf(aModeId) );
+    mSettingsList.replace( UsbModeList, val );
+    myDebug() << "<<< UsbUiSettingModel::setUsbModelistSetting";
+    return ret;
+}
+
+/*!
+ * it checks the response from usbwatcher to see if the new mode change has been successful
+ * it will go back to the previous personality if it has not been successfull
+ */
+void UsbUiSettingModel::setPersonalityCompleted (int status )
+{
+  myDebug() << ">>> UsbUiSettingModel::setPersonalityCompleted status= "
+    << status;    
+  // status contains Symbian error code from usbwatcher
+  // if the status is KErrNone, we are ready to process the next request
+  if (status != KErrNone) 
+    {
+    // changing the personality failed, so we need to set back the previous personality
+    // the value will be read from central repository and also updates mCurrentMode  
+    mPreviousMode = mSettingsManager.readItemValue(
+                   XQSettingsKey( XQSettingsKey::TargetCentralRepository, 
+                   KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ).toInt();
+    setNewUsbMode(mPreviousMode);
+    }
+   
+   // after handling the return code we know the the current personality works
+   // and we will not go back to the previous one 
+   mPreviousMode = mCurrentMode; 
+   myDebug() << "<<< UsbUiSettingModel::setPersonalityCompleted";      
+}
+
+bool UsbUiSettingModel::isPersonalityHidden(RUsb &usbman, TInt personalityId)
+{
+    myDebug() << ">>> UsbUiSettingModel::isPersonalityHidden from USB Manager";
+    bool hidden = false;
+    TUint32 property = 0;
+    TInt ret = usbman.GetPersonalityProperty(personalityId, property);
+    if (ret == KErrNone) {
+        myDebug() << "property " << property;
+        if (property & KUsbPersonalityPropertyHidden) {
+            hidden = true;
+        }
+    } 
+    myDebug() << "<<< UsbUiSettingModel::isPersonalityHidden " << hidden;
+    return hidden;
+}
+
+bool UsbUiSettingModel::isPersonalityHidden(TInt personalityId)
+{
+    return ( mPersonalityIds.indexOf(personalityId) == -1 );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbview.docml	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.1">
+    <widget name="viewMain" type="HbView">
+        <widget name="content" role="HbView:widget" type="HbWidget">
+            <widget name="container" type="HbWidget">
+                <sizehint height="18.0" type="MINIMUM" width="18.0"/>
+                <sizehint height="160.0" type="PREFERRED" width="363.0"/>
+                <zvalue value="0.0017000000000000006"/>
+                <layout orientation="Vertical" type="linear"/>
+            </widget>
+            <widget name="container_1" type="HbWidget">
+                <sizehint height="18.0" type="MINIMUM" width="18.0"/>
+                <sizehint height="160.0" type="PREFERRED" width="363.0"/>
+                <zvalue value="0.0016000000000000005"/>
+                <layout orientation="Vertical" type="linear"/>
+            </widget>
+            <widget name="container_2" type="HbWidget">
+                <sizehint height="18.0" type="MINIMUM" width="18.0"/>
+                <sizehint height="160.0" type="PREFERRED" width="363.0"/>
+                <zvalue value="0.0018000000000000006"/>
+                <layout orientation="Vertical" type="linear"/>
+            </widget>
+            <layout type="anchor" widget="content">
+                <anchoritem dst="container" dstEdge="LEFT" spacing="0.0" src="" srcEdge="LEFT"/>
+                <anchoritem dst="container" dstEdge="TOP" spacing="0.0" src="" srcEdge="TOP"/>
+                <anchoritem dst="container" dstEdge="RIGHT" spacing="0.0" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="container_1" dstEdge="LEFT" spacing="0.0" src="" srcEdge="LEFT"/>
+                <anchoritem dst="container_1" dstEdge="TOP" spacing="0.0" src="container" srcEdge="BOTTOM"/>
+                <anchoritem dst="container_1" dstEdge="RIGHT" spacing="0.0" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="container_2" dstEdge="LEFT" spacing="-3.0" src="" srcEdge="LEFT"/>
+                <anchoritem dst="container_2" dstEdge="TOP" spacing="0.0" src="container_1" srcEdge="BOTTOM"/>
+            </layout>
+        </widget>
+        <string name="title" value="USB"/>
+    </widget>
+    <metadata>
+        <resource location="usbapplication.qrc"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/src/usbviewmanager.cpp	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* 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: 
+*
+*/
+
+#include <hbmainwindow.h>
+#include "usbviewmanager.h"
+#include "usbmainview.h"
+
+
+UsbViewManager::UsbViewManager( HbMainWindow* mainWindow, QObject *parent )
+:   QObject( parent ),
+    mWindow(mainWindow)
+    {
+    }
+
+UsbViewManager::~UsbViewManager()
+    {
+    
+    }
+
+/*!
+    Create views(main view, gadget gallery view and gadget details view).
+    Add them to MainWindow.
+ */
+void UsbViewManager::addView()
+    {
+    // Create main view and add
+    mMainView = new UsbMainView( this );
+    mWindow->addView(mMainView);
+      
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuiqt/usbapplication.pro	Fri Jun 04 10:27:39 2010 +0100
@@ -0,0 +1,67 @@
+#
+# 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:  Project definition file for project USB Settings Application
+#
+
+TEMPLATE = app
+TARGET = usbapplication
+QT += core \
+    gui \
+    xml
+HEADERS += inc/usbuisettingmodel.h \
+    inc/usbuimodelactive.h \
+    inc/usbviewmanager.h \
+    inc/usbmainview.h
+SOURCES += src/usbuisettingmodel.cpp \
+    src/usbuimodelactive.cpp \
+    src/usbviewmanager.cpp \
+    src/usbmainview.cpp \
+    src/main.cpp \
+    src/usbapplication_reg.rss
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+LIBS += -lcentralrepository
+LIBS += -lusbwatcher
+LIBS += -lxqsettingsmanager
+LIBS += -lusbman
+
+FORMS += 
+RESOURCES += src/usbicons.qrc \
+    src/usbapplication.qrc
+CONFIG += qt \
+    hb
+
+symbian: {
+    TARGET.UID3 = 0x2002BCA3
+    TARGET.CAPABILITY = LocalServices \
+        WriteDeviceData
+
+	# for pkg
+	usbuitranslation.sources = src/usbapplication.qm
+	usbuitranslation.path = /resource
+	DEPLOYMENT += usbuitranslation
+
+    BLD_INF_RULES.prj_exports += "./src/usbapplication.qm z:/resource/qt/translations/usbapplication.qm
+}
+
+# placeholder for creating sis file
+createsis.commands += ( makesis -v usbapplication.pkg ); \
+    && \
+    ( signsis.exe usbapplication.sis usbapplication_signed.sisx Nokia_RnDCert_02.der Nokia_RnDCert_02.key ); \
+    && \
+    ( del usbapplication.sis );
+QMAKE_EXTRA_TARGETS += createsis
+
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
+        "rom/usbsettings.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(usbsettings.iby)" \
+        "rom/usbsettingsresources.iby   LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(usbsettingsresources.iby)"