--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+ <!ENTITY layer_real_source_path "sf/mw/usbservices" >
+]>
+
+<SystemDefinition name="usbservices" schema="1.4.0">
+ <systemModel>
+ <layer name="mw_layer">
+ <module name="usbservices">
+ <unit unitID="lcdo.usbservices" mrp="" bldFile="&layer_real_source_path;/group" name="usbservices" />
+ </module>
+ <module name="">
+ <unit unitID="lcdo.usbservices.usbclasses.usbosdescriptorhandler" mrp="" bldFile="&layer_real_source_path;/usbclasses/usbosdescriptorhandler/group" filter="!sf_build" name="usbservices_usbclasses_usbosdescriptorhandler" />
+ </module>
+ </layer>
+ </systemModel>
+</SystemDefinition>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml Thu Dec 17 09:14:30 2009 +0200
@@ -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"/>
+ <!-- <unit bldFile="usbclasses/usbobexclasscontroller/tsrc/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="ptpstack" filter="s60" name="Picture Transfer Protocol Stack">
+ <unit bldFile="usbclasses/ptpstack/group"/>
+ </component>
+ <component id="sicdusbplugin" filter="s60" name="SICD USB Plugin" class="plugin">
+ <unit bldFile="usbclasses/sicdusbplugin/group"/>
+ </component>
+ <component id="ptpserver" filter="s60" name="Picture Transfer Protocol Server">
+ <unit bldFile="usbclasses/ptpserver/group"/>
+ <!-- <unit bldFile="usbclasses/ptpserver/ptpclasscontroller/group"/> -->
+ </component>
+ <component id="pictbridgeengine" filter="s60" name="PictBridge Engine">
+ <unit bldFile="usbclasses/pictbridgeengine/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"/>
+ <!-- <unit bldFile="usbengines/usblocodplugin/tsrc/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>
+ </collection>
+ <collection id="usbuis" name="USB UIs" level="specific">
+ <component id="usbui" filter="s60" name="USB UI">
+ <unit bldFile="usbuis/usbui/group"/>
+ <!-- <unit bldFile="usbuis/usbui/tsrc/usbuiapitest/group"/> -->
+ </component>
+ <component id="usbuinotif" filter="s60" name="USB UI Notifiers">
+ <unit bldFile="usbuis/usbuinotif/group"/>
+ <!-- <unit bldFile="usbuis/usbuinotif/tsrc/usbuinotifapitest/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>
+ </package>
+</SystemDefinition>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,86 @@
+ <!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>
+ <!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/usbclasses/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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: 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 "../msmmplugin/group/bld.inf"
+#include "../usbhidclassdriver/group/bld.inf"
+#include "../usbphoneasmodem/group/bld.inf"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/pictbridgeengine/BWINS/pictbridgeU.DEF Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,120 @@
+/*
+* 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())
+ {
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,323 @@
+/*
+* 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)
+ {
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,58 @@
+/*
+* 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
+
+start resource usbms.rss
+targetpath /private/10204bbb
+header
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,426 @@
+/*
+* 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 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;
+
+ /**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:
+*
+*/
+
+
+/**
+ * @file
+ *
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1016 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main 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)
+ {
+ 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();
+
+ // Remove all queries shown by this personality
+ iPersonalityParams.PersonalityNotifier().CancelQuery(KQueriesNotifier);
+
+ 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 )
+ {
+ // 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." ) );
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/usbmscpersonality/src/usbms.rss Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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:
+*
+*/
+
+
+/**
+ * @file
+ *
+ * Resource file for the USB mass storage configuration.
+ */
+
+NAME MSCF
+
+#include <badef.rh>
+#include "usbms.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/usbobexclasscontroller/data/10281F29.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* 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
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,100 @@
+/*
+* 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: 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>
+
+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:
+ /**
+ * 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 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;
+ };
+
+#endif // CUSBOBEXCLASSCONTROLLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/rom/UsbObexClassController.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,262 @@
+/*
+* 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: Implements OBEX class controller
+*
+*/
+
+
+#include "CUsbObexClassController.h"
+#include <usb_std.h>
+#include <obex.h>
+#include <SrcsInterface.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h> //for CleanupResetAndDestroyPushL
+// 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();
+ }
+
+// ---------------------------------------------------------------------------
+// From class CUsbClassControllerPlugIn.
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbObexClassController::~CUsbObexClassController()
+ {
+ LOG_FUNC
+ Cancel();
+ delete iObexSM;
+ }
+
+// ---------------------------------------------------------------------------
+// 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;
+ }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/src/CUsbObexClassImpCollection.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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/tsrc/UsbObexClassControllerTest/Bmarm/UsbObexClassControllerTestU.DEF Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/Bwins/UsbObexClassControllerTestU.DEF Thu Dec 17 09:14:30 2009 +0200
@@ -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/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/EABI/UsbObexClassControllerTestU.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+ _ZTI27CUSBObexApiTestActiveObject @ 2 NONAME
+ _ZTV27CUSBObexApiTestActiveObject @ 3 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/conf/UsbObexClassControllerTest.cfg Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,106 @@
+[StifSettings]
+CapsModifier= UsbObexClassControllerTest.exe
+[EndStifSettings]
+
+// UsbObexClassControllerTest Module - total ... tc
+
+// UsbObexClassControllerTest Api Tests (... tc)
+
+//[Test]
+//title Example Api Test
+//create UsbObexClassControllerTest tester
+//tester ExecuteApiTest ExampleApiTest
+//delete tester
+//[Endtest]
+
+[Test]
+title Initialization Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest InitializationTest
+delete tester
+[Endtest]
+
+[Test]
+title Start Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest StartTest
+delete tester
+[Endtest]
+
+[Test]
+title Stop Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest StopTest
+delete tester
+[Endtest]
+
+[Test]
+title InterfaceInfo Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest InterfaceInfoTest
+delete tester
+[Endtest]
+
+[Test]
+title InterfaceLengthInfo Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest InterfaceLengthInfoTest
+delete tester
+[Endtest]
+
+[Test]
+title NumberOfInterfacesInfo Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest NumberOfInterfacesInfoTest
+delete tester
+[Endtest]
+
+[Test]
+title StartupPriorityInfo Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest StartupPriorityInfoTest
+delete tester
+[Endtest]
+
+[Test]
+title StateInfo Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest StateInfoTest
+delete tester
+[Endtest]
+
+[Test]
+title Owner Test
+create UsbObexClassControllerTest tester
+tester ExecuteApiTest OwnerTest
+delete tester
+[Endtest]
+
+// Add new api tests here
+// ...
+
+
+// UsbObexClassControllerTest Module Tests (... tc)
+
+//[Test]
+//title Example Module Test
+//create UsbObexClassControllerTest tester
+//tester ExecuteModuleTest ExampleModuleTest
+//delete tester
+//[Endtest]
+
+// Add new module tests here
+// ...
+
+
+// UsbObexClassControllerTest Branch Tests (... tc)
+
+//[Test]
+//title Example Branch Test
+//create UsbObexClassControllerTest tester
+//tester ExecuteBranchTest ExampleBranchTest
+//delete tester
+//[Endtest]
+
+// Add new branch tests here
+// ...
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/UsbObexClassControllerTest.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,50 @@
+/*TYPE TESTCLASS*/
+/*
+* 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 UsbObexClassControllerTest.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY NetworkControl LocalServices NetworkServices CommDD ProtServ
+
+DEFFILE UsbObexClassControllerTest.def
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+
+SOURCEPATH ../src
+SOURCE UsbObexClassControllerTest.cpp
+SOURCE UsbObexClassControllerTestBlocks.cpp USBObexApiTestActiveObject.cpp UsbObexClassControllerTest_exe.cpp
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY stiftestengine.lib
+LIBRARY usbclasscontroller.lib
+LIBRARY ecom.lib
+
+
+LANG SC
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/UsbObexClassControllerTest_ats.pkg Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+;
+
+; 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\UsbObexClassControllerTest.dll"-"c:\Sys\Bin\UsbObexClassControllerTest.dll"
+"\epoc32\release\armv5\udeb\UsbObexClassControllerTest.exe"-"c:\Sys\Bin\UsbObexClassControllerTest.exe"
+
+"..\init\UsbObexClassControllerTest_ats.ini"-"e:\testing\init\UsbObexClassControllerTest.ini"
+"..\conf\UsbObexClassControllerTest.cfg"-"e:\testing\conf\UsbObexClassControllerTest.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/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/UsbObexClassControllerTest_exe.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,42 @@
+/*TYPE TESTCLASS*/
+/*
+* 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 UsbObexClassControllerTest.exe
+TARGETTYPE exe
+
+CAPABILITY NetworkControl LocalServices NetworkServices CommDD ProtServ
+
+UID 0 0xEF4892C6
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+
+SOURCE UsbObexClassControllerTest_exe.cpp
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+
+EPOCSTACKSIZE 40960
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/UsbObexClassControllerTest_phone.pkg Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+;
+
+; 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\UsbObexClassControllerTest.dll"-"c:\Sys\Bin\UsbObexClassControllerTest.dll"
+"\epoc32\release\armv5\udeb\UsbObexClassControllerTest.exe"-"c:\Sys\Bin\UsbObexClassControllerTest.exe"
+
+"..\init\UsbObexClassControllerTest_phone.ini"-"c:\testframework\testframework.ini"
+"..\conf\UsbObexClassControllerTest.cfg"-"c:\testframework\UsbObexClassControllerTest.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/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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
+UsbObexClassControllerTest.mmp
+UsbObexClassControllerTest_exe.mmp
+
+PRJ_MMPFILES
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/build_sis_ats.bat Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,23 @@
+@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 reallyclean armv5
+call abld test build armv5
+call makesis UsbObexClassControllerTest_ats.pkg
+call signsis UsbObexClassControllerTest_ats.sis UsbObexClassControllerTest_ats.sisx rd.cer rd-key.pem
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/group/build_sis_phone.bat Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,23 @@
+@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 reallyclean armv5
+call abld test build armv5
+call makesis UsbObexClassControllerTest_phone.pkg
+call signsis UsbObexClassControllerTest_phone.sis UsbObexClassControllerTest_phone.sisx rd.cer rd-key.pem
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/inc/USBObexApiTestActiveObject.h Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+*
+*/
+
+#ifndef USBOBEXAPITESTACTIVEOBJECT_H_
+#define USBOBEXAPITESTACTIVEOBJECT_H_
+
+#include <e32base.h>
+#include <StifLogger.h>
+#include <CUsbClassControllerPlugIn.h>
+
+class CStifLogger;
+class CUsbClassControllerPlugIn;
+
+class CUSBObexApiTestActiveObject : public CActive
+{
+public:
+ static CUSBObexApiTestActiveObject* NewL
+ (CStifLogger* aLog,
+ CUsbClassControllerPlugIn* aUsbClassControllerPlugIn);
+ virtual ~CUSBObexApiTestActiveObject();
+
+ void Start();
+ void Stop();
+
+private:
+ CUSBObexApiTestActiveObject
+ (CStifLogger* aLog,
+ CUsbClassControllerPlugIn* aUsbClassControllerPlugIn);
+ void RunL();
+ void DoCancel();
+ void ConstructL();
+
+
+private:
+ CStifLogger* iLog;
+ CUsbClassControllerPlugIn* iUsbClassControllerPlugIn;
+ TUsbServiceState iUsbServiceState;
+};
+
+#endif /*USBOBEXAPITESTACTIVEOBJECT_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/inc/UsbObexClassControllerTest.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,240 @@
+/*
+* 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 USBOBEXCLASSCONTROLLERTEST_H
+#define USBOBEXCLASSCONTROLLERTEST_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include "USBObexApiTestActiveObject.h"
+#include <musbclasscontrollernotify.h>
+#include <cusbclasscontrollerplugin.h>
+#include <usbobex.h>
+#include <usb_std.h>
+#include <ecom/ecom.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( KUsbObexClassControllerTestLogPath, "\\logs\\testframework\\UsbObexClassControllerTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+//_LIT( KUsbObexClassControllerTestLogPath, "e:\\testing\\stiflogs\\" );
+
+// Log file
+_LIT( KUsbObexClassControllerTestLogFile, "UsbObexClassControllerTest.txt" );
+_LIT( KUsbObexClassControllerTestLogFileWithTitle, "UsbObexClassControllerTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CUsbObexClassControllerTest;
+class CUsbClassControllerIterator;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TUsbObexClassControllerTestResult
+ {
+ ETestCasePassed,
+ ETestCaseFailed
+ };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+* CUsbObexClassControllerTest test class for STIF Test Framework TestScripter.
+* ?other_description_lines
+*
+* @lib ?library
+* @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CUsbObexClassControllerTest) :
+ public CScriptBase,
+ public MUsbClassControllerNotify
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static CUsbObexClassControllerTest* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbObexClassControllerTest();
+
+ 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 );
+
+ /**
+ * overrider of pure virtual functions from MUsbClassControllerNotify class
+ */
+ CUsbClassControllerIterator* UccnGetClassControllerIteratorL();
+ void UccnError(TInt aError);
+
+ 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.
+ */
+ CUsbObexClassControllerTest( 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, TUsbObexClassControllerTestResult& aTestResult );
+
+ void ExampleApiTestL( TUsbObexClassControllerTestResult& aTestResult );
+
+ void DoExecuteModuleTestL( TPtrC aModuleTestName, TUsbObexClassControllerTestResult& aTestResult );
+
+ void ExampleModuleTestL( TUsbObexClassControllerTestResult& aTestResult );
+
+ void DoExecuteBranchTestL( TPtrC aBranchTestName, TUsbObexClassControllerTestResult& aTestResult );
+
+ void ExampleBranchTestL( TUsbObexClassControllerTestResult& aTestResult );
+
+ void InitializeTestObjectL();
+ void DeleteTestObject();
+ TInt InitializationTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt StartTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt StopTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt InterfaceInfoTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt InterfaceLengthInfoTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt NumberOfInterfacesInfoTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt StartupPriorityInfoTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt StateInfoTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt OwnerTestL( TUsbObexClassControllerTestResult& aTestResult );
+ TInt CompareTestL( TUsbObexClassControllerTestResult& aTestResult );
+
+ public: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ protected: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ private: // Data
+
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ CUsbClassControllerPlugIn* iUsbClassControllerPlugIn;
+ CActiveScheduler* iScheduler;
+ TRequestStatus iRequestStatus;
+ TUsbServiceState iUsbServiceState;
+
+ // 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 // USBOBEXCLASSCONTROLLERTEST_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/init/UsbObexClassControllerTest_ats.ini Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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= UsbObexClassControllerTest_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= UsbObexClassControllerTestUsbObexClassControllerTestUsbObexClassControllerTest
+# 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\UsbObexClassControllerTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbObexClassControllerTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbObexClassControllerTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUsbObexClassControllerTest 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/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/init/UsbObexClassControllerTest_phone.ini Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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\UsbObexClassControllerTest\
+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= UsbObexClassControllerTestUsbObexClassControllerTestUsbObexClassControllerTest
+# 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\UsbObexClassControllerTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbObexClassControllerTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbObexClassControllerTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleUsbObexClassControllerTest 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/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/src/USBObexApiTestActiveObject.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* 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 "USBObexApiTestActiveObject.h"
+
+// -----------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::CUSBObexApiTestActiveObject
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUSBObexApiTestActiveObject::CUSBObexApiTestActiveObject( CStifLogger* aLog,
+ CUsbClassControllerPlugIn* aUsbClassControllerPlugIn ) :
+ CActive( EPriorityStandard )
+ {
+ iUsbClassControllerPlugIn = aUsbClassControllerPlugIn;
+ iLog = aLog;
+ }
+
+// Destructor
+CUSBObexApiTestActiveObject::~CUSBObexApiTestActiveObject()
+ {
+ Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::RunL
+// ---------------------------------------------------------------------------
+//
+void CUSBObexApiTestActiveObject::RunL()
+ {
+ iLog->Log( _L("ActiveTestObject::RunL"));
+ CActiveScheduler::Stop();
+ iLog->Log( _L("ActiveScheduler Stopped"));
+ iUsbServiceState = iUsbClassControllerPlugIn -> State();
+ }
+
+// -----------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUSBObexApiTestActiveObject* CUSBObexApiTestActiveObject::NewL(
+ CStifLogger* aLog, CUsbClassControllerPlugIn* aUsbClassControllerPlugIn )
+ {
+ CUSBObexApiTestActiveObject* self = new ( ELeave )CUSBObexApiTestActiveObject( aLog, aUsbClassControllerPlugIn );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUSBObexApiTestActiveObject::ConstructL()
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CUSBObexApiTestActiveObject::DoCancel()
+ {
+ iLog->Log( _L("ActiveTestObject::DoCancel"));
+ }
+
+// ---------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::Start
+// ---------------------------------------------------------------------------
+//
+void CUSBObexApiTestActiveObject::Start()
+ {
+ iUsbClassControllerPlugIn -> Start( iStatus );
+ SetActive();
+ iLog->Log( _L("Obex Controller Started"));
+ }
+
+// ---------------------------------------------------------------------------
+// CUSBObexApiTestActiveObject::Stop
+// ---------------------------------------------------------------------------
+//
+void CUSBObexApiTestActiveObject::Stop()
+ {
+ iUsbClassControllerPlugIn -> Stop( iStatus );
+ SetActive();
+ iLog->Log( _L("Obex Controller Stopped"));
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/src/UsbObexClassControllerTest.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,202 @@
+/*
+* 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 "UsbObexClassControllerTest.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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::CUsbObexClassControllerTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUsbObexClassControllerTest::CUsbObexClassControllerTest(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::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(KUsbObexClassControllerTestLogFileWithTitle, &title);
+ }
+ else
+ {
+ logFileName.Copy(KUsbObexClassControllerTestLogFile);
+ }
+
+ iLog = CStifLogger::NewL( KUsbObexClassControllerTestLogPath,
+ logFileName,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+
+ SendTestClassVersion();
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbObexClassControllerTest* CUsbObexClassControllerTest::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ CUsbObexClassControllerTest* self = new (ELeave) CUsbObexClassControllerTest( aTestModuleIf );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+
+ }
+
+// Destructor
+CUsbObexClassControllerTest::~CUsbObexClassControllerTest()
+ {
+
+ // Delete resources allocated from test methods
+ Delete();
+
+ // Delete logger
+ delete iLog;
+
+ }
+
+//-----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::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("UsbObexClassControllerTest.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* ) CUsbObexClassControllerTest::NewL( aTestModuleIf );
+
+ }
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/src/UsbObexClassControllerTestBlocks.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,681 @@
+/*
+* 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 "UsbObexClassControllerTest.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+const TUid KCSrcsInterfaceUid = {0x101F7C8C};
+const TInt KObexNumInterfaces = 2;
+
+// 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 ===============================
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::Delete()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::RunMethodL(
+ CStifItemParser& aItem )
+ {
+
+ static TStifFunctionInfo const KFunctions[] =
+ {
+ //ADD NEW ENTRY HERE
+ // [test cases entries] - Do not remove
+ ENTRY( "ExecuteApiTest", CUsbObexClassControllerTest::ExecuteApiTest ),
+ ENTRY( "ExecuteModuleTest", CUsbObexClassControllerTest::ExecuteModuleTest ),
+ ENTRY( "ExecuteBranchTest", CUsbObexClassControllerTest::ExecuteBranchTest ),
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExecuteApiTest
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::ExecuteApiTest( CStifItemParser& aItem )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExecuteApiTest" );
+
+ TInt res;
+ TUsbObexClassControllerTestResult testResult = ETestCaseFailed;
+ 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;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::DoExecuteApiTestL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::DoExecuteApiTestL( TPtrC aApiTestName, TUsbObexClassControllerTestResult& aTestResult )
+ {
+ STIF_LOG( "[STIF_LOG] >>>DoExecuteApiTestL" );
+ if ( !aApiTestName.Compare( _L( "ExampleApiTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ ExampleApiTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "InitializationTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ InitializationTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "StartTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ StartTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "StopTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ StopTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "InterfaceInfoTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ InterfaceInfoTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "InterfaceLengthInfoTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ InterfaceLengthInfoTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "NumberOfInterfacesInfoTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ NumberOfInterfacesInfoTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "StartupPriorityInfoTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ StartupPriorityInfoTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "StateInfoTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ StateInfoTestL( aTestResult );
+ }
+ else if ( !aApiTestName.Compare( _L( "OwnerTest" ) ) )
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: ExampleApiTest" );
+ OwnerTestL( aTestResult );
+ }
+ else
+ {
+ STIF_LOG( "[STIF_LOG] Api test type: not found" );
+ User::Leave( KErrNotFound );
+ }
+ STIF_LOG( "[STIF_LOG] <<<DoExecuteApiTestL" );
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExecuteApiTest
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::ExampleApiTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExampleApiTestL" );
+
+ aTestResult = ETestCasePassed;
+
+ STIF_LOG( "[STIF_LOG] <<<ExampleApiTestL" );
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExecuteModuleTest
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::ExecuteModuleTest( CStifItemParser& aItem )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExecuteModuleTest" );
+
+ TInt res;
+ TUsbObexClassControllerTestResult 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;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::DoExecuteModuleTestL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::DoExecuteModuleTestL( TPtrC aModuleTestName, TUsbObexClassControllerTestResult& 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" );
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExampleModuleTestL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::ExampleModuleTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExampleModuleTestL" );
+
+ aTestResult = ETestCasePassed;
+
+ STIF_LOG( "[STIF_LOG] <<<ExampleModuleTestL" );
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExecuteBranchTest
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::ExecuteBranchTest( CStifItemParser& aItem )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExecuteBranchTest" );
+
+ TInt res;
+ TUsbObexClassControllerTestResult 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;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::DoExecuteBranchTestL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::DoExecuteBranchTestL( TPtrC aBranchTestName, TUsbObexClassControllerTestResult& 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" );
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::ExampleBranchTestL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::ExampleBranchTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ STIF_LOG( "[STIF_LOG] >>>ExampleBranchTestL" );
+
+ aTestResult = ETestCasePassed;
+
+ STIF_LOG( "[STIF_LOG] <<<ExampleBranchTestL" );
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::InitializationTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::InitializationTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ InitializeTestObjectL();
+ STIF_ASSERT_NOT_NULL( iUsbClassControllerPlugIn );
+ DeleteTestObject();
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::StartTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::StartTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ iUsbServiceState = EUsbServiceStarted;
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ iLog->Log( _L("UsbServiceState = %d, expected %d"),
+ iUsbServiceState, iUsbClassControllerPlugIn -> State());
+ STIF_ASSERT_EQUALS( iUsbServiceState, iUsbClassControllerPlugIn -> State() );
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::StopTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::StopTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ iUsbServiceState = EUsbServiceIdle;
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ activeTestObject -> Stop();
+ CActiveScheduler::Start();
+ iLog->Log( _L("UsbServiceState = %d, expected %d"),
+ iUsbServiceState, iUsbClassControllerPlugIn -> State());
+ STIF_ASSERT_EQUALS( iUsbServiceState, iUsbClassControllerPlugIn -> State() );
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::InterfaceInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::InterfaceInfoTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ TUsbDescriptor aDescriptorInfo;
+ RImplInfoPtrArray implInfoArray;
+ CleanupClosePushL(implInfoArray);
+ TEComResolverParams resolverParams;
+ TInt numberOfInterfaces;
+
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ iUsbClassControllerPlugIn -> GetDescriptorInfo( aDescriptorInfo );
+ resolverParams.SetDataType( KSrcsTransportUSB );
+ resolverParams.SetWildcardMatch( EFalse );
+ REComSession::ListImplementationsL( KCSrcsInterfaceUid, resolverParams, implInfoArray );
+ numberOfInterfaces = implInfoArray.Count() * KObexNumInterfaces;
+
+ iLog->Log( _L("Number of interfaces = %d, expected %d"),
+ numberOfInterfaces, aDescriptorInfo.iNumInterfaces);
+ STIF_ASSERT_EQUALS( numberOfInterfaces, aDescriptorInfo.iNumInterfaces );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+ CleanupStack::PopAndDestroy(&implInfoArray);
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::InterfaceLengthInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::InterfaceLengthInfoTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ TUsbDescriptor aDescriptorInfo;
+ RImplInfoPtrArray implInfoArray;
+ CleanupClosePushL(implInfoArray);
+ TEComResolverParams resolverParams;
+ TInt interfaceLength = 0;
+
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ iUsbClassControllerPlugIn -> GetDescriptorInfo( aDescriptorInfo );
+ resolverParams.SetDataType( KSrcsTransportUSB );
+ resolverParams.SetWildcardMatch( EFalse );
+ REComSession::ListImplementationsL( KCSrcsInterfaceUid, resolverParams, implInfoArray );
+
+ iLog->Log( _L("Interface Length = %d, expected %d"),
+ interfaceLength, aDescriptorInfo.iLength);
+ STIF_ASSERT_EQUALS( interfaceLength, aDescriptorInfo.iLength );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+ CleanupStack::PopAndDestroy(&implInfoArray);
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::NumberOfInterfacesInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::NumberOfInterfacesInfoTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ TUsbDescriptor aDescriptorInfo;
+ RImplInfoPtrArray implInfoArray;
+ CleanupClosePushL(implInfoArray);
+ TEComResolverParams resolverParams;
+ TInt interfaceLength = 0;
+
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ iUsbClassControllerPlugIn -> GetDescriptorInfo( aDescriptorInfo );
+ resolverParams.SetDataType( KSrcsTransportUSB );
+ resolverParams.SetWildcardMatch( EFalse );
+ REComSession::ListImplementationsL( KCSrcsInterfaceUid, resolverParams, implInfoArray );
+
+ iLog->Log( _L("Number of Interfaces this class controller is responsible for = %d, expected %d"),
+ interfaceLength, aDescriptorInfo.iNumInterfaces);
+ STIF_ASSERT_EQUALS( interfaceLength, aDescriptorInfo.iLength );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+ CleanupStack::PopAndDestroy(&implInfoArray);
+
+ // Case was executed
+ iLog->Log( _L("Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::StartupPriorityInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::StartupPriorityInfoTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ TInt priority = 0;
+
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ priority = iUsbClassControllerPlugIn -> StartupPriority();
+
+ iLog->Log( _L("StartupPriorityInfoTestL:> Priority = %d "),priority );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("StartupPriorityInfoTestL:> Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::StateInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::StateInfoTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ TUsbServiceState state;
+
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ state = iUsbClassControllerPlugIn -> State();
+
+ iLog->Log( _L("StateTestL:> State = 0x%x "), state );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("StateInfoTestL:> Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::OwnerTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::OwnerTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ InitializeTestObjectL();
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+ (iUsbClassControllerPlugIn -> Owner()).UccnGetClassControllerIteratorL();
+
+ (iUsbClassControllerPlugIn -> Owner()).UccnError( KErrNone );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("OwnerTestL:> Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::CompareTestL
+// -----------------------------------------------------------------------------
+//
+TInt CUsbObexClassControllerTest::CompareTestL( TUsbObexClassControllerTestResult& aTestResult )
+ {
+ InitializeTestObjectL();
+
+ CUSBObexApiTestActiveObject* activeTestObject =
+ CUSBObexApiTestActiveObject::NewL( iLog, iUsbClassControllerPlugIn );
+ activeTestObject -> Start();
+ CActiveScheduler::Start();
+
+ //result = iUsbClassControllerPlugIn -> Compare( this, iUsbClassControllerPlugIn );
+ //iLog->Log( _L("CompareTestL:> Comparition Result = %d "),result );
+
+ DeleteTestObject();
+ activeTestObject -> Cancel();
+
+ // Case was executed
+ iLog->Log( _L("CompareTestL:> Test Case Passed"));
+ aTestResult = ETestCasePassed;
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::InitializeTestObjectL
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::InitializeTestObjectL()
+ {
+ iUsbClassControllerPlugIn = CUsbClassControllerPlugIn::NewL( TUid::Uid( 0x10281F2A ), *this);
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::DeleteTestObject
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::DeleteTestObject()
+ {
+ delete iUsbClassControllerPlugIn;
+ iUsbClassControllerPlugIn = NULL;
+ REComSession::FinalClose();
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::UccnGetClassControllerIteratorL
+// -----------------------------------------------------------------------------
+//
+CUsbClassControllerIterator* CUsbObexClassControllerTest::UccnGetClassControllerIteratorL()
+ {
+ iLog->Log( _L("get class controller iterator"));
+ return (CUsbClassControllerIterator *)NULL;
+ }
+
+// -----------------------------------------------------------------------------
+// CUsbObexClassControllerTest::UccnError
+// -----------------------------------------------------------------------------
+//
+void CUsbObexClassControllerTest::UccnError( TInt aError )
+ {
+ iLog->Log( _L("class controller iterator error: %d"), aError );
+ }
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+// [End of File] - Do not remove
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbobexclasscontroller/tsrc/UsbObexClassControllerTest/src/UsbObexClassControllerTest_exe.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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
+ // UsbObexClassControllerTest_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/usbclasses/usbphoneasmodem/classcontroller/data/2000fda8.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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/usbmscfileresource.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+// RESOURCE IDENTIFIER
+NAME UMSC
+
+#include <eikon.rh>
+#include "usbmscfileclasscontroller.rh"
+
+// CONSTANTS
+
+// MACROS
+
+// RESOURCE DEFINITIONS
+
+//-----------------------------------------------------------------------------
+//
+// -
+// Resource signature
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE {}
+
+//-----------------------------------------------------------------------------
+//
+// -
+// Resource filename
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE TBUF
+ {
+ buf = "usbmscfileresource";
+ }
+
+RESOURCE ARRAY r_usbmscfile_image_paths
+ {
+ items =
+ {
+ USBMSCFILE_FILESYSTEM_IMAGE
+ {
+ lun = 0;
+ path = "phone_as_modem.iso";
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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
+usbmscfileclasscontroller.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+../rom/usbmscfileclasscontroller.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbmscfileclasscontroller.iby)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/group/usbmscfileclasscontroller.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -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 <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 usbmscfileresource.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+END
+
+LIBRARY euser.lib
+LIBRARY usbclasscontroller.lib
+LIBRARY efsrv.lib
+LIBRARY bafl.lib
+DEBUGLIBRARY flogger.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/inc/usbmscfileclasscontroller.h Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+ 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.rh Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+
+#include <badef.rh>
+
+STRUCT USBMSCFILE_FILESYSTEM_IMAGE
+ {
+ WORD protocol = 0; // protocol not used
+ WORD lun; // only LUN 0 supported currently
+ LTEXT path; // full path to file system image file
+ }
+
+// End Of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/rom/usbmscfileclasscontroller.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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)
+S60_APP_RESOURCE(usbmscfileresource)
+
+#endif
+
+#endif // __USBMSCFILECLASSCONTROLLER_IBY__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontroller.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,441 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ 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 <usbms.rsg>
+#include <usbmscfileresource.rsg>
+#include <data_caging_path_literals.hrh>
+#include "usbmscfileclasscontroller.h"
+#include "usbmscfile.h"
+#include "debug.h"
+
+// Panic category
+#ifdef _DEBUG
+_LIT( KMsCcPanicCategory, "UsbMscFileCc" );
+#endif
+
+_LIT( KResourceFileName, "usbmscfileresource.rsc" );
+_LIT( KUsbMsResource, "\\private\\101fe1db\\usbms.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 );
+ LEAVE_IF_ERROR( fs.Connect() );
+ CleanupClosePushL( fs );
+
+ TFileName fileName;
+ const TDriveNumber KStoreDrive = EDriveZ;
+ TDriveUnit driveUnit( KStoreDrive );
+ TDriveName drive = driveUnit.Name();
+ fileName.Insert( 0, drive );
+
+ fileName += KDC_APP_RESOURCE_DIR; // From data_caging_path_literals.hrh
+ fileName += KResourceFileName;
+
+ RResourceFile resourceFile;
+ CleanupClosePushL( resourceFile );
+ resourceFile.OpenL( fs, fileName );
+ resourceFile.ConfirmSignatureL();
+
+ HBufC8* buf8 = resourceFile.AllocReadLC( R_USBMSCFILE_IMAGE_PATHS );
+
+ TResourceReader reader;
+ reader.SetBuffer( buf8 );
+
+ TInt count = reader.ReadInt16();
+
+ while ( count-- )
+ {
+ TInt protocol = reader.ReadUint16();
+ TInt lun = reader.ReadUint16();
+ HBufC* path = reader.ReadHBufCL();
+ CleanupStack::PushL( path );
+ LEAVE_IF_ERROR( mscFile.SetupLogicalUnit( *path, protocol, lun ) );
+ CleanupStack::PopAndDestroy( path );
+ }
+ CleanupStack::PopAndDestroy( 4 ); // mscFile, fs, resourceFile, buf8
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/classcontroller/src/usbmscfileclasscontrollerimp.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+/**
+ @file
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,104 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,90 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+/**
+ @file
+ @internalTechnology
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+/**
+ @file
+ @internalTechnology
+ */
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,262 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,79 @@
+// 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:
+//
+//
+
+/**
+ @file
+ @internalTechnology
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+/**
+ @file
+ @internalTechnology
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+//
+
+
+/*
+ @file
+ @internalTechnology
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,70 @@
+// 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:
+//
+//
+
+/**
+ * @file
+ * @internalComponent
+ *
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,73 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ @internalTechnology
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+//
+//
+
+
+
+/**
+@file
+@internalTechnology
+*/
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,241 @@
+// 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:
+//
+//
+
+
+/**
+@file
+@internalTechnology
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1493 @@
+// 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:
+//
+//
+/**
+ @file
+ */
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,99 @@
+// 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:
+//
+//
+
+/**
+ @file
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,163 @@
+// 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:
+//
+//
+
+/**
+ @file
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,196 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,211 @@
+// 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:
+//
+//
+
+
+/**
+ @file
+ 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 buf;
+ TInt len = aMessage.GetDesLength( 0 );
+ buf.CreateL( len );
+ buf.CleanupClosePushL();
+ aMessage.ReadL( 0, buf );
+ protocol = aMessage.Int1();
+ lun = aMessage.Int2();
+
+ //get the directory and name of image file
+ 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 );
+ // append private path
+ TPath privatePath;
+ fs.PrivatePath(privatePath);
+ fileName.Append(privatePath);
+ CleanupStack::PopAndDestroy(&fs);
+
+ fileName.Append(buf);
+ iMscFileServer.Controller().SetupLogicalUnitL( fileName, protocol, lun );
+ CleanupStack::PopAndDestroy( &buf );
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1089 @@
+// 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:
+//
+//
+
+/**
+ @file
+ 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());
+ }
+
Binary file usbclasses/usbphoneasmodem/document/S60_USB_Phone_As_Modem.mdzip has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbclasses/usbphoneasmodem/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,192 @@
+/*
+* 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: 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();
+
+ /**
+ * Take needed actions on resuming services
+ *
+ * @since S60 v.5.0
+ */
+ void ResumeL();
+
+ // 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,419 @@
+/*
+* 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: 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" ) );
+
+ StartL();
+ break;
+ }
+
+ case EUsbcDeviceStatePowered:
+ {
+
+ FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Powered" ) );
+
+ StartL();
+ break;
+ }
+
+ case EUsbcDeviceStateDefault:
+ {
+
+ 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" ) );
+
+ if(iPrevUsbState == EUsbcDeviceStateSuspended)
+ {
+ ResumeL();
+ }
+ else
+ {
+ StartL();
+ }
+
+ break;
+ }
+ case EUsbcDeviceStateSuspended:
+ {
+
+ FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Suspended" ) );
+
+ break;
+ }
+
+ default:
+ {
+
+ FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: ***Undefined***" ) );
+
+ 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
+ CUsbDevCon:: ~CUsbDevCon(); // destruct resources
+ User::Exit(KErrNone);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// 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" ) );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Resumes UsbDevCon services
+// ---------------------------------------------------------------------------
+//
+void CUsbDevCon::ResumeL()
+ {
+
+ FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ResumeL" ) );
+
+ // Resume state machine
+ StartL();
+
+ }
+
+// ----------------------------------------------------------------------------
+// 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* 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: 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();
+ void NotifyLcd(TBool aUsbStatus);
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,161 @@
+/*
+* 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: 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 = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, value);
+ LOGTEXT2(_L8("CUsbLcdActive::RunL() Personality = %d"), value);
+ iProperty.Subscribe(iStatus);
+ SetActive();
+ if (ret == KErrNone)
+ {
+ switch (value)
+ {
+ case KUsbPersonalityIdPCSuite:
+ case KUsbPersonalityIdPCSuiteMTP:
+ NotifyLcd(ETrue);
+ LOGTEXT(_L8("CUsbLcdActive::RunL() in PC Suite mode"));
+ break;
+
+ default:
+ NotifyLcd(EFalse);
+ LOGTEXT(_L8("CUsbLcdActive::RunL() mode is not PC Suite"));
+ break;
+ }
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// 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();
+ }
+
+// ---------------------------------------------------------------------------
+// This function notifying LoCoD framewark about active USB personality
+// If Personality == 113 (PC Suite), then ETrue; in all other cases is EFalse
+// ---------------------------------------------------------------------------
+//
+void CUsbLcdActive::NotifyLcd(TBool aUsbStatus)
+ {
+ LOG_FUNC
+ iObserver.NotifyBearerStatus(ELocodBearerUSB, aUsbStatus);
+ }
+
+//End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usblocodplugin/src/usblcdplugin.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,74 @@
+// 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,52 @@
+/*TYPE TESTCLASS*/
+/*
+* 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 ?myapp
+*
+*/
+
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -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: 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 panic.cpp
+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 cusbpersonalityswitch.cpp
+
+SOURCE cusbstate.cpp
+SOURCE cusbstatehostabase.cpp
+SOURCE cusbstatehostainitiatebase.cpp
+SOURCE cusbstatehostainitiate.cpp
+SOURCE cusbstatehostahost.cpp
+SOURCE cusbstatehostaperipheral.cpp
+SOURCE cusbstatehostaidle.cpp
+SOURCE cusbstatehosthandle.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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* 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: 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
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* 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: 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
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* 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: 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
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,111 @@
+/*
+* 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 "cusbtimer.h"
+#include "cusbnotifier.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, MUsbTimerObserver
+ {
+public:
+ /**
+ * Two-phased constructor.
+ * @param aNotifManager Owner of the class, will destroy the object when needed
+ * @return Pointer to the new instance of CUsbIndicatorNotifier
+ */
+ static CUsbIndicatorNotifier* NewL(CUsbNotifManager* aNotifManager);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbIndicatorNotifier();
+
+ /**
+ * 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 ShowIndicatorL(TBool aVisible);
+
+ // From base class CUsbNotifier
+ /**
+ * Start to show notifier
+ */
+ virtual void ShowL();
+
+ /**
+ * Stop showing notifier
+ */
+ virtual void Close();
+
+ // From MUsbTimerObserver
+ /**
+ * Timer elapsed
+ * @param Timer id
+ */
+ void TimerElapsedL(TUsbTimerId aTimerId);
+
+private:
+
+ /**
+ * Default constructor.
+ * @param aNotifManager Owner
+ */
+ CUsbIndicatorNotifier(CUsbNotifManager* aNotifManager);
+
+ /**
+ * 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Set USB indicator On or Off
+ * @param aState Indicator states
+ */
+ void SetIndicatorStateL(const TInt aState);
+
+private:
+ // data
+
+ /**
+ * Switch timer for showing/hiding the usb indicator interleavingly for
+ * animating the indicator.
+ * Own
+ */
+ CUsbTimer* iIconBlinkingTimer;
+
+ /**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,159 @@
+/*
+* 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: 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
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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: 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;
+ };
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,194 @@
+/*
+* 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: Manages notifiers
+ *
+*/
+
+
+#ifndef C_USBNOTIFMANAGER_H
+#define C_USBNOTIFMANAGER_H
+
+#include <e32base.h>
+
+// forward declaration
+class CUsbNotifier;
+class CUsbIndicatorNotifier;
+
+// 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
+ */
+ static CUsbNotifManager* NewL();
+
+ /**
+ * 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 = NULL);
+
+ /**
+ * Changes USB indicator to blink or not
+ * @param aBlinking ETrue if want to make it blinking, EFalse otherwise
+ */
+ void BlinkIndicatorL(TBool aBlinking);
+
+ /**
+ * Shows or hides usb indicator
+ * @param aVisible ETRue is show, EFalse id hide
+ */
+ void ShowIndicatorL(TBool aVisible);
+
+ /**
+ * 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
+ */
+ CUsbNotifManager();
+
+ /**
+ * Second phase construction
+ */
+ void ConstructL();
+
+private:
+ // data
+
+ /**
+ * RNotifier API
+ */
+ RNotifier iNotifier;
+
+ /**
+ * List of notifiers waiting for user action
+ */
+ RPointerArray<CWaitNotifierInfo> iWaitNotifiers;
+
+ /**
+ * Own
+ * Notifier for showing or blinking Usb indicator
+ */
+ CUsbIndicatorNotifier* iIndicatorNotifier;
+ };
+
+#endif // C_USBNOTIFMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbotgstateobserver.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,165 @@
+/*
+* 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: 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
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,467 @@
+/*
+* 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: 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;
+
+/**
+ * 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
+ */
+ CUsbStateHostHandle* HostHandle() const;
+
+ /**
+ * Handles problems in host functioning
+ * @param aWhatKindOf problem Id to be handled
+ */
+ void HandleHostProblemL(TInt aWhatKindOf);
+
+ /**
+ * 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;
+ };
+
+#endif // C_USBOTGWATCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbpersonalityswitch.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* 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: Personality switch function.
+ *
+*/
+
+#ifndef C_USBPERSONALITYSWITCH_H
+#define C_USBPERSONALITYSWITCH_H
+
+#include <e32base.h>
+#include <d32usbdi.h>
+
+const TInt KGetAllPersonalitiesReq = 0x82;
+const TInt KSetPersonalityReq = 0x89;
+
+const TInt KNumOfPersShift = 3;
+const TInt KCurrPersShift = 2;
+const TInt KFirstPersonalityIdShift = 4;
+const TInt KLenghtOfPersonalityData = 2;
+
+class MUsbPersonalitySwitchObserver
+ {
+public:
+ enum TState
+ {
+ EIdle = 0,
+ ERequestingAllPersonalities,
+ ERequestingSetPersonality,
+ EGetAllPersonalitiesCompleted,
+ ESetPersonalityCompleted,
+ ERequestCancelled,
+ ERequestFailed
+ };
+public:
+ virtual void UsbPersonalitySwitchStateChangedL(TState aState, TInt aData) = 0;
+ };
+
+/* *
+ * Reads personalities, if possible, switches peripheral to mass storage.
+ * It is assumed that USB is started already
+ */
+NONSHARABLE_CLASS(CUsbPersonalitySwitch) : public CActive
+ {
+ enum TState
+ {
+ EIdle = 0,
+ EGetAllPersonalities,
+ ESetPersonality /*,
+ EGetAllPersResult,
+ EGetSetPersResult*/
+ };
+
+public:
+
+ /**
+ * Two-phased constructor
+ *
+ * @param aObserver will get call back
+ * @param aTimerId timer id
+ */
+ static CUsbPersonalitySwitch * NewL(MUsbPersonalitySwitchObserver* aObserver);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbPersonalitySwitch();
+
+ /**
+ * calls RunL after aMilliseconds
+ * @param aMilliseconds time in millisecs
+ */
+ TInt SwitchPersonalityL(TUint32 aDeviceId, TInt aPersonalityToBeSet);
+
+ void CancelSwitchPersonalityL();
+
+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
+ */
+ CUsbPersonalitySwitch(MUsbPersonalitySwitchObserver* aObserver);
+
+ /**
+ * 2nd phase construction
+ */
+ void ConstructL();
+
+ void Reset();
+
+private:
+ // data
+
+ /**
+ * Observer
+ * not own
+ */
+ MUsbPersonalitySwitchObserver* iObserver;
+
+ RUsbInterface iUsbInterface;
+
+ /**
+ * timer id
+ */
+ TInt iPersonalityToBeSet;
+
+ RUsbInterface::TUsbTransferRequestDetails iTransfer;
+
+ RBuf8 iSendData;
+
+ RBuf8 iRcvData;
+
+ TState iState;
+ };
+
+#endif // C_USBPERSONALITYSWITCH_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbservicecontrol.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#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:
+
+ /**
+ * 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::UsbServiceStarted 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 Start(TInt aPersonalityId);
+
+ /**
+ * Stops service. When service is stopped call back function
+ * MUsbServiceControlObserver::UsbServiceStopped will be called
+ * @return error code
+ */
+ TInt Stop();
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,267 @@
+/*
+* 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: Base class for states in state machine
+ *
+*/
+
+
+#ifndef C_USBSTATE_H
+#define C_USBSTATE_H
+
+#include <e32base.h>
+#include <usbotgdefs.h>
+
+#include "cusbotgwatcher.h"
+
+#ifndef STIF
+#include "cusbidpinobserver.h"
+#include "cusbvbusobserver.h"
+#include "cusbotgstateobserver.h"
+#include "cusbbusactivityobserver.h"
+#include "cusbhosteventnotificationobserver.h"
+#include "cusbmessagenotificationobserver.h"
+#else
+#include "mockcusbidpinobserver.h"
+#include "mockcusbvbusobserver.h"
+#include "mockcusbotgstateobserver.h"
+#include "mockcusbbusactivityobserver.h"
+#include "mockcusbhosteventnotificationobserver.h"
+#include "mockcusbmessagenotificationobserver.h"
+#endif
+
+/**
+ * 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:
+
+ /**
+ * 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);
+
+private:
+
+ /**
+ * 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;
+
+ /**
+ * 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.
+ */
+
+ /**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of the conctet state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTABASE_H
+#define C_USBSTATEHOSTABASE_H
+
+#include "cusbstate.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();
+
+ /**
+ * Handles special situation (error, or something else)
+ * @param aWhat to hande (id)
+ */
+ virtual void HandleL(TInt aWhat);
+
+ //from CUsbState
+ // 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();
+
+ // 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);
+ /**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of the concret state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTAHOST_H
+#define C_USBSTATEHOSTAHOST_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostabase.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * 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.
+ *
+ */
+ void JustAdvancedToThisStateL();
+
+ /**
+ * State machine calls this, state object to perform any initial
+ * activity, just before leaving this state
+ *
+ */
+ void JustBeforeLeavingThisStateL();
+
+ // From OTG state observer
+ /**
+ * Became a Host when A
+ */
+ void AHostL();
+
+ /**
+ * Became a Peripheral when A
+ */
+ void APeripheralL();
+
+ // From Host Event notification observer
+ /**
+ * Device is detached
+ * @param aInfo Device event data
+ */
+ void DeviceDetachedL(TDeviceEventInformation aInfo);
+
+ // From message notification observer
+ /**
+ * Connected to hub in wrong level
+ */
+ void BadHubPositionL();
+
+private:
+ // data
+ };
+
+#endif // C_USBSTATEHOSTAHOST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostaidle.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* 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: Iplementation of the concret state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTAIDLE_H
+#define C_USBSTATEHOSTAIDLE_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostainitiatebase.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * This class implements basic behaviour in Idle state (VBus down, IdPin on)
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostAIdle ) : public CUsbStateHostAInitiateBase
+
+ {
+
+public:
+
+ /**
+ * Two-phased constructor.
+ * @param aWatcher owner
+ */
+ static CUsbStateHostAIdle* NewL(CUsbOtgWatcher* aWatcher);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbStateHostAIdle();
+
+private:
+
+ /**
+ * Default construction
+ * @param aWatcher owner
+ */
+ CUsbStateHostAIdle(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();
+
+ };
+
+#endif // C_USBSTATEHOSTAIDLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of the concret state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTAINITIATE_H
+#define C_USBSTATEHOSTAINITIATE_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostainitiatebase.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * This class implements behaviour when Id pin just detected (initiating host role, loading drivers)
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostAInitiate ) : public CUsbStateHostAInitiateBase
+ {
+ friend class CtUsbOtgWatcher;
+
+public:
+
+ /**
+ * Two-phased constructor.
+ * @param aWatcher owner
+ */
+ static CUsbStateHostAInitiate* NewL(CUsbOtgWatcher* aWatcher);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbStateHostAInitiate();
+
+private:
+
+ /**
+ * 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.
+ *
+ */
+ virtual void JustBeforeLeavingThisStateL();
+
+ };
+
+#endif // C_USBSTATEHOSTINITIATE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostainitiatebase.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* 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: Implements concrete state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTAINITIATEBASE_H
+#define C_USBSTATEHOSTAINITIATEBASE_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostabase.h"
+#include "cusbpersonalityswitch.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * This class implements besic behaviour when Id pin on, and vbus just turned down or just turned on,
+ * specific concrete case/state is implemented in subclass
+ */
+NONSHARABLE_CLASS( CUsbStateHostAInitiateBase ) : public CUsbStateHostABase,
+ MUsbTimerObserver, MUsbPersonalitySwitchObserver
+
+ {
+ friend class CTestUsbOtgWatcher;
+
+public:
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbStateHostAInitiateBase();
+
+ // From MUsbTimerObserver
+ /**
+ * timer expired call back
+ * @param aTimerId timer id
+ */
+ void TimerElapsedL(TUsbTimerId aTimerId);
+
+ void UsbPersonalitySwitchStateChangedL(MUsbPersonalitySwitchObserver::TState aState, TInt aData);
+
+protected:
+
+ /**
+ * Default construction
+ * @param aWatcher owner
+ */
+ CUsbStateHostAInitiateBase(CUsbOtgWatcher* aWatcher);
+
+ /**
+ * 2nd phase construction
+ */
+ void ConstructL();
+
+ //from CUsbState
+
+ /**
+ * 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 JustBeforeLeavingThisStateL();
+
+ // From VBus observer
+ /**
+ * VBus down
+ */
+ virtual void VBusDownL();
+ /**
+ * VBus UP
+ */
+ virtual void VBusUpL();
+
+ /**
+ * AHost
+ */
+ virtual void AHostL();
+
+ /**
+ * APeripheral
+ */
+ virtual void APeripheralL();
+
+ // From Host Event notification observer
+ /**
+ * Device is attached
+ * @param Device event data
+ */
+ virtual void DeviceAttachedL(TDeviceEventInformation);
+ /**
+ * Device is detached
+ * @param Device event data
+ */
+ virtual void DriverLoadSuccessL(TDeviceEventInformation);
+ /**
+ * Drivers loaded partially
+ * @param Device event data
+ */
+ virtual void DriverLoadPartialSuccessL(TDeviceEventInformation);
+ /**
+ * Drivers loading failed
+ * @param Device event data
+ */
+ virtual void DriverLoadFailureL(TDeviceEventInformation);
+
+ // From message notification observer
+ /**
+ * SRP request received
+ */
+ virtual void SrpReceivedL();
+
+protected:
+ // data
+
+ /*
+ * attachment timer
+ * own
+ */
+ CUsbTimer* iAttachmentTimer;
+
+ CUsbPersonalitySwitch* iUsbPersonalitySwitch;
+ };
+
+#endif // C_USBSTATEHOSTAINITIATEBASE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,88 @@
+/*
+* 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: Implements concrete state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTAPERIPHERAL_H
+#define C_USBSTATEHOSTAPERIPHERAL_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstatehostabase.h"
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * 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();
+
+ /**
+ * State machine calls this, state object to perform any initial
+ * activity, once just entered this state
+ *
+ */
+ void JustAdvancedToThisStateL();
+
+ //from CUsbState
+ /**
+ * state id
+ * @return state id
+ */
+ TUsbStateIds Id();
+
+ // From OTG state observer
+ /**
+ * Became a host when A
+ */
+ void AHostL();
+
+private:
+ // data
+
+ };
+
+#endif // C_USBSTATEHOSTAPERIPHERAL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbstatehosthandle.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,229 @@
+/*
+* 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: Implements concrete state
+ *
+*/
+
+
+#ifndef C_USBSTATEHOSTHANDLE_H
+#define C_USBSTATEHOSTHANDLE_H
+
+#include "cusbotgwatcher.h"
+#include "cusbstate.h"
+
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#include "cusbtimer.h"
+#else
+#include "mockcusbnotifmanager.h"
+#include "mockcusbtimer.h"
+#endif
+
+/**
+ * This class implements behaviour when some problem needs vbus drop, and mostly, user action.
+ *
+ */
+NONSHARABLE_CLASS( CUsbStateHostHandle ) : public CUsbState,
+ MWaitNotifierObserver,
+ MUsbTimerObserver
+// 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 CUsbStateHostHandle* NewL(CUsbOtgWatcher* aWatcher);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbStateHostHandle();
+
+ /**
+ * Sets id of the issue to be handled
+ * @param aWhat issue id
+ */
+ void SetWhat(TInt aWhat);
+
+ // from MWaitNotifierObserver
+ /**
+ * Callback when notifier is completed
+ * @param aFeedback how notifier completed
+ */
+ void WaitNotifierCompletedL(TInt aFeedback);
+
+ // From MUsbTimerObserver
+ /**
+ * Call back when timer expired
+ * @param aTimerId timer id
+ */
+ void TimerElapsedL(TUsbTimerId aTimerId);
+
+private:
+
+ // From VBus observer
+ /**
+ * VBus down
+ */
+ void VBusDownL();
+
+ // 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();
+
+ // From bus activity observer
+ /**
+ * Bus is in idle
+ */
+ void BusIdleL();
+ /**
+ * Bus active
+ */
+ void BusActiveL();
+
+ // 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
+ */
+ 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
+ */
+ 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();
+
+ /**
+ * Default constructor
+ * @param aWatcher owner
+ */
+ CUsbStateHostHandle(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 leaving this state,
+ *
+ */
+ void JustBeforeLeavingThisStateL();
+
+ /**
+ * handles issue
+ */
+ void DoHandleL();
+
+private:
+ // data
+
+ /**
+ * identifies situation to be handled
+ */
+ TInt iWhat;
+
+ /**
+ * too much power timer
+ * own
+ */
+ CUsbTimer* iTooMuchPowerTimer;
+ };
+
+#endif // C_USBSTATEHOSTHANDLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/cusbtimer.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,135 @@
+/*
+* 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: timer
+ *
+*/
+
+#ifndef C_USBTIMER_H
+#define C_USBTIMER_H
+
+#include <e32base.h>
+
+class CUsbTimer;
+
+/**
+ * timer ids for usbotgwatcher
+ */
+enum TUsbTimerId
+ {
+ EDeviceAttachmentTimer,
+ EInactiveTimer,
+ EIconBlinkingTimer,
+ ETooMuchPowerRequiredTimer
+ };
+
+/**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* 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: 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
+ * Own
+ */
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,67 @@
+/*
+* 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: 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* 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: 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* 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 _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__
+
+#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( "[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 // USBDEVCON_DEBUG_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/definitions.h Thu Dec 17 09:14:30 2009 +0200
@@ -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: 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 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
+ {
+ EUsbStateHostAInitiate,
+ EUsbStateHostAHost,
+ EUsbStateHostAPeripheral,
+ EUsbStateHostAIdle,
+
+ EUsbStateHostHandle
+ };
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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: 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
+
+ };
+
+#endif // ERRRORS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/inc/panic.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,121 @@
+/*
+* 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: Central place for debug-type macros & functions
+ *
+*/
+
+#ifndef USBWATCHER_PANIC_H
+#define USBWATCHER_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
+
+ };
+
+/**
+ * Shows application name and panic code
+ * @param aPanicId panic id
+ */
+void Panic(TUsbWatcherPanic aPanicId);
+
+#endif // USBWATCHER_PANIC_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/rom/errrd Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1 @@
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/rom/usbotgwatcher.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,242 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbotgdefs.h>
+
+#include "cusbbusactivityobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::CUsbBusActivityObserver() :
+ CActive(EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::ConstructL" ) );
+
+ User::LeaveIfError(iBusActivity.Attach(KUidUsbManCategory,
+ KUsbOtgConnectionIdleProperty));
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver* CUsbBusActivityObserver::NewL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::NewL" ) );
+
+ CUsbBusActivityObserver* self = new (ELeave) CUsbBusActivityObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::~CUsbBusActivityObserver()
+
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::~CUsbBusActivityObserver" ) );
+
+ Cancel();
+
+ iBusActivity.Close();
+
+ iObservers.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::TBusActivity CUsbBusActivityObserver::BusActivity()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::BusActivity" ) );
+
+ TInt val(0);
+
+ TInt err = iBusActivity.Get(val);
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::BusActivity CanNotGetBusActivityProperty" ) );
+ Panic(ECanNotGetBusActivityProperty);
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::State = %d" ), val ));
+
+ return (0 == val ? EBusActive : EBusIdle);
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::SubscribeL(MUsbBusActivityObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iBusActivity.Subscribe(iStatus);
+ SetActive();
+
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::UnsubscribeL(MUsbBusActivityObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL" ) );
+
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ ++i;
+
+ if (aObserver == iObservers[i]) // found
+ {
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL CanNotFindBusActivityObserver " ) );
+ Panic(ECanNotFindBusActivityObserver);
+ }
+
+ if (0 == iObservers.Count()) // no items
+ {
+ // cancel pending request
+ Cancel();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL 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:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusIdle" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BusIdleL();
+ }
+ break;
+ }
+
+ case EBusActive:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusActive" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BusActiveL();
+ }
+ break;
+ }
+
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusActive WrongBusState" ) );
+ Panic(EWrongBusState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::DoCancel()
+ {
+ iBusActivity.Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbBusActivityObserver::RunError(TInt aError)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunError aError = %d" ), aError));
+
+ // try to continue
+ return KErrNone;
+
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,270 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <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()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::ConstructL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver* CUsbHostEventNotificationObserver::NewL(
+ RUsb* aUsb)
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::NewL" ) );
+
+ CUsbHostEventNotificationObserver* self =
+ new (ELeave) CUsbHostEventNotificationObserver(aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver" ) );
+
+ Cancel();
+
+ iObservers.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::SubscribeL(
+ MUsbHostEventNotificationObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iUsb->HostEventNotification(iStatus, iEventInfo);
+ SetActive();
+
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::UnsubscribeL(
+ MUsbHostEventNotificationObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL" ) );
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ ++i;
+
+ if (aObserver == iObservers[i]) // found
+ {
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL CanNotFindIdPinObserver" ) );
+ Panic(ECanNotFindIdPinObserver);
+ }
+
+ if (0 == iObservers.Count()) // no items
+ {
+ // cancel pending request
+ Cancel();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL 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
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iDeviceId = %d" ), dei.iDeviceId));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iEventType = %d" ), dei.iEventType));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iError = %d" ), dei.iError));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iDriverLoadStatus = %d" ), dei.iDriverLoadStatus));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iVid = %d" ), dei.iVid));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iPid = %d" ), dei.iPid));
+
+ // then process property change
+ switch (dei.iEventType)
+ {
+ case EDeviceAttachment:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DeviceAttachment" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->DeviceAttachedL(dei);
+ }
+ break;
+ }
+
+ case EDeviceDetachment:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DeviceDetachment" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->DeviceDetachedL(dei);
+ }
+ break;
+ }
+
+ case EDriverLoad:
+ {
+ switch (dei.iDriverLoadStatus)
+ {
+ case EDriverLoadSuccess:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadSuccess" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->DriverLoadSuccessL(dei);
+ }
+
+ break;
+ }
+ case EDriverLoadPartialSuccess:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadPartialSuccess" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->DriverLoadPartialSuccessL(dei);
+ }
+ break;
+
+ }
+ case EDriverLoadFailure:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadFailure" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->DriverLoadFailureL(dei);
+ }
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadFailure WrongDriverLoadStatus" ) );
+ Panic(EWrongDriverLoadStatus);
+ }
+ }
+ break;
+
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL WrongHostEventNotification" ) );
+ Panic(EWrongHostEventNotification);
+ }
+
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::DoCancel()
+ {
+ iUsb->HostEventNotificationCancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbHostEventNotificationObserver::RunError(TInt aError)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunError 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbotgdefs.h>
+
+#include "cusbidpinobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::CUsbIdPinObserver() :
+ CActive(EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::ConstructL" ) );
+
+ User::LeaveIfError(iIdPin.Attach(KUidUsbManCategory,
+ KUsbOtgIdPinPresentProperty));
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver* CUsbIdPinObserver::NewL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::NewL" ) );
+
+ CUsbIdPinObserver* self = new (ELeave) CUsbIdPinObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::~CUsbIdPinObserver()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::~CUsbIdPinObserver" ) );
+
+ Cancel();
+
+ iIdPin.Close();
+
+ iObservers.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::TState CUsbIdPinObserver::IdPin()
+/* this getter is not const, because for some reason RProperty::Get is not const */
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin" ) );
+
+ TInt val(0);
+
+ TInt err = iIdPin.Get(val);
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin CanNotGetIdPinProperty" ) );
+ Panic(ECanNotGetIdPinProperty);
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin = %d" ), val ));
+
+ // not found in docs clear definition of this property. Verification is needed
+ return (0 == val ? EIdPinOff : EIdPinOn);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iIdPin.Subscribe(iStatus);
+ SetActive();
+
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL" ) );
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ ++i;
+
+ if (aObserver == iObservers[i]) // found
+ {
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL CanNotGetIdPinObserver" ) );
+ Panic(ECanNotFindIdPinObserver);
+ }
+
+ if (0 == iObservers.Count()) // no items
+ {
+ // cancel pending request
+ Cancel();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL 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:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL IdPin ON"));
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->IdPinOnL();
+ }
+ break;
+ }
+ ;
+
+ case EIdPinOff:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL IdPin OFF"));
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->IdPinOffL();
+ }
+ break;
+ }
+ ;
+
+ default:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL WrongIdPinState"));
+ Panic(EWrongIdPinState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::DoCancel()
+ {
+ iIdPin.Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbIdPinObserver::RunError(TInt aError)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunError aError = %d" ), aError));
+
+ // try to continue
+ return KErrNone;
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* 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 "cusbnotifier.h"
+#include "definitions.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier* CUsbIndicatorNotifier::NewL(CUsbNotifManager* aNotifManager)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::NewL" ));
+
+ CUsbIndicatorNotifier* self = new (ELeave) CUsbIndicatorNotifier(aNotifManager);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier::~CUsbIndicatorNotifier()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::~CUsbIndicatorNotifier" ) );
+
+ Close();
+ delete iIconBlinkingTimer;
+ }
+
+// ---------------------------------------------------------------------------
+// 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::ShowIndicatorL(TBool aVisible)
+ {
+ FTRACE( FPrint (_L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ShowIndicator, aVisible=%d" ), aVisible));
+
+ iIconBlinkingTimer->Cancel();
+
+ SetIndicatorStateL(aVisible ? EAknIndicatorStateOn : EAknIndicatorStateOff);
+ }
+
+// ---------------------------------------------------------------------------
+// From CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::ShowL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ShowL" ));
+
+ // Will be canceled if active in After()
+ iIconBlinkingTimer->After(0);
+ }
+
+// ---------------------------------------------------------------------------
+// From CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::Close()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::Close" ) );
+
+ iIconBlinkingTimer->Cancel();
+ TRAP_IGNORE( ShowIndicatorL(EFalse) );
+ }
+
+// ---------------------------------------------------------------------------
+// From MUsbTimerObserver
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::TimerElapsedL(TUsbTimerId aTimerId)
+ {
+ switch (aTimerId)
+ {
+ case EIconBlinkingTimer:
+ {
+ SetIndicatorStateL(iIndicatorState ? EAknIndicatorStateOn : EAknIndicatorStateOff);
+
+ iIndicatorState = (iIndicatorState == EAknIndicatorStateOn
+ ? EAknIndicatorStateOff : EAknIndicatorStateOn);
+
+ // Will be canceled if active in After()
+ iIconBlinkingTimer->After(KUsbIndicatorBlinkingInterval);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::TimerElapsedL - Unknown timer" ) );
+
+ Panic(EWrongTimerId);
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbIndicatorNotifier::CUsbIndicatorNotifier(CUsbNotifManager* aNotifManager) :
+ CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::CUsbIndicatorNotifier" ) );
+
+ //To be changed to EAknIndicatorStateAnimate and remove iIconBlinkingTimer
+ //when AVKON implements animation form of usb indicator.
+ iIndicatorState = EAknIndicatorStateOn;
+ }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ConstructL" ) );
+
+ iIconBlinkingTimer = CUsbTimer::NewL(this, EIconBlinkingTimer);
+ }
+
+// ---------------------------------------------------------------------------
+// Set USB indicator On or Off
+// ---------------------------------------------------------------------------
+//
+void CUsbIndicatorNotifier::SetIndicatorStateL(const TInt aState)
+ {
+ FTRACE( FPrint (_L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::SetIndicatorStateL - aState=%d" ), aState));
+
+ CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC(TUid::Uid(EAknIndicatorUSBConnection));
+ indicator->SetIndicatorStateL( aState );
+ CleanupStack::PopAndDestroy( indicator ); //indicator
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <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()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::ConstructL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver* CUsbMessageNotificationObserver::NewL(
+ RUsb* aUsb)
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::NewL" ) );
+
+ CUsbMessageNotificationObserver* self =
+ new (ELeave) CUsbMessageNotificationObserver(aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver::~CUsbMessageNotificationObserver()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::~CUsbMessageNotificationObserver" ) );
+
+ Cancel();
+
+ iObservers.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::SubscribeL(
+ MUsbMessageNotificationObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iUsb->MessageNotification(iStatus, iMessage);
+ SetActive();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::UnsubscribeL(
+ MUsbMessageNotificationObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL" ) );
+
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ ++i;
+
+ if (aObserver == iObservers[i]) // found
+ {
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL CanNotFindMessageNotificationObserver" ) );
+ Panic(ECanNotFindMessageNotificationObserver);
+ }
+
+ if (0 == iObservers.Count()) // no items
+ {
+ // cancel pending request
+ Cancel();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::RunL()
+ {
+ // 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();
+
+ // Log the event
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL iMessage = %d" ), message));
+
+ // then process property change
+ switch (message)
+ {
+ case KErrUsbBadHubPosition:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL HubBadPosition" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BadHubPositionL();
+ }
+ break;
+ }
+ case KErrUsbOtgVbusError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL VBusError" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->VBusErrorL();
+ }
+ break;
+ }
+ case KUsbMessageSrpReceived:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL SRP received" ) );
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->SrpReceivedL();
+ }
+ break;
+ }
+ case KUsbMessageRequestSession:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL 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)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunError 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,172 @@
+/*
+* 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)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CUsbNoteNotifier" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ConstructL" ) );
+
+ iNotifierActive = new(ELeave)CUsbNoteNotifier::CNotifierActive(iNotifier, this);
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbNoteNotifier::~CUsbNoteNotifier()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::~CUsbNoteNotifier" ) );
+
+ delete iNotifierActive;
+ }
+
+// ---------------------------------------------------------------------------
+// From base class CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::ShowL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ShowL aCat = 0x%X aNotifId = 0x%X" ), iCat, iNotifId));
+
+ iNotifierActive->StartL();
+ }
+
+// ---------------------------------------------------------------------------
+// From base class CUsbNotifier
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::Close()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::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()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::ShowL aCat = 0x%X aNotifId = 0x%X" ),
+ iUsbNoteNotifier->iCat, iUsbNoteNotifier->iNotifId));
+
+ if (IsActive())
+ {
+ Panic(ENotifierIsActiveAlready);
+ return;
+ }
+
+ TPckgBuf<TInt> pckg;
+ pckg() = iUsbNoteNotifier->iNotifId;
+
+ iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier->iCat, pckg, iRes);
+ SetActive();
+ }
+
+// ---------------------------------------------------------------------------
+// From base class CActive
+// ---------------------------------------------------------------------------
+//
+void CUsbNoteNotifier::CNotifierActive::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCCUsbNoteNotifier::CNotifierActive::RunL iStatus = %d" ), iStatus.Int()));
+
+ // if error occured, deal with it in RunError
+ User::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()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::DoCancel" ) );
+
+ iNotifier.CancelNotifier(iUsbNoteNotifier->iCat);
+ }
+
+// ---------------------------------------------------------------------------
+// From base class CActive
+// ---------------------------------------------------------------------------
+//
+TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError)
+ {
+ FTRACE( FPrint(_L("[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::RunError 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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: Base classes for Usb notifier wrapper
+ *
+*/
+
+
+#include "cusbnotifmanager.h"
+#include "cusbnotifier.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Desctructor
+// ---------------------------------------------------------------------------
+//
+CUsbNotifier::~CUsbNotifier()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::~CUsbNotifier" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// 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)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::CUsbNotifier" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// Set by child-classe if the concrete notifier needs feedback from end-user
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifier::SetFeedbackNeeded()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::SetFeedbackNeeded" ) );
+ iIsFeedbackNeeded = ETrue;
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbnotifmanager.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,269 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+#include <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()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::ConstructL" ) );
+ // owenrship for iWaitNotifier transferred in default constructor.
+ // this object is responsible for deletion of the iWaitNotifier then
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CWaitNotifierInfo* CWaitNotifierInfo::NewL(CUsbNotifier* aWaitNotifier,
+ MWaitNotifierObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::NewL" ) );
+ CWaitNotifierInfo* self = new (ELeave) CWaitNotifierInfo(aWaitNotifier,
+ aObserver);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CWaitNotifierInfo::~CWaitNotifierInfo()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::~CWaitNotifierInfo" ) );
+ delete iWaitNotifier;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbNotifier* CWaitNotifierInfo::WaitNotifier() const
+ {
+ return iWaitNotifier;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+MWaitNotifierObserver* CWaitNotifierInfo::Observer() const
+ {
+ return iObserver;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::CUsbNotifManager()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ConstructL" ) );
+
+ User::LeaveIfError(iNotifier.Connect());
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager* CUsbNotifManager::NewL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::NewL" ) );
+
+ CUsbNotifManager* self = new (ELeave) CUsbNotifManager();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::~CUsbNotifManager()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::~CUsbNotifManager" ) );
+
+ CloseAllNotifiers();
+
+ iNotifier.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId,
+ MWaitNotifierObserver* aObserver)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifier 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* waitNotifier = iWaitNotifiers[i];
+ if (!(waitNotifier->WaitNotifier()->IsFeedbackNeeded()))
+ {
+ delete waitNotifier;
+ 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_ALWAYS(aObserver != NULL, Panic(EWrongNotifierCategory));
+ notifier = CUsbWaitNotifier::NewL(iNotifier, this, aNotifId);
+ }
+ else if (aCat == KUsbUiNotifOtgWarning)
+ {
+ notifier = CUsbWarningNotifier::NewL(iNotifier, this, aNotifId);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Unexpected aCat" ) );
+ Panic(EWrongNotifierCategory);
+ }
+
+ CleanupStack::PushL(notifier);
+
+ iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, aObserver));
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Start to show note" ) );
+ notifier->ShowL();
+
+ CleanupStack::Pop(notifier);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::BlinkIndicatorL(TBool aBlinking)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::BlinkIndicatorL, aBlinking=%d" ), aBlinking));
+
+ if (!iIndicatorNotifier)
+ iIndicatorNotifier = CUsbIndicatorNotifier::NewL(this);
+
+ if (aBlinking)
+ iIndicatorNotifier->ShowL();
+ else
+ iIndicatorNotifier->Close();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ShowIndicatorL(TBool aVisible)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowIndicatorL, aVisible=%d" ), aVisible ));
+
+ if (!iIndicatorNotifier)
+ iIndicatorNotifier = CUsbIndicatorNotifier::NewL(this);
+
+ iIndicatorNotifier->ShowIndicatorL(aVisible);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier* aWaitNotifier,
+ TInt aResult, TInt aFeedback)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::NotifierShowCompleted 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()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::CloseAllNotifiers" ) );
+
+ iWaitNotifiers.ResetAndDestroy();
+ delete iIndicatorNotifier;
+ iIndicatorNotifier = NULL;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,286 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include "cusbotgstateobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::CUsbOtgStateObserver() :
+ CActive(EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::ConstructL" ) );
+
+ User::LeaveIfError(iOtgState.Attach(KUidUsbManCategory,
+ KUsbOtgStateProperty));
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver* CUsbOtgStateObserver::NewL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::NewL" ) );
+
+ CUsbOtgStateObserver* self = new (ELeave) CUsbOtgStateObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::~CUsbOtgStateObserver()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::~CUsbOtgStateObserver" ) );
+
+ Cancel();
+
+ iOtgState.Close();
+
+ iObservers.ResetAndDestroy();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbOtgState CUsbOtgStateObserver::OtgState()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState" ) );
+
+ TInt val(0);
+
+ TInt err = iOtgState.Get(val);
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::StOtgState CanNotGetOtgStateProperty" ) );
+ Panic(ECanNotGetOtgStateProperty);
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState = %d" ), val ));
+
+ return (TUsbOtgState) val;
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iOtgState.Subscribe(iStatus);
+ SetActive();
+
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::UnsubscribeL" ) );
+
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ ++i;
+
+ if (aObserver == iObservers[i]) // found
+ {
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::UnsubscribeL CanNotFindOtgStateObserver" ) );
+ Panic(ECanNotFindOtgStateObserver);
+ }
+
+ if (0 == iObservers.Count()) // no items
+ {
+ // cancel pending request
+ Cancel();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunL 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:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == RESET" ) );
+ break;
+ }
+ case EUsbOtgStateAIdle:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AIdle" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->AIdleL();
+ }
+ break;
+ }
+ case EUsbOtgStateAHost:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AHost" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->AHostL();
+ }
+ break;
+ }
+ case EUsbOtgStateAPeripheral:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == APeripheral" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->APeripheralL();
+ }
+ break;
+ }
+ case EUsbOtgStateAVbusError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AVBusError" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->AVBusErrorL();
+ }
+ break;
+ }
+ case EUsbOtgStateBIdle:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BIdle" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BIdleL();
+ }
+ break;
+ }
+ case EUsbOtgStateBPeripheral:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BPeripheral" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BPeripheralL();
+ }
+ break;
+ }
+ case EUsbOtgStateBHost:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BHost" ) );
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->BHostL();
+ }
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL WrongOtgState" ) );
+ Panic(EWrongOtgState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::DoCancel()
+ {
+ iOtgState.Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbOtgStateObserver::RunError(TInt aError)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunError aError = %d" ), aError));
+
+ // try to continue
+ return KErrNone;
+
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbotgwatcher.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1053 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbpersonalityids.h>
+#include <usbuinotif.h>
+#include <UsbWatcherInternalPSKeys.h>
+
+#include "cusbotgwatcher.h"
+#include "cusbstate.h"
+
+#include "cusbstatehostainitiate.h"
+#include "cusbstatehostahost.h"
+#include "cusbstatehostaperipheral.h"
+#include "cusbstatehostaidle.h"
+#include "cusbstatehosthandle.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)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CUsbOtgWatcher" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ConstructL" ) );
+
+#ifdef _DEBUG
+ SelfTestL();
+#endif
+
+#ifndef STIF
+ User::LeaveIfError(RProperty::Define( KPSUidUsbWatcher,
+ KUsbWatcherIsPeripheralConnected, RProperty::EInt, KAlwaysPassPolicy,
+ KLocalServicesPolicy ) );
+
+ User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
+ KUsbWatcherIsPeripheralConnected,
+ KUsbWatcherPeripheralIsNotConnected ) );
+#endif
+
+ iNotifManager = CUsbNotifManager::NewL();
+ iUsbServiceControl = CUsbServiceControl::NewL(this, iUsb);
+
+ User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAIdle::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostHandle::NewL(this)));
+
+ iIdPinObserver = CUsbIdPinObserver::NewL();
+ iVBusObserver = CUsbVBusObserver::NewL();
+ iOtgStateObserver = CUsbOtgStateObserver::NewL();
+ iBusActivityObserver = CUsbBusActivityObserver::NewL();
+ iHostEventNotificationObserver = CUsbHostEventNotificationObserver::NewL(
+ &iUsb);
+ iMessageNotificationObserver = CUsbMessageNotificationObserver::NewL(
+ &iUsb);
+
+ iIdPinObserver->SubscribeL(this);
+
+ if (CUsbIdPinObserver::EIdPinOn == iIdPinObserver->IdPin())
+ {
+ StartSessionL();
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CUsbOtgWatcher::IsDeviceA()
+ {
+ __ASSERT_DEBUG(iIdPinObserver != NULL, Panic(EIdPinObserverNULLPointer));
+ return (iIdPinObserver->IdPin() == CUsbIdPinObserver::EIdPinOn
+ ? ETrue
+ : EFalse);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUsbOtgWatcher* CUsbOtgWatcher::NewL(RUsb& aUsbMan)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::NewL" ) );
+
+ CUsbOtgWatcher* self = new (ELeave) CUsbOtgWatcher(aUsbMan);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbOtgWatcher::~CUsbOtgWatcher()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::~CUsbOtgWatcher" ) );
+
+#ifndef STIF
+ RProperty::Delete( KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected );
+#endif
+
+ delete iIdPinObserver;
+ delete iVBusObserver;
+ delete iOtgStateObserver;
+ delete iBusActivityObserver;
+ delete iHostEventNotificationObserver;
+ delete iMessageNotificationObserver;
+
+ // Destroy states
+ iStates.ResetAndDestroy();
+ iStates.Close();
+
+ delete iNotifManager;
+ delete iUsbServiceControl;
+
+ iUsb.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPersonalityL(TRequestStatus& /*aStatus*/,
+ TInt aPersonality)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPersonalityL 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()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CancelSetPersonalityL" ) );
+
+ iState->CancelSetPersonalityL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPersonalityL(TRequestStatus& /*aStatus*/)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPersonalityL" ) );
+
+ // maybe more complex processing needed here
+ iState->SetPreviousPersonalityL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPersonalityL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPersonalityL" ) );
+
+ iState->SetPreviousPersonalityL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::CancelSetPreviousPersonalityL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CancelSetPreviousPersonalityL" ) );
+
+ iState->CancelSetPreviousPersonalityL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SetPreviousPreviousPersonalityOnDisconnectL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPreviousPersonalityOnDisconnectL" ) );
+
+ }
+
+// From IdPin observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::StartSessionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::StartSessionL" ) );
+
+ if (!CanStartSessionL())
+ {
+ HandleHostProblemL(EUsbWatcherErrorInConnection);
+ return;
+ }
+
+ TInt err = iUsbServiceControl->Start(iPersonalityId);
+ if (KErrNone != err)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::StartSessionL Can not start usb services. reason = %d" ), err));
+ HandleHostProblemL(EUsbWatcherCanNotStartUsbServices);
+ return;
+ }
+
+ // call back from iUsbServiceControl->Start(iPersonalityId) call is UsbServiceControlReqCompletedL(TInt aError)
+ // so, continue there if everything is OK
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::HandleHostProblemL(TInt aWhatKindOf)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HandleProblemL" ) );
+ HostHandle()->SetWhat(aWhatKindOf);
+ ChangeHostStateL(EUsbStateHostHandle);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinOnL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOnL" ) );
+ StartSessionL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinOffL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL" ) );
+
+ // for example, USB failed to start
+ if(NULL == iHostState) return;
+
+ iVBusObserver->UnsubscribeL(this);
+ iOtgStateObserver->UnsubscribeL(this);
+ iBusActivityObserver->UnsubscribeL(this);
+ iHostEventNotificationObserver->UnsubscribeL(this);
+ iMessageNotificationObserver->UnsubscribeL(this);
+
+ iHostState->JustBeforeLeavingThisStateL();
+
+ iHostState = NULL;
+
+ iNotifManager->CloseAllNotifiers();
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL Before DisableFunctionDriverLoad " ) );
+ Usb().DisableFunctionDriverLoading();
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL Before TryStop" ) );
+
+ TInt err = iUsbServiceControl->Stop();
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOnL ErrorStoppingUsbServices" ) );
+ Panic(ECanNotStopUsbServices);
+ }
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL iUsbServiceControl->Stop() OK" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::IdPinErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ HandleHostProblemL(EUsbWatcherIdPinError);
+
+ }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusDownL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusDownL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->VBusDownL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusUpL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusUpL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->VBusUpL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusObserverErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusObserverErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ HandleHostProblemL(EUsbWatcherVBusObserverError);
+ }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AIdleL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->AIdleL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AHostL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->AHostL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::APeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::APeripheralL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->APeripheralL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::AVBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AVBusErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->AVBusErrorL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BIdleL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BIdleL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BPeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BPeripheralL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BPeripheralL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BHostL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BHostL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::OtgStateErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::OtgStateErrorL" ) );
+__ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+HandleHostProblemL(EUsbWatcherOtgStateError);
+ }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusIdleL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BusIdleL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusActiveL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusActiveL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BusActiveL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BusActivityErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusActivityErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ // no action, continue
+ }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DeviceAttachedL(TDeviceEventInformation aTdi)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DeviceAttachedL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->DeviceAttachedL(aTdi);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DeviceDetachedL(TDeviceEventInformation aTdi)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DeviceDetachedL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->DeviceDetachedL(aTdi);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadSuccessL(TDeviceEventInformation aTdi)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadSuccessL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->DriverLoadSuccessL(aTdi);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadPartialSuccessL(TDeviceEventInformation aTdi)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadPartialSuccessL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->DriverLoadPartialSuccessL(aTdi);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::DriverLoadFailureL(TDeviceEventInformation aTdi)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadFailureL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->DriverLoadFailureL(aTdi);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::HostEventNotificationErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HostEventNotificationErrorL" ) );
+__ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+HandleHostProblemL(EUsbWatcherHostEventNotificationError);
+ }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::MessageNotificationReceivedL(TInt aMessage)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::MessageNotificationReceivedL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->MessageNotificationReceivedL(aMessage);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::BadHubPositionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BadHubPositionL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->BadHubPositionL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::VBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->VBusErrorL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SrpReceivedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SrpReceivedL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->SrpReceivedL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::SessionRequestedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SessionRequestedL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ iHostState->SessionRequestedL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::MessageNotificationErrorL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::MessageNotificationErrorL" ) );
+ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState));
+ HandleHostProblemL(EUsbWatcherMessageNotificationError);
+ }
+
+// ---------------------------------------------------------------------------
+// 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() const
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HostHandle" ) );
+ __ASSERT_DEBUG(iStates[EUsbStateHostHandle] != NULL, Panic(EBadState));
+ return (CUsbStateHostHandle*) iStates[EUsbStateHostHandle];
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ChangeStateL(TUsbStateIds aNewStateId)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ChangeStateL aNewState = %d" ), aNewStateId));
+
+ if (NULL != iState)
+ {
+ if (aNewStateId == iState->Id())
+ {
+ return; // we already in the target state
+ }
+ else
+ {
+
+ 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_DEBUG(iState != NULL, Panic(EBadState));
+
+ iState->JustAdvancedToThisStateL(); // do any initial activity, once advanced to the state
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::ChangeHostStateL(TUsbStateIds aNewStateId)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ChangeHostStateL aNewState = %d" ), aNewStateId));
+
+ if (NULL != iHostState)
+ {
+ if (aNewStateId == iHostState->Id())
+ {
+ return; // we already in the target state
+ }
+ else
+ {
+
+ 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_DEBUG(iHostState != NULL, Panic(EBadState));
+
+ iHostState->JustAdvancedToThisStateL(); // checks if there are conditions for advancing to another state(s)
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool CUsbOtgWatcher::CanStartSessionL()
+ {
+ // define policy here
+ return ETrue;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::PrintStateToLog()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog IdPin = %d" ), iIdPinObserver->IdPin()));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog VBus = %d" ), iVBusObserver->VBus()));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog OtgState = %d" ), iOtgStateObserver->OtgState()));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog BusActivity = %d" ), iBusActivityObserver->BusActivity()));
+
+ TInt isPeripheralConnected(KUsbWatcherPeripheralIsNotConnected);
+
+ RProperty::Get( KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected,
+ isPeripheralConnected );
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog IsPeripheralConnected = %d" ), isPeripheralConnected));
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager* CUsbOtgWatcher::NotifManager()
+ {
+ return iNotifManager;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgWatcher::UsbServiceControlReqCompletedL(TInt aError)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompleted" ) );
+
+ if (KErrNone != aError)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompleted Error returned by UsbServiceControl = %d" ), aError));
+ HandleHostProblemL(EUsbWatcherCanNotStartUsbServices);
+ return;
+ }
+
+ TUsbServiceState serviceState;
+ TInt err = iUsb.GetServiceState(serviceState);
+
+ if (KErrNone != err)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompleted Error when requesting GetServiceState = %d" ), err));
+ HandleHostProblemL(EUsbWatcherCanNotStartUsbServices);
+ return;
+ }
+
+ switch (serviceState)
+ {
+ case EUsbServiceIdle: // just stopped usb service
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceIdle" ) );
+ // do nothing
+ break;
+ }
+
+ case EUsbServiceStarted: // just started usb service
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStarted" ) );
+
+ iHostState = iStates[EUsbStateHostAInitiate];
+
+ iHostState->JustAdvancedToThisStateL(); // do any initial activity, once advanced to the state
+
+ iVBusObserver->SubscribeL(this);
+ iOtgStateObserver->SubscribeL(this);
+ iBusActivityObserver->SubscribeL(this);
+ iHostEventNotificationObserver->SubscribeL(this);
+ iMessageNotificationObserver->SubscribeL(this);
+
+ break;
+ }
+ case EUsbServiceStarting:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStarting" ) );
+ // should not receive that, due to call back is called when service stopped or started
+ // therefore scream
+ }
+ case EUsbServiceStopping:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStopping" ) );
+ // should not receive that, due to call back is called when service stopped or started
+ // therefore scream
+ }
+ case EUsbServiceFatalError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceFatalError" ) );
+ Panic(EUnexpectedUsbServiceState);
+ break;
+ }
+
+ default:
+ {
+ Panic(EUnknownUsbServiceState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+
+TInt CUsbOtgWatcher::SelfTestL()
+ {
+#ifdef _DEBUG
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Creating observers." ) );
+
+ // create all the observers
+ iIdPinObserver = CUsbIdPinObserver::NewL();
+ iVBusObserver = CUsbVBusObserver::NewL();
+ iOtgStateObserver = CUsbOtgStateObserver::NewL();
+ iBusActivityObserver =
+ CUsbBusActivityObserver::NewL();
+ iHostEventNotificationObserver =
+ CUsbHostEventNotificationObserver::NewL(&iUsb);
+ iMessageNotificationObserver =
+ CUsbMessageNotificationObserver::NewL(&iUsb);
+
+ /* FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL idPinObserver->Subscribe" ) );
+
+ iIdPinObserver->SubscribeL(this);
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL idPinObserver->Unsubscribe" ) );
+
+ iIdPinObserver->UnsubscribeL(this); */
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Observers getters." ) );
+
+ if (iIdPinObserver != IdPinObserver())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ if (iOtgStateObserver != OtgStateObserver())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ if (iBusActivityObserver != BusActivityObserver())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ if (iHostEventNotificationObserver != HostEventNotificationObserver())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ if (iMessageNotificationObserver != MessageNotificationObserver())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Observers destructors." ) );
+
+ delete iIdPinObserver;
+ iIdPinObserver = 0;
+ delete iVBusObserver;
+ iVBusObserver = 0;
+ delete iOtgStateObserver;
+ iOtgStateObserver = 0;
+ delete iBusActivityObserver;
+ iBusActivityObserver = 0;
+ delete iHostEventNotificationObserver;
+ iHostEventNotificationObserver = 0;
+ delete iMessageNotificationObserver;
+ iMessageNotificationObserver = 0;
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL NotifManager and WarningNotifier." ) );
+
+ CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL();
+ RNotifier rnotifier;
+ User::LeaveIfError(rnotifier.Connect());
+ CUsbWarningNotifier* usbnotifier = CUsbWarningNotifier::NewL(rnotifier,
+ usbnotifmanager, EUsbOtgPartiallySupportedDevice);
+ usbnotifier->IsFeedbackNeeded();
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL NotifManager and WarningNotifier destruction." ) );
+
+ delete usbnotifier;
+ rnotifier.Close();
+ delete usbnotifmanager;
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Creating states." ) );
+
+ User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostAIdle::NewL(this)));
+ User::LeaveIfError(iStates.Append(CUsbStateHostHandle::NewL(this)));
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check State()" ) );
+
+ if (iStates[EUsbStateHostAInitiate] != State(EUsbStateHostAInitiate))
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check CurrentHostState()" ) );
+
+ iHostState = iStates[EUsbStateHostAInitiate];
+
+ if (iStates[EUsbStateHostAInitiate] != CurrentHostState())
+ {
+ User::Leave(KErrGeneral);
+ }
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Destructing states." ) );
+
+ iStates.ResetAndDestroy();
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check UsbServiceControl" ) );
+
+ CUsbServiceControl* usbServiceControl = CUsbServiceControl::NewL(this,
+ iUsb);
+ usbServiceControl->RunError(KErrNone);
+ delete usbServiceControl;
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL All completed OK." ) );
+#endif
+ return KErrNone;
+
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbpersonalityswitch.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,299 @@
+/*
+* 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: Switches personality
+ *
+*/
+
+#include <e32base.h>
+#include <usb.h>
+#include <usbpersonalityids.h>
+
+#include "cusbpersonalityswitch.h"
+
+#include "panic.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbPersonalitySwitch::CUsbPersonalitySwitch(
+ MUsbPersonalitySwitchObserver* aObserver) :
+ CActive(CActive::EPriorityStandard), iObserver(aObserver), iState(EIdle)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbPersonalitySwitch::~CUsbPersonalitySwitch()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::~CUsbPersonalitySwitch" ) );
+ Cancel();
+ iUsbInterface.Close();
+ iSendData.Close();
+ iRcvData.Close();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbPersonalitySwitch::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::ConstructL" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbPersonalitySwitch* CUsbPersonalitySwitch::NewL(
+ MUsbPersonalitySwitchObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::NewL" ) );
+
+ CUsbPersonalitySwitch* self = new (ELeave) CUsbPersonalitySwitch(
+ aObserver);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self); // pop self
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbPersonalitySwitch::SwitchPersonalityL(TUint32 aDeviceId,
+ TInt aPersonalityToBeSet)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonality aDeviceId %d, aPersonalityToBeSet %d" ), aDeviceId, aPersonalityToBeSet))
+
+ if (IsActive() || EIdle != iState)
+ {
+ Cancel();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ERequestCancelled, KErrNone);
+ }
+
+ // create usb interface for the device id
+ TUint32 token(0); // = RFdc.InterfaceToken();
+ TInt err = iUsbInterface.Open(token);
+
+ FTRACE(FPrint(_L("[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonality UsbInterface Open err = %d" ), err));
+ if (KErrNone != err)
+ {
+ return err;
+ }
+
+ iPersonalityToBeSet = aPersonalityToBeSet;
+
+ // get list of supported personalities
+ iTransfer.iRequestType = KUsbRequestType_DirToHost
+ | KUsbRequestType_TypeVendor | KUsbRequestType_DestDevice;
+
+ iTransfer.iRequest = KGetAllPersonalitiesReq;
+ iTransfer.iValue = 0;
+ iTransfer.iIndex = 0;
+ iTransfer.iFlags
+ = RUsbInterface::TUsbTransferRequestDetails::EShortTransferOk;
+
+ Reset();
+
+ iState = EGetAllPersonalities;
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonalityL Sending GetAllPersonalities request." ) );
+ iUsbInterface.Ep0Transfer(iTransfer, iSendData, iRcvData, iStatus);
+ SetActive();
+
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ERequestingAllPersonalities,
+ KErrNone);
+
+ return KErrNone;
+ }
+
+void CUsbPersonalitySwitch::CancelSwitchPersonalityL()
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::CancelSwitchPersonalityL"));
+
+ if (IsActive())
+ {
+ Cancel();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ERequestCancelled, KErrNone);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbPersonalitySwitch::RunL()
+ {
+
+ if (KErrNone != iStatus.Int())
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL iStatus %d" ), iStatus.Int()));
+ User::Leave(iStatus.Int());
+ }
+
+ switch (iState)
+ {
+
+ case EGetAllPersonalities:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetAllPersonalities completed."));
+
+ TInt numOfPersonalities = iRcvData[KNumOfPersShift];
+ FTRACE(FPrint(_L("[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Amount of personalities in peripheral = %d" ), numOfPersonalities));
+
+ // if no personalities then return
+ if (0 == numOfPersonalities)
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL No personailies found in peripheral."));
+ Reset();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted,
+ KErrNotFound);
+ return;
+ }
+
+ // if needed pers already set, then return
+ TInt currentPersonality = iRcvData[KCurrPersShift];
+ if (iPersonalityToBeSet == currentPersonality)
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Needed personality already set in peripheral."));
+ Reset();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted,
+ KErrInUse);
+ return;
+ }
+
+ // check if device supports needed personality
+ TInt count(0);
+ while (count < numOfPersonalities && iPersonalityToBeSet
+ != iRcvData[KFirstPersonalityIdShift
+ + KLenghtOfPersonalityData * count])
+ {
+ ++count;
+ }
+
+ if (count == numOfPersonalities) // not found == not supported
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Peripheral does not support needed personality."));
+ Reset();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted,
+ KErrNotFound);
+ return;
+ }
+
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted,
+ KErrNone);
+
+ // set personality
+ iTransfer.iRequestType = KUsbRequestType_DirToDev
+ | KUsbRequestType_TypeVendor | KUsbRequestType_DestDevice;
+
+ iTransfer.iRequest = KSetPersonalityReq;
+ iTransfer.iValue = iPersonalityToBeSet;
+ iTransfer.iIndex = 0;
+ iTransfer.iFlags
+ = RUsbInterface::TUsbTransferRequestDetails::EShortTransferOk;
+
+ iSendData.Close();
+ iRcvData.Close();
+
+ iState = ESetPersonality;
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Sending SetPersonality request." ) );
+ iUsbInterface.Ep0Transfer(iTransfer, iSendData, iRcvData, iStatus);
+ SetActive();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ERequestingSetPersonality,
+ KErrNone);
+
+ break;
+ }
+ case ESetPersonality:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL SetPersonality completed."));
+ Reset();
+ iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ESetPersonalityCompleted,
+ KErrNone);
+
+ break;
+ }
+ /* case EGetAllPersResult:
+ {
+ FLOG( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetAllPersResult completed.");
+
+ break;
+ }
+ case EGetSetPersResult:
+ {
+ FLOG( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetSetPersResult completed.");
+
+ break;
+ } */
+
+ case EIdle: // do not break
+ default:
+ {
+ Panic(EUnexpectedUsbSwitchPersonalityState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbPersonalitySwitch::RunError(TInt aError)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunError aError %d" ), aError ));
+ Reset();
+ TRAP_IGNORE (iObserver->UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::ERequestFailed, aError) );
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbPersonalitySwitch::DoCancel()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::DoCancel" ) )
+
+ iUsbInterface.CancelEP0Transfer();
+ Reset();
+ }
+
+void CUsbPersonalitySwitch::Reset()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::Reset" ) )
+
+ iState = EIdle;
+ iSendData.Close();
+ iRcvData.Close();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbservicecontrol.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,403 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <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()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::~CUsbServiceControl" ) );
+ Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::ConstructL" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbServiceControl* CUsbServiceControl::NewL(
+ MUsbServiceControlObserver* aObserver, RUsb& aUsb)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::NewL" ) );
+
+ CUsbServiceControl* self = new (ELeave) CUsbServiceControl(aObserver,
+ aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self); // pop self
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::Start(TInt aPersonalityId)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start aPersonalityId = %d" ), aPersonalityId));
+
+ TUsbServiceState serviceState;
+ TInt err = iUsb.GetServiceState(serviceState);
+
+ if (KErrNone != err)
+ {
+ return err;
+ }
+
+ switch (serviceState)
+ {
+ case EUsbServiceIdle:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceIdle" ) );
+
+ iPersonalityId = aPersonalityId; // when request completed, this will indicate that we started what we wanted
+ if (IsActive())
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Request is outstanding, cancelling first." ) );
+ Cancel();
+ }
+ iUsb.TryStart(aPersonalityId, iStatus);
+ SetActive();
+ break;
+ }
+
+ case EUsbServiceStarted:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) );
+
+ TInt currentPersonality(0);
+ err = iUsb.GetCurrentPersonalityId(currentPersonality);
+ if (KErrNone != err)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Error getting current personality err = %d" ), err));
+ return err;
+ }
+
+ if (aPersonalityId == currentPersonality) // already started
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already sterted" ) );
+ iObserver->UsbServiceControlReqCompletedL(KErrNone);
+ 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
+
+ Stop();
+
+ // start new personality in RunL() when state is Idle
+
+ break;
+ }
+ case EUsbServiceStarting:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarting" ) );
+ // do exactly the same as in case of EUsbServiceStopping;
+ // break statement is not required here
+ }
+ case EUsbServiceStopping:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start 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())
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start 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:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
+ return KErrGeneral;
+ }
+ default:
+ {
+ Panic(EUnknownUsbServiceState);
+ }
+ }
+
+ return KErrNone;
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::Stop()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop" ) );
+
+ TUsbServiceState serviceState;
+ TInt err = iUsb.GetServiceState(serviceState);
+
+ if (KErrNone != err)
+ {
+ return err;
+ }
+
+ switch (serviceState)
+ {
+ case EUsbServiceIdle:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceIdle" ) );
+
+ return KErrNone;
+ }
+
+ case EUsbServiceStarted:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStarted" ) );
+
+ if (IsActive())
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop Request is outstanding, cancelling it." ) );
+ Cancel();
+ }
+ iUsb.TryStop(iStatus);
+ SetActive();
+
+ break;
+ }
+ case EUsbServiceStopping:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStopping" ) );
+ // do exactly the same as in case of EUsbServiceStarting;
+ // break statement is not required here
+ }
+ case EUsbServiceStarting:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop 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())
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop 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:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
+ return KErrGeneral;
+ }
+ default:
+ {
+ Panic(EUnknownUsbServiceState);
+ }
+ }
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::RunL()
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL iStatus %d" ), iStatus.Int()));
+ if (KErrNone != iStatus.Int())
+ {
+ //User::Leave(iStatus.Int());
+ iObserver->UsbServiceControlReqCompletedL(iStatus.Int());
+ return;
+ }
+
+ TUsbServiceState serviceState;
+ TInt err = iUsb.GetServiceState(serviceState);
+
+ if (KErrNone != err)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting service state %d" ), err));
+ //User::Leave(err);
+ iObserver->UsbServiceControlReqCompletedL(err);
+ return;
+ }
+
+ switch (serviceState)
+ {
+ case EUsbServiceIdle: // usb service stopped
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL UsbServiceState == EUsbServiceIdle" ) );
+
+ if (iPersonalityId != 0) // during service stopping, requested to start it
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId));
+ TInt personalityId = iPersonalityId;
+ iPersonalityId = 0; // reset
+ err = Start(personalityId);
+ if(KErrNone != err)
+ {
+ iObserver->UsbServiceControlReqCompletedL(err);
+ }
+ return;
+ }
+
+ // otherwise, we've done, notify
+ iObserver->UsbServiceControlReqCompletedL(KErrNone);
+ break;
+ }
+
+ case EUsbServiceStarted:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) );
+
+ TInt currentPersonality(0);
+ err = iUsb.GetCurrentPersonalityId(currentPersonality);
+ if (KErrNone != err)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting PersonalityId err = %d" ), err));
+ //User::Leave(err);
+ iObserver->UsbServiceControlReqCompletedL(err);
+ return;
+ }
+
+ if (iPersonalityId == currentPersonality) // already done
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already started." ) );
+ iPersonalityId = 0;
+ iObserver->UsbServiceControlReqCompletedL(KErrNone);
+ return;
+ }
+
+ if (iPersonalityId == 0) // during service start requested to stop it
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Requested to stop personality. Stopping." ) );
+ err = Stop();
+ if(KErrNone != err)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while stopping personality err = %d" ), err));
+ iObserver->UsbServiceControlReqCompletedL(err);
+ }
+ return;
+ }
+
+ // otherwise, during service start, requested to start it with another personality
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId));
+ TInt personalityId = iPersonalityId;
+ iPersonalityId = 0; // reset
+ //User::LeaveIfError(Start(personalityId));
+ err = Start(personalityId);
+ if(KErrNone != err)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL 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
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStarting. Continue." ) );
+ }
+ case EUsbServiceStopping:
+ {
+ // we are not interested in these states, just continue monitoring
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStopping. Continue." ) );
+ iUsb.ServiceStateNotification(iServiceState, iStatus);
+ SetActive();
+ break;
+ }
+ case EUsbServiceFatalError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
+ //User::Leave(KErrGeneral);
+ iObserver->UsbServiceControlReqCompletedL(KErrGeneral);
+ break;
+ }
+ default:
+ {
+ Panic(EUnknownUsbServiceState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbServiceControl::RunError(TInt aError)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunError aError %d" ), aError ));
+ //TRAP_IGNORE(iObserver->UsbServiceControlReqCompletedL(aError));
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbServiceControl::DoCancel()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TryStart."))
+ iUsb.CancelInterest(RUsb::ETryStart);
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TrySop."))
+ iUsb.CancelInterest(RUsb::ETryStop);
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to usb states notifications."))
+ iUsb.ServiceStateNotificationCancel();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstate.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include "cusbstate.h"
+
+#include "panic.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbState::CUsbState(CUsbOtgWatcher* aWatcher) :
+ iWatcher(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbState::~CUsbState()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::JustAdvancedToThisStateL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::JustBeforeLeavingThisStateL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::ChangeStateL(TUsbStateIds aNewStateId)
+ {
+
+ iWatcher->ChangeStateL(aNewStateId);
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::ChangeHostStateL(TUsbStateIds aNewStateId)
+ {
+
+ iWatcher->ChangeHostStateL(aNewStateId);
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPersonalityL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::CancelSetPersonalityL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPreviousPersonalityL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::CancelSetPreviousPersonalityL()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SetPreviousPreviousPersonalityOnDisconnectL()
+ {
+ }
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+// From IdPin observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::IdPinOffL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::IdPinOffL" ) );
+ Panic(EIdPinOffNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::IdPinOnL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::IdPinOnL" ) );
+ Panic(EIdPinOnNotExpected);
+ }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusDownL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusDownL" ) );
+ Panic(EVBusDownNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusUpL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusUpL" ) );
+ }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AIdleL" ) );
+ Panic(EAIdleNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AHostL" ) );
+ Panic(EAHostNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::APeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::APeripheralL" ) );
+ Panic(EAPeripheralNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::AVBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AVBusErrorL" ) );
+ Panic(EAVBusErrorNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BIdleL" ) );
+ Panic(EBIdleNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BPeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BPeripheralL" ) );
+ Panic(EBPeripheralNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BHostL" ) );
+ Panic(EBHostNotExpected);
+ }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BusIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BusIdleL" ) );
+ Panic(EBusIdleNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BusActiveL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BusActiveL" ) );
+ Panic(EBusActiveNotExpected);
+ }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DeviceAttachedL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DeviceAttachedL" ) );
+ Panic(EDeviceAttachedNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DeviceDetachedL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DeviceDetachedL" ) );
+ Panic(EDeviceDetachedNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadSuccessL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadSuccessL" ) );
+ Panic(EDriverLoadSuccessNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadPartialSuccessL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadPartialSuccessL" ) );
+ Panic(EDriverLoadPartialSuccessNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::DriverLoadFailureL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadFailureL" ) );
+ Panic(EDriverLoadFailureNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::BadHubPositionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BadHubPositionL" ) );
+ Panic(EBadHubPositionNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::VBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusErrorL" ) );
+ Panic(EVBusErrorNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::MessageNotificationReceivedL(TInt)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::MessageNotificationReceivedL" ) );
+ Panic(EMessageNotificationNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SrpReceivedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::SrpReceivedL" ) );
+ Panic(ESrpNotExpected);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbState::SessionRequestedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::SessionRequestedL" ) );
+ Panic(ESessionRequestNotExpected);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostabase.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,269 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <e32base.h>
+#include <usbhosterrors.h>
+#include <d32otgdi_errors.h>
+#include <d32usbdi_errors.h>
+
+#include "cusbstatehostabase.h"
+#include "cusbstatehosthandle.h"
+
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostABase::CUsbStateHostABase(CUsbOtgWatcher* aWatcher) :
+ CUsbState(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::ConstructL" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostABase::~CUsbStateHostABase()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::~CUsbStateHostABase" ) );
+
+ }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::VBusDownL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::VBusDownL" ) );
+ ChangeHostStateL(EUsbStateHostAIdle);
+ }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::AIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AIdleL" ) );
+ // do nothing
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::AVBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AVBusErrorL" ) );
+ // No need to handle BusClearError error code, due to Bus will be dropped anyway
+ iWatcher->Usb().BusClearError();
+ HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower);
+ }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BusIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BusIdleL" ) );
+ //do nothing
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BusActiveL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BusActiveL" ) );
+ // do nothing
+ }
+
+// From message notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::MessageNotificationReceivedL(TInt aMessage)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL = %d" ), aMessage));
+
+ switch (aMessage)
+ {
+
+ // OTGDI
+ case KErrUsbOtgEventQueueOverflow: // = -6670;
+ case KErrUsbOtgStateQueueOverflow:// = -6671;
+ case KErrUsbOtgMessageQueueOverflow: // = -6672;
+
+ case KErrUsbOtgBadState:// = -6675;
+
+ case KErrUsbOtgStackNotStarted:// = -6680;
+ //case KErrUsbOtgVbusAlreadyRaised:// = -6681;
+ //case KErrUsbOtgSrpForbidden:// = -6682;
+
+ case KErrUsbOtgHnpNotResponding:// = -6683;
+ //case KErrUsbOtgHnpBusDrop:// = -6684;
+
+ case KErrUsbOtgBusControlProblem:// = -6685;
+
+ case KErrUsbOtgVbusPowerUpError:// = -6686;
+
+ case KErrUsbOtgHnpEnableProblem:// = -6687;
+
+ case KErrUsbOtgVbusError:// = -6690;
+ case KErrUsbOtgSrpTimeout:// = -6691;
+ //case KErrUsbOtgSrpActive:// = -6692;
+ //case KErrUsbOtgSrpNotPermitted:// = -6693;
+ //case KErrUsbOtgHnpNotPermitted:// = -6694;
+ //case KErrUsbOtgHnpNotEnabled:// = -6695;
+ //case KErrUsbOtgHnpNotSuspended:// = -6696;
+ //case KErrUsbOtgVbusPowerUpNotPermitted:// = -6697;
+ //case KErrUsbOtgVbusPowerDownNotPermitted:// = -6698;
+ //case KErrUsbOtgVbusClearErrorNotPermitted:// = -6699;
+
+ // hosterrors.h
+ case KErrUsbConfigurationHasNoInterfaces:
+ case KErrUsbInterfaceCountMismatch:
+ case KErrUsbDuplicateInterfaceNumbers:
+ case KErrUsbBadDescriptor:
+ case KErrUsbDeviceDetachedDuringDriverLoading:
+ case KErrUsbAttachmentFailureGeneralError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL ErrorInConnection" ) );
+ HandleL(EUsbWatcherErrorInConnection);
+ break;
+ }
+
+ // OTGDI
+ case KErrUsbOtgPeriphNotSupported: // = -6688
+
+ // 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:
+ case KErrUsbBadHub:
+ case KErrUsbEventOverflow:
+
+ // hosterrors.h
+ case KErrUsbUnsupportedDevice:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL UnsupportedDevice" ) );
+ HandleL(EUsbWatcherErrUnsupportedDevice);
+ break;
+ }
+ default:
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL Unhandled message = %d" ), aMessage));
+ break;
+ }
+
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::BadHubPositionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BadHubPositionL" ) );
+ HandleL(EUsbWatcherHubsNotSupported);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::VBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::VBusErrorL" ) );
+ // No error code handling after BusClearError call, due to bus will be dropped anyway
+ iWatcher->Usb().BusClearError();
+ HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::SessionRequestedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL" ) );
+
+ if (iWatcher->VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
+ {
+ // session already ongoing; BusRequest() in this case returns KErrUsbOtgBadState...
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL() VBus is already UP; ignore Session request." ) );
+ return;
+ }
+
+ TInt err = iWatcher->Usb().BusRequest();
+ if (KErrNone != err && KErrUsbOtgVbusAlreadyRaised != err) // sometimes this also comes...
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL BusRequestError err = %d" ), err));
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ return;
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL Session started OK (or VBUS already UP) err = %d" ), err));
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostABase::HandleL(TInt aWhat)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::HandleL aWhat = %d" ), aWhat));
+
+ iWatcher->HandleHostProblemL(aWhat);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostahost.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <e32base.h>
+#include <UsbWatcherInternalPSKeys.h>
+
+#include "cusbstatehostahost.h"
+#include "cusbnotifmanager.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+#include "definitions.h"
+
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher* aWatcher) :
+ CUsbStateHostABase(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::ConstructL" ) );
+
+ CUsbStateHostABase::ConstructL();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher* aWatcher)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) );
+
+ CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAHost::~CUsbStateHostAHost()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::~CUsbStateHostAHost" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAHost::Id()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::Id" ) );
+
+ return EUsbStateHostAHost;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::JustAdvancedToThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustAdvancedToThisStateL" ) );
+
+ User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
+ KUsbWatcherIsPeripheralConnected,
+ KUsbWatcherPeripheralIsConnected ) );
+
+ iWatcher->NotifManager()->ShowIndicatorL(ETrue);
+
+ iWatcher->PrintStateToLog();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::JustBeforeLeavingThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustBeforeLeavingThisStateL" ) );
+
+ User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
+ KUsbWatcherIsPeripheralConnected,
+ KUsbWatcherPeripheralIsNotConnected ) );
+
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::AHostL" ) );
+ // do nothing
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::APeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) );
+ ChangeHostStateL(EUsbStateHostAPeripheral);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::DeviceDetachedL" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAHost::BadHubPositionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::BadHubPositionL" ) );
+ Panic(EBadHubPositionEventNotExpected);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostaidle.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include "cusbstatehostaidle.h"
+#include "cusbnotifmanager.h"
+
+#ifndef STIF
+#include "cusbtimer.h"
+#else
+#include "mockcusbtimer.h"
+#endif
+#include "definitions.h"
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAIdle::CUsbStateHostAIdle(CUsbOtgWatcher* aWatcher) :
+ CUsbStateHostAInitiateBase(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAIdle::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::ConstructL" ) );
+
+ CUsbStateHostAInitiateBase::ConstructL();
+ }
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+CUsbStateHostAIdle* CUsbStateHostAIdle::NewL(CUsbOtgWatcher* aWatcher)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::NewL" ) );
+
+ CUsbStateHostAIdle* self = new (ELeave) CUsbStateHostAIdle(aWatcher);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAIdle::~CUsbStateHostAIdle()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::~CUsbStateHostAIdle" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAIdle::Id()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::Id" ) );
+
+ return EUsbStateHostAIdle;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAIdle::JustAdvancedToThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::JustAdvancedToThisStateL" ) );
+
+ iWatcher->PrintStateToLog();
+
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+
+ // do BusDrop, if Up
+ if (CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus())
+ {
+ TInt err = iWatcher->Usb().BusDrop();
+ if (err != KErrNone)
+ {
+ err = iWatcher->Usb().BusClearError();
+ if (KErrNone != err)
+ {
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ }
+ }
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include "cusbstatehostainitiate.h"
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#include "cusbtimer.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) :
+ CUsbStateHostAInitiateBase(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::ConstructL" ) );
+
+ CUsbStateHostAInitiateBase::ConstructL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiate* CUsbStateHostAInitiate::NewL(CUsbOtgWatcher* aWatcher)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::NewL" ) );
+
+ CUsbStateHostAInitiate* self = new (ELeave) CUsbStateHostAInitiate(
+ aWatcher);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiate::~CUsbStateHostAInitiate()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::~CUsbStateHostAInitiate" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAInitiate::Id()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::Id" ) );
+
+ return EUsbStateHostAInitiate;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::JustAdvancedToThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL" ) );
+
+ iWatcher->PrintStateToLog();
+
+ TInt err = iWatcher->Usb().EnableFunctionDriverLoading();
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL EnableFunctionDriverLoading error" ) );
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ return;
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL EnableFunctionDriverLoading(); = %d" ), err));
+
+ // 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();
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL BusRequest() = %d" ), err));
+
+ if (KErrNone != busReqErr)
+ {
+ err = iWatcher->Usb().BusClearError();
+ if (KErrNone != err)
+ {
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ return;
+ }
+ }
+ ++count;
+ }
+ if (KErrNone != busReqErr)
+ {
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ return;
+ }
+ }
+
+ // start timer, waiting for device attachment
+ iAttachmentTimer->After(KTimeToWaitForDeviceAttachment);
+
+ iWatcher->NotifManager()->BlinkIndicatorL(ETrue);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiate::JustBeforeLeavingThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustBeforeLeavingThisStateL" ) );
+
+ iWatcher->NotifManager()->BlinkIndicatorL(EFalse);
+
+ CUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostainitiatebase.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbuinotif.h>
+#include <usbpersonalityids.h>
+
+#include "cusbstatehostainitiatebase.h"
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#include "cusbtimer.h"
+#else
+#include "mockcusbnotifmanager.h"
+#include "mockcusbtimer.h"
+#endif
+
+#include "definitions.h"
+#include "errors.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiateBase::CUsbStateHostAInitiateBase(
+ CUsbOtgWatcher* aWatcher) :
+ CUsbStateHostABase(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::ConstructL" ) );
+
+ CUsbStateHostABase::ConstructL();
+
+ iAttachmentTimer = CUsbTimer::NewL(this, EDeviceAttachmentTimer);
+
+ //iUsbPersonalitySwitch = CUsbPersonalitySwitch::NewL(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAInitiateBase::~CUsbStateHostAInitiateBase()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::~CUsbStateHostAInitiateBase" ) );
+
+ delete iAttachmentTimer;
+ //delete iUsbPersonalitySwitch;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL" ) );
+ iAttachmentTimer->Cancel();
+ }
+
+// From TimerObserver
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::TimerElapsedL(TUsbTimerId aTimerId)
+ {
+ switch (aTimerId)
+ {
+ case EDeviceAttachmentTimer:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::TimerElapsedL - AttachmentTimer" ) );
+ HandleL(EUsbWatcherErrDandlingCable);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::TimerElapsedL - Unknown timer" ) );
+ Panic(EWrongTimerId);
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::VBusUpL()
+ {
+ // start timer, waiting for device attachment
+ iAttachmentTimer->After(KTimeToWaitForDeviceAttachment);
+ }
+
+// From VBus observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::VBusDownL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::VBusDownL" ) );
+ iAttachmentTimer->Cancel();
+
+ CUsbStateHostABase::VBusDownL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::AHostL" ) );
+ // do nothing
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::APeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) );
+ ChangeHostStateL(EUsbStateHostAPeripheral);
+ }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::DeviceAttachedL(TDeviceEventInformation aTdi)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iDeviceId = %d" ), aTdi.iDeviceId));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iEventType = %d" ), aTdi.iEventType));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iError = %d" ), aTdi.iError));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iDriverLoadStatus = %d" ), aTdi.iDriverLoadStatus));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iVid = %d" ), aTdi.iVid));
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iPid = %d" ), aTdi.iPid));
+
+ 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);
+
+ TBool hnpSupported(otgDescriptor.iAttributes & EUsbOtgHNPSupported);
+ TBool srpSupported(otgDescriptor.iAttributes & EUsbOtgSRPSupported);
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL GetOtgDescriptor err = %d, HNP supported = %d, SRP supported = %d" ), err, hnpSupported, srpSupported));
+
+ // OTG device supports both hnp and srp
+ if(hnpSupported && srpSupported)
+ {
+ HandleL(EUsbWatcherConnectedToOTG);
+ return;
+ }
+
+ if (KErrNone != aTdi.iError)
+ {
+ switch (aTdi.iError)
+ // error in attachement
+ {
+ case KErrBadPower:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL TooMuchPower" ) );
+ HandleL(EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL AttachmentError" ) );
+ HandleL(EUsbWatcherErrUnsupportedDevice);
+ break;
+ }
+
+ }
+
+ return;
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::DriverLoadSuccessL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadSuccessL" ) );
+ ChangeHostStateL(EUsbStateHostAHost);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::DriverLoadPartialSuccessL(
+ TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadPartialSuccessL" ) );
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgWarning,
+ EUsbOtgPartiallySupportedDevice, NULL);
+ ChangeHostStateL(EUsbStateHostAHost);
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::DriverLoadFailureL(
+ TDeviceEventInformation aDei)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadFailureL" ) );
+
+ // try initiate to switch to mass storage
+ /* if (KErrNone != iUsbPersonalitySwitch->SwitchPersonalityL(aDei.iDeviceId,
+ KUsbPersonalityIdMS ))
+ {*/
+ HandleL(EUsbWatcherErrDriversNotFound);
+ // }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAInitiateBase::SrpReceivedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::SrpReceivedL" ) );
+ if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus())
+ {
+ TInt err = iWatcher->Usb().BusRespondSrp();
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::SrpReceivedL BusRespondSrp error" ) );
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ }
+ }
+ }
+
+void CUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL(
+ MUsbPersonalitySwitchObserver::TState aState, TInt aData)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL aState = %d aData = %d" ), TInt(aState), aData));
+
+ switch (aState)
+ {
+ case ERequestingAllPersonalities:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestingAllPersonalities" ) );
+ break;
+ }
+ case ERequestingSetPersonality:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestingSetPersonality" ) );
+ break;
+ }
+ case EGetAllPersonalitiesCompleted:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL EGetAllPersonalitiesCompleted" ) );
+ if (KErrNotFound == aData)
+ {
+ // no supported or needed personality/ies in the peripheral
+ HandleL(EUsbWatcherErrDriversNotFound);
+ }
+ break;
+ }
+ case ESetPersonalityCompleted:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ESetPersonalityCompleted" ) );
+
+ break;
+ }
+ case ERequestCancelled:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestCancelled" ) );
+ break;
+ }
+ case ERequestFailed:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestFailed" ) );
+ HandleL(EUsbWatcherErrDriversNotFound);
+ break;
+ }
+ default:
+ {
+ Panic(EUnexpectedUsbSwitchPersonalityState);
+ }
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbuinotif.h>
+
+#include "cusbstatehostaperipheral.h"
+
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#include "cusbtimer.h"
+#else
+#include "mockcusbnotifmanager.h"
+#include "mockcusbtimer.h"
+#endif
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral::CUsbStateHostAPeripheral(CUsbOtgWatcher* aWatcher) :
+ CUsbStateHostABase(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::ConstructL" ) );
+
+ CUsbStateHostABase::ConstructL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral* CUsbStateHostAPeripheral::NewL(
+ CUsbOtgWatcher* aWatcher)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::NewL" ) );
+
+ CUsbStateHostAPeripheral* self = new (ELeave) CUsbStateHostAPeripheral(
+ aWatcher);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostAPeripheral::~CUsbStateHostAPeripheral()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::~CUsbStateHostAPeripheral" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::JustAdvancedToThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::JustAdvancedToThisStateL" ) );
+ iWatcher->PrintStateToLog();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostAPeripheral::Id()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::Id" ) );
+ return EUsbStateHostAPeripheral;
+ }
+
+// From OTG state observer
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostAPeripheral::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::AHostL" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,606 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbuinotif.h>
+
+#include "cusbstatehosthandle.h"
+#ifndef STIF
+#include "cusbnotifmanager.h"
+#else
+#include "mockcusbnotifmanager.h"
+#endif
+
+#include "errors.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle::CUsbStateHostHandle(CUsbOtgWatcher* aWatcher) :
+ CUsbState(aWatcher)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle* CUsbStateHostHandle::NewL(CUsbOtgWatcher* aWatcher)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) );
+
+ CUsbStateHostHandle* self = new (ELeave) CUsbStateHostHandle(aWatcher);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::ConstructL" ) );
+
+ iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer);
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbStateHostHandle::~CUsbStateHostHandle()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::~CUsbStateHostHandle" ) );
+
+ delete iTooMuchPowerTimer;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TUsbStateIds CUsbStateHostHandle::Id()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::Id" ) );
+
+ return EUsbStateHostHandle;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::JustAdvancedToThisStateL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::JustAdvancedToThisStateL" ) );
+ iWatcher->PrintStateToLog();
+
+ DoHandleL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::JustBeforeLeavingThisStateL()
+ {
+ iTooMuchPowerTimer->Cancel();
+ iWatcher->NotifManager()->CloseAllNotifiers();
+ }
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::SetWhat(TInt aWhat)
+ {
+ iWhat = aWhat;
+ }
+
+// this means only one wait notifier at a time can be shown by this state
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::WaitNotifierCompletedL(TInt /*aFeedback*/)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL" ) );
+ switch (iWhat)
+ {
+ case EUsbWatcherErrDriversNotFound:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL DriversNotFound" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherHubsNotSupported:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherHubsNotSupported" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherErrDeviceRequiresTooMuchPower:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPower" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherErrUnsupportedDevice:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrUnsupportedDevice" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherConnectedToOTG:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherConnectedToOTG" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherErrDandlingCable:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDandlingCable" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherNoActivity:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherNoActivity" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherErrorInConnection:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrorInConnection" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ case EUsbWatcherCanNotStartUsbServices:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherCanNotStartUsbServices" ) );
+
+ break;
+ }
+ // errors from observers mapped to one
+ case EUsbWatcherIdPinError:
+ case EUsbWatcherVBusObserverError:
+ case EUsbWatcherHostEventNotificationError:
+ case EUsbWatcherOtgStateError:
+ case EUsbWatcherMessageNotificationError:
+ {
+ // try to restore
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Error in observer" ) );
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) );
+ Panic(EUnexpectedSituationToHandle);
+ break;
+ }
+
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DoHandleL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL iWhat = %d" ), iWhat));
+
+ if (iTooMuchPowerTimer)
+ iTooMuchPowerTimer->Cancel();
+
+ switch (iWhat)
+ {
+ case EUsbWatcherErrDriversNotFound:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL DriversNotFound" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgUnsupportedDevice, this);
+
+ break;
+ }
+ case EUsbWatcherHubsNotSupported:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherHubsNotSupported" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgHubUnsupported, this);
+ break;
+ }
+ case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) );
+
+ iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired);
+ break;
+ }
+ case EUsbWatcherErrDeviceRequiresTooMuchPower:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPower" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgTooMuchPower, this);
+ break;
+ }
+ case EUsbWatcherErrUnsupportedDevice:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrUnsupportedDevice" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgUnsupportedDevice, this);
+ break;
+ }
+ case EUsbWatcherConnectedToOTG:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherConnectedToOTG" ) );
+
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgUnsupportedDevice, this);
+ break;
+ }
+ case EUsbWatcherErrDandlingCable:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDandlingCable" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgErrorAttachTimedOut, this);
+ break;
+ }
+ case EUsbWatcherNoActivity:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherNoActivity" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgUnsupportedDevice, this);
+
+ break;
+ }
+ case EUsbWatcherErrorInConnection:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrorInConnection" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgErrorInConnection, this);
+ break;
+ }
+ case EUsbWatcherCanNotStartUsbServices:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherCanNotStartUsbServices" ) );
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgErrorInConnection, this);
+ break;
+ }
+ // errors from observers mapped to one
+ case EUsbWatcherIdPinError:
+ case EUsbWatcherVBusObserverError:
+ case EUsbWatcherHostEventNotificationError:
+ case EUsbWatcherOtgStateError:
+ case EUsbWatcherMessageNotificationError:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL Error from observer" ) );
+ // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgErrorInConnection, this);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) );
+ Panic(EUnexpectedSituationToHandle);
+ break;
+ }
+ }
+ }
+
+/////////////////////////////////////////////////////////////////////////////////////
+// just ignore all the events
+// From VBus observer
+void CUsbStateHostHandle::VBusDownL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusDownL" ) );
+ }
+
+// From OTG state observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::AIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AIdleL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::AHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AHostL" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::APeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::APeripheralL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::AVBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AVBusErrorL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BIdleL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BPeripheralL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BPeripheralL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BHostL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BHostL" ) );
+
+ }
+
+// From bus activity observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BusIdleL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusIdleL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BusActiveL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusActiveL" ) );
+
+ }
+
+// From Host Event notification observer
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DeviceAttachedL(
+ TDeviceEventInformation aDevEventInfo)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL" ) );
+
+ if (iTooMuchPowerTimer->IsActive())
+ {
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ iWatcher->DeviceAttachedL(aDevEventInfo);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DeviceDetachedL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceDetachedL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DriverLoadSuccessL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadSuccessL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DriverLoadPartialSuccessL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadPartialSuccessL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::DriverLoadFailureL(TDeviceEventInformation)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadFailureL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::BadHubPositionL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BadHubPositionL" ) );
+
+ if (iTooMuchPowerTimer->IsActive())
+ {
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ iWatcher->BadHubPositionL();
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::VBusErrorL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL" ) );
+
+ iWatcher->Usb().BusClearError();
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL Unexpected situation" ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::MessageNotificationReceivedL(TInt)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::MessageNotificationReceivedL" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::SrpReceivedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL" ) );
+
+ if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus())
+ {
+ TInt err = iWatcher->Usb().BusRespondSrp();
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL BusRespondSrp error" ) );
+ iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
+ }
+ else
+ {
+ ChangeHostStateL(EUsbStateHostAInitiate);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::SessionRequestedL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SessionRequestedL" ) );
+
+ }
+
+// From TimerObserver
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbStateHostHandle::TimerElapsedL(TUsbTimerId aTimerId)
+ {
+ switch (aTimerId)
+ {
+ case ETooMuchPowerRequiredTimer:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - ETooMuchPowerRequiredTimer" ) );
+ iWatcher->Usb().BusDrop();
+ iWatcher->NotifManager()->ShowIndicatorL(EFalse);
+ iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
+ EUsbOtgTooMuchPowerRequired, this);
+ break;
+ }
+ default:
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - Unknown timer" ) );
+ Panic(EWrongTimerId);
+ }
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbtimer.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include "cusbtimer.h"
+
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbTimer::CUsbTimer(MUsbTimerObserver* aObserver, TUsbTimerId aTimerId) :
+ CActive(CActive::EPriorityStandard), iObserver(aObserver), iTimerId(
+ aTimerId)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbTimer::~CUsbTimer()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::~CUsbTimer" ) );
+ Cancel();
+ iTimer.Close();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::ConstructL" ) );
+ User::LeaveIfError(iTimer.CreateLocal());
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbTimer* CUsbTimer::NewL(MUsbTimerObserver* anObserver,
+ TUsbTimerId aTimerId)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::NewL" ) );
+
+ CUsbTimer* self = new (ELeave) CUsbTimer(anObserver, aTimerId);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self); // pop self
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::After(TInt aMilliseconds)
+ {
+// FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::After aMilliseconds %d, timerId=%d" ), aMilliseconds, iTimerId))
+
+ if (IsActive()) // should we panic here? or just restart timer
+ {
+ Cancel();
+ }
+
+ // RunL will be called after KInactiveTimeForShutDown milliseconds
+ iTimer.After(iStatus, TTimeIntervalMicroSeconds32(aMilliseconds));
+ SetActive();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::RunL()
+ {
+
+ if(KErrNone != iStatus.Int())
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::RunL iStatus %d" ), iStatus.Int()));
+ User::Leave(iStatus.Int());
+ }
+
+ iObserver->TimerElapsedL(iTimerId);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbTimer::RunError(TInt aError)
+ {
+ FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::RunError aError %d" ), aError ));
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbTimer::DoCancel()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::DoCancel" ) )
+ iTimer.Cancel();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbvbusobserver.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,246 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation
+ *
+*/
+
+
+#include <usbotgdefs.h>
+
+#include "cusbvbusobserver.h"
+
+#include "definitions.h"
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::CUsbVBusObserver() :
+ CActive(EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::ConstructL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::ConstructL" ) );
+
+ User::LeaveIfError(iVBus.Attach(KUidUsbManCategory,
+ KUsbOtgVBusPoweredProperty));
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver* CUsbVBusObserver::NewL()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::NewL" ) );
+
+ CUsbVBusObserver* self = new (ELeave) CUsbVBusObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::~CUsbVBusObserver()
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::~CUsbVBusObserver" ) );
+
+ Cancel();
+
+ iVBus.Close();
+
+ iObservers.Close();
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* not const, because for some reason RProperty::Get is not const! */
+ {
+
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus" ) );
+
+ TInt val(0);
+
+ TInt err = iVBus.Get(val);
+
+ if (KErrNone != err)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus CanNotGetVBusProperty" ) );
+ Panic(ECanNotGetVBusProperty);
+ }
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus = %d" ), val ));
+
+ // not found in docs clear definition of this property. Verification is needed
+ return (0 == val ? EVBusDown : EVBusUp);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::SubscribeL(MUsbVBusObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::SubscribeL" ) );
+
+ User::LeaveIfError(iObservers.Append(aObserver));
+
+ if (KFirst == iObservers.Count()) // first item
+ {
+ iVBus.Subscribe(iStatus);
+ SetActive();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver* aObserver)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL" ) );
+
+ if (0 == iObservers.Count()) // no items
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL No observers" ) );
+ return;
+ }
+
+ TInt i(0);
+ while (i < iObservers.Count() && aObserver != iObservers[i])
+ {
+ ++i;
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL i = %d" ), i ));
+ }
+
+ if (aObserver == iObservers[i]) // found
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL Removing item" ) );
+ iObservers.Remove(i);
+ }
+ else
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL CanNotFindVBusObserver" ) );
+ Panic(ECanNotFindVBusObserver);
+ }
+
+ if (0 == iObservers.Count()) // no observers anymore
+ {
+ // cancel pending request, if any
+ Cancel();
+ return;
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::RunL()
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL 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:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus UP"));
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->VBusUpL();
+ }
+ break;
+ }
+ ;
+
+ case EVBusDown:
+ {
+ FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus DOWN"));
+
+ for (TInt i(0); i < iObservers.Count(); ++i)
+ {
+ iObservers[i]->VBusDownL();
+ }
+ break;
+ }
+ ;
+
+ default:
+ {
+ Panic(EWrongVBusState);
+ }
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::DoCancel()
+ {
+ iVBus.Cancel();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CUsbVBusObserver::RunError(TInt aError)
+ {
+
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunError aError = %d" ), aError));
+
+ // try to continue
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* 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: 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)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::NewL" ) );
+
+ CUsbWaitNotifier* self = new (ELeave) CUsbWaitNotifier(aNotifier,
+ aNotifManager, aNotifId);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUsbWaitNotifier::~CUsbWaitNotifier()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::~CUsbWaitNotifier" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbWaitNotifier::CUsbWaitNotifier(RNotifier& aNotifier,
+ CUsbNotifManager* aNotifManager, TUint aNotifId) :
+ CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgError, aNotifId)
+ {
+ SetFeedbackNeeded();
+ }
+
+// ---------------------------------------------------------------------------
+// Second-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CUsbWaitNotifier::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::ConstructL" ) );
+
+ CUsbNoteNotifier::ConstructL();
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* 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: 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)
+ {
+ FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbWarningNotifier::NewL aNotifId = %d" ), aNotifId));
+
+ CUsbWarningNotifier* self = new (ELeave) CUsbWarningNotifier(aNotifier,
+ aNotifManager, aNotifId);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbWarningNotifier::~CUsbWarningNotifier()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::~CUsbWarningNotifier" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CUsbWarningNotifier::CUsbWarningNotifier(RNotifier& aNotifier,
+ CUsbNotifManager* aNotifManager, TUint aNotifId) :
+ CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgWarning,
+ aNotifId)
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::CUsbWarningNotifier" ) );
+ }
+
+// -----------------------------------------------------------------------------
+// Second-phase constructor
+// -----------------------------------------------------------------------------
+//
+void CUsbWarningNotifier::ConstructL()
+ {
+ FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::ConstructL" ) );
+
+ CUsbNoteNotifier::ConstructL();
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/src/panic.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Central place for debug-type macros & functions
+*
+*/
+
+
+#include "panic.h"
+
+void Panic(TUsbWatcherPanic aCategory)
+{
+#ifdef _DEBUG
+ User::Panic(KUsbWatcherPanic, aCategory);
+#endif
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbremotepersonality/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,163 @@
+/*
+* 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;
+ iUsbWatcher->SetPreviousPersonalityOnDisconnect();
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,103 @@
+[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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,51 @@
+/*TYPE TESTCLASS*/
+/*
+* 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,41 @@
+/*TYPE TESTCLASS*/
+/*
+* 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/data/numberofacmfunctions.ini Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,9 @@
+[ACM_CONF]
+NumberOfAcmFunctions= 2
+
+[ACM 1]
+ProtocolNum= 1 // 0x01 - Code taken from USBCDC 1.1. Table 17- Hayes compatible modem
+
+
+[ACM 2]
+ProtocolNum= 255 //0xFF - vendor-specific
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/group/backup_registration.xml Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,50 @@
+/*
+* 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
+../data/numberofacmfunctions.ini /epoc32/data/z/private/101fe1db/numberofacmfunctions.ini
+../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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,86 @@
+/*
+* 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
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,278 @@
+/*
+* 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;
+
+ /**
+ * 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;
+
+ /**
+ * 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;
+ };
+
+#endif // CUSBACTIVEPERSONALITYHANDLER_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbactivestate.h Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,448 @@
+/*
+* 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"
+
+
+
+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
+ */
+ inline 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
+
+ };
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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;
+ }
+
+// ----------------------------------------------------------------------------
+// Write new personality to central repository.
+// ----------------------------------------------------------------------------
+//
+inline TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId )
+ {
+ return iPersonalityRepository->Set( KUsbWatcherPersonality,
+ aPersonalityId);
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/cusbwatcherscheduler.h Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,171 @@
+/*
+* 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/usbvariation.rh Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,211 @@
+/*
+* 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
+
+// mediasyncserver.iby
+#ifndef MEDIASYNCSERVER_IBY
+#define MEDIASYNCSERVER_IBY
+file=ABI_DIR\BUILD_DIR\rmediasyncserver.dll SHARED_LIB_DIR\rmediasyncserver.dll
+file=ABI_DIR\BUILD_DIR\mediasyncserver.exe PROGRAMS_DIR\mediasyncserver.exe
+#endif // MEDIASYNCSERVER_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
+#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
+
+// contactdp
+#ifndef MTP_CONTACTDP_IBY
+#define MTP_CONTACTDP_IBY
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+// MTP Data Provider API
+ECOM_PLUGIN(mtpcontactdp.dll, mtpcontactdp.rsc)
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102872bd.rsc resource\mtp\102872bd.rsc
+data=EPOCROOT##epoc32\data\Z\resource\apps\mtpcontactviewdefinition.rsc resource\apps\mtpcontactviewdefinition.rsc
+#endif // SYMBIAN_EXCLUDE_MTP
+#endif // MTP_CONTACTDP_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
+
+#endif // MTPSYMBIANTEMP_IBY__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/usbmanrsc.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 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
+data=ZPRIVATE\101fe1db\numberofacmfunctions.ini private\101fe1db\numberofacmfunctions.ini
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/rom/usbwatcher_resources.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,557 @@
+/*
+* 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 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 <rusb.h> // for KUsbmanSvrUid
+#include "cusbactivepersonalityhandler.h"
+#include "cusbglobalsystemstateobserver.h"
+
+// CONSTANTS
+// const TInt KSerialNumberLength = 12;
+const TInt KContainerIdLength = 16;
+
+// ============================ 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 )
+ {
+ 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();
+
+ // currently the serial number is used for the USB container ID
+ // the container ID length must be at least 16 bytes
+ // also, even when serial number is not used for the container id
+ // it must be at least 12, see below
+ if( length < KContainerIdLength )
+ {
+ // In GSM, the complete IMEI can 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 leading zeroes. When
+ // doing this, make sure not to write anything over descriptor's
+ // max length
+ if( iPhoneInfo.iSerialNumber.MaxLength() < KContainerIdLength )
+ {
+ iPhoneInfo.iSerialNumber.SetLength( KContainerIdLength );
+ }
+ while( length < KContainerIdLength )
+ {
+ 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;
+ 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;
+
+ // 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;
+ }
+ 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
+
+ return KErrNone;
+ }
+
+// ----------------------------------------------------------------------------
+// Executed when iStatus is completed.
+// ----------------------------------------------------------------------------
+//
+void CUsbActivePersonalityHandler::RunL()
+ {
+ LOG_FUNC
+
+ TInt ret = iStatus.Int();
+ if( KErrNone != ret )
+ {
+ LOG1( "ERROR: CUsbActivePersonalityHandler::RunL iStatus = %d", ret );
+ }
+
+ 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:
+ 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 );
+ }
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* 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
+ LOG2( "DeviceState change: %d ==> %d", iPreviousState, iCurrentState );
+ TUsbDeviceState newState = iCurrentState;
+ iUsbMan.DeviceStateNotification( KUsbAllStates, iCurrentState,
+ iStatus );
+ SetActive();
+ iOwner.StateChangeNotify( iPreviousState, newState );
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,1033 @@
+/*
+* 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 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
+
+ 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 );
+ iState = EUsbStarted;
+ if( iStopStartScenario )
+ {
+ iStopStartScenario = EFalse;
+ }
+ 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
+ // Left empty cause this can't happend
+ 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 );
+
+ if( IsDeviceA() )
+ {
+ LOG( "SetPersonality not allowed in A-device state" );
+ Notify( KErrAccessDenied );
+ return;
+ }
+
+ // 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
+
+ if( IsDeviceA() )
+ {
+ LOG( "Not allowed in A-device state" );
+ Notify( KErrAccessDenied );
+ return;
+ }
+
+ TUsbDeviceState state = iActiveState->CurrentState();
+ LOG1( "Device state : %d", state );
+
+ if( state != EUsbDeviceStateUndefined )
+ {
+ 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;
+ }
+ }
+ else
+ {
+ // if no connection -> just save the setting
+ LOG( "CUsbWatcher::SwitchPersonality: Notify" );
+ Notify( KErrNone );
+ }
+ }
+
+// ----------------------------------------------------------------------------
+// This method starts personality loading or continues stop start scenario.
+// ----------------------------------------------------------------------------
+//
+void CUsbWatcher::Start()
+ {
+ LOG_FUNC
+
+ TInt globalState = CUsbGlobalSystemStateObserver::GlobalSystemState();
+
+ if( iState == EUsbIdle )
+ {
+ iStarted = 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;
+ iPersonalityHandler->StartPersonality( iPersonalityId,
+ KUsbWatcherChangeOnConnectionOff, iStatus );
+ }
+ else
+ {
+ LOG1( "GetChargingPersonalityId = %d. Not started", ret );
+ }
+ }
+ else if( ( ( ESwStateNormalRfOn == globalState ) ||
+ ( ESwStateNormalRfOff == globalState ) ||
+ ( ESwStateNormalBTSap == globalState ) ))
+ {
+ LOG( "Global state: normal" );
+ 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;
+ }
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/cusbwatcherscheduler.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/tusbpersonalityparams.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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";
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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";
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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";
+ 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 = 0xFF;
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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";
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* 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() );
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,155 @@
+/*
+ * 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
+ };
+
+/**
+ * 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
+ };
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* 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"
+#include "../rndisui/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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,312 @@
+/*
+* 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
+* Version : %version: 13 %
+*
+*/
+
+
+
+// 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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;
+ }
+ };
+ }
+ };
+ }
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/imageprintuiprovider/data/imageprintuiprovider.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/rndisui/BWINS/rndisautherizationnotifieru.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ ?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/BWINS/rndisrefusalnotifieru.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ ?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/data/nokiarndis.inf Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,134 @@
+; 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: Nokia USB Remote NDIS Device
+
+
+[Version]
+Signature = "$Windows NT$"
+Class = Net
+ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318}
+Provider = %Symbian%
+DriverVer = 05/02/2007,0.0.0.1
+;CatalogFile = Symbian.cat
+
+[Manufacturer]
+%Symbian% = SymbianDevices,NT.5.1
+
+[SymbianDevices]
+%SymbianDevice% = RNDIS, USB\VID_0421&PID_03A3
+
+[SymbianDevices.NT.5.1]
+%SymbianDevice% = RNDIS.NT.5.1, USB\VID_0421&PID_03A3
+
+[ControlFlags]
+ExcludeFromSelect=*
+
+; Windows 2000 specific sections ---------------------------------
+
+[RNDIS.NT]
+Characteristics = 0x84 ; NCF_PHYSICAL + NCF_HAS_UI
+BusType = 15
+DriverVer = 05/02/2007,0.0.0.1
+AddReg = RNDIS_AddReg_NT, RNDIS_AddReg_WIN2K
+CopyFiles = RNDIS_CopyFiles_NT
+
+; DO NOT MODIFY THE SERVICE NAME
+[RNDIS.NT.Services]
+AddService = USB_RNDISY, 2, RNDIS_ServiceInst_NT, RNDIS_EventLog
+
+[RNDIS_CopyFiles_NT]
+; no rename of files on Windows 2000, use the 'y' names as is
+usb8023y.sys, , , 0
+rndismpy.sys, , , 0
+
+[RNDIS_ServiceInst_NT]
+DisplayName = %ServiceDisplayName%
+ServiceType = 1
+StartType = 3
+ErrorControl = 1
+ServiceBinary = %12%\usb8023y.sys
+LoadOrderGroup = NDIS
+AddReg = RNDIS_WMI_AddReg_NT
+
+[RNDIS_WMI_AddReg_NT]
+HKR, , MofImagePath, 0x00020000, "System32\drivers\rndismpy.sys"
+
+; Windows XP specific sections -----------------------------------
+
+[RNDIS.NT.5.1]
+Characteristics = 0x84 ; NCF_PHYSICAL + NCF_HAS_UI
+BusType = 15
+DriverVer = 05/02/2007,0.0.0.1
+AddReg = RNDIS_AddReg_XP
+include = netrndis.inf
+needs = Usb_Rndis.ndi
+
+; no copyfiles - the files are already in place
+
+[RNDIS.NT.5.1.Services]
+include = netrndis.inf
+needs = Usb_Rndis.ndi.Services
+
+; Windows 2000 sections
+
+; DO NOT MODIFY ServiceName
+[RNDIS_AddReg_NT]
+HKR, Ndi, Service, 0, "USB_RNDISY"
+HKR, Ndi\Interfaces, UpperRange, 0, "ndis5"
+HKR, Ndi\Interfaces, LowerRange, 0, "ethernet"
+
+[RNDIS_AddReg_WIN2K]
+HKR, , ReclaimRecv, 0x00010001, 1
+HKR, NDI\params\NetworkAddress, ParamDesc, 0, %NetworkAddress%
+HKR, NDI\params\NetworkAddress, type, 0, "edit"
+HKR, NDI\params\NetworkAddress, LimitText, 0, "12"
+HKR, NDI\params\NetworkAddress, UpperCase, 0, "1"
+HKR, NDI\params\NetworkAddress, default, 0, " "
+HKR, NDI\params\NetworkAddress, optional, 0, "1"
+
+[RNDIS_EventLog]
+AddReg = RNDIS_EventLog_AddReg
+
+[RNDIS_EventLog_AddReg]
+HKR, , EventMessageFile, 0x00020000, "%%SystemRoot%%\System32\netevent.dll"
+HKR, , TypesSupported, 0x00010001, 7
+
+; An optional Property to demonstrate adding advanced properties on Windows XP
+[RNDIS_AddReg_XP]
+HKR, NDI\params\XPProperty, ParamDesc, 0, %Sample_Property%
+HKR, NDI\params\XPProperty, type, 0, "edit"
+HKR, NDI\params\XPProperty, LimitText, 0, "12"
+HKR, NDI\params\XPProperty, UpperCase, 0, "1"
+HKR, NDI\params\XPProperty, default, 0, " "
+HKR, NDI\params\XPProperty, optional, 0, "1"
+
+
+[SourceDisksNames]
+1=%SourceDisk%,,1
+
+[SourceDisksFiles]
+usb8023y.sys=1
+rndismpy.sys=1
+
+[DestinationDirs]
+RNDIS_CopyFiles_NT = 12
+
+; DO NOT CHANGE ServiceDisplayName
+[Strings]
+ServiceDisplayName = "USB Remote NDIS Y Network Device Driver"
+Sample_Property = "Sample XP property"
+NetworkAddress = "Network Address"
+Symbian = "Symbian Software"
+SymbianDevice = "Symbian USB Remote NDIS Network Device"
+SourceDisk = "Symbian USB Network Driver Install Disk"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/data/rndisauthorizationnotifier.rss Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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: RNDIS uplink authorization notifier resource file
+*
+*/
+
+#include <ecom/registryinfo.rh>
+#include <uikon.hrh>
+#include "rndisauthorizationnotifier.hrh"
+
+RESOURCE REGISTRY_INFO r_registry
+ {
+ dll_uid = KUidUplinkAuthNotifierValue;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KUikonUidPluginInterfaceNotifiers;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = KUidUplinkAuthNotifierImp;
+ version_no = 1;
+ display_name = "Uplink Authorization Notifier Plugin";
+ default_data = "UplinkAuthNotifier";
+ opaque_data = "0";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/data/rndisrefusalnotifier.rss Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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: RNDIS refusal notifier resource file
+*
+*/
+
+#include <ecom/registryinfo.rh>
+#include <uikon.hrh>
+#include "rndisrefusalnotifier.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = KUidNetworkConnectionRefusalNotifierValue;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KUikonUidPluginInterfaceNotifiers;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = KUidNetworkConnectionRefusalNotifierImp;
+ version_no = 1;
+ display_name = "RNDIS Network Connection Refusal Notifier Plugin";
+ default_data = "RndisNetworkConnectionRefusalNotifier";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/eabi/rndisautherizationnotifieru.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z24ImplementationGroupProxyRi @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/eabi/rndisrefusalnotifieru.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z24ImplementationGroupProxyRi @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -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 provides building information for RNDIS for debugging.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/rndisauthorizationnotifier.iby CORE_MW_LAYER_IBY_EXPORT_PATH(rndisauthorizationnotifier.iby)
+../rom/rndisrefusalnotifier.iby CORE_MW_LAYER_IBY_EXPORT_PATH(rndisrefusalnotifier.iby)
+
+PRJ_MMPFILES
+./rndisauthorizationnotifier.mmp
+./rndisrefusalnotifier.mmp
+
+PRJ_TESTMMPFILES
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/group/rndisauthorizationnotifier.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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: definition file for RNDIS uplink authorization notifier
+*
+*/
+
+#include "../inc/rndisauthorizationnotifier.hrh"
+
+TARGET rndisauthorizationnotifier.dll
+TARGETTYPE PLUGIN
+UID 0x10009D8D KUidUplinkAuthNotifierValue
+CAPABILITY CAP_ECOM_PLUGIN
+VENDORID VID_DEFAULT
+DEFFILE rndisautherizationnotifier.def
+
+USERINCLUDE ../inc
+OS_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+
+SOURCE rndisauthorizationnotifier.cpp
+
+//Notifier resource file
+START RESOURCE ../data/rndisauthorizationnotifier.rss
+ TARGET rndisauthorizationnotifier.rsc
+END
+
+LIBRARY eiksrv.lib
+LIBRARY ecom.lib
+LIBRARY euser.lib
+
+NOEXPORTLIBRARY
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/group/rndisrefusalnotifier.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* 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: definition file for RNDIS refusal notifier
+*
+*/
+
+#include "../inc/rndisrefusalnotifier.hrh"
+
+TARGET rndisrefusalnotifier.dll
+TARGETTYPE PLUGIN
+UID 0x10009D8D KUidNetworkConnectionRefusalNotifierValue
+CAPABILITY CAP_ECOM_PLUGIN
+VENDORID VID_DEFAULT
+
+DEFFILE rndisrefusalnotifier.def
+
+USERINCLUDE ../inc
+
+OS_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+SOURCE rndisrefusalnotifier.cpp
+
+//Refusal notifier resource file
+START RESOURCE ../data/rndisrefusalnotifier.rss
+ TARGET rndisrefusalnotifier.rsc
+END
+
+LIBRARY euser.lib
+LIBRARY ecom.lib
+LIBRARY eiksrv.lib
+
+NOEXPORTLIBRARY
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/inc/rndisauthorizationnotifier.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,58 @@
+/*
+* 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: Header file for RNDIS uplink authorization notifier
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef RNDISAUTHORIZATIONNOTIFIER_H
+#define RNDISAUTHORIZATIONNOTIFIER_H
+
+#include <e32base.h> // CBase
+#include <e32std.h> // TBuf
+#include <eiknotapi.h> // For MEikSrvNotifierBase2
+
+NONSHARABLE_CLASS(CRndisAuthorizationNotifier)
+ : public CBase
+ , public MEikSrvNotifierBase2
+ {
+public:
+ // Create CRndisAuthorizationNotifier.
+ static CRndisAuthorizationNotifier* NewLC();
+ // Destructor
+ virtual ~CRndisAuthorizationNotifier();
+
+public:
+ // virtual functions from MEikSrvNotifierBase2
+ virtual void Release();
+ virtual TNotifierInfo RegisterL();
+ virtual TNotifierInfo Info() const;
+ virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
+ virtual TPtrC8 StartL(const TDesC8& aBuffer);
+ virtual void Cancel();
+ virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
+
+private:
+ CRndisAuthorizationNotifier();
+ void ConstructL();
+
+private:
+ TNotifierInfo iInfo;
+ };
+
+#endif //RNDISAUTHORIZATIONNOTIFIER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/inc/rndisauthorizationnotifier.hrh Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef RNDISAUTHORIZATIONNOTIFIER_HRH
+#define RNDISAUTHORIZATIONNOTIFIER_HRH
+
+// This is the dll plugin id.
+#define KUidUplinkAuthNotifierValue 0xA000EA56
+
+// KUidUplinkAuthNotifierImp must be equal to KUidRndisUplinkAuthorizationNotifier
+// which defined in rndisuiinterfaces.h
+#define KUidUplinkAuthNotifierImp 0x10286A44
+
+#endif //RNDISAUTHORIZATIONNOTIFIER_HRH
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/inc/rndisrefusalnotifier.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* 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: Header file for RNDIS refusal notifier
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef RNDISREFUSALNOTIFIER_H
+#define RNDISREFUSALNOTIFIER_H
+
+#include <e32base.h> // CBase
+#include <e32std.h> // TBuf
+#include <eiknotapi.h> // For MEikSrvNotifierBase2
+
+NONSHARABLE_CLASS(CRndisNetworkConnectionRefusalNotifier)
+ : public MEikSrvNotifierBase2
+/**
+RNDIS network connection refusal notifier
+*/
+ {
+public:
+ //Create CRndisNetworkConnectionRefusalNotifier.
+ static CRndisNetworkConnectionRefusalNotifier* NewLC();
+ //Destructor
+ ~CRndisNetworkConnectionRefusalNotifier();
+
+public:
+ // virtual functions from MEikSrvNotifierBase2
+ virtual void Release();
+ virtual TNotifierInfo RegisterL();
+ virtual TNotifierInfo Info() const;
+ virtual TPtrC8 StartL(const TDesC8& aBuffer);
+ virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
+ virtual void Cancel();
+ virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
+
+private:
+ CRndisNetworkConnectionRefusalNotifier();
+ void ConstructL();
+
+private:
+ TNotifierInfo iInfo;
+ };
+
+#endif //RNDISREFUSALNOTIFIER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/inc/rndisrefusalnotifier.hrh Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef RNDISREFUSALNOTIFIER_HRH
+#define RNDISREFUSALNOTIFIER_HRH
+
+// This is the dll plugin id.
+#define KUidNetworkConnectionRefusalNotifierValue 0xA000EA55
+
+// KUidNetworkConnectionRefusalNotifierImp must be equal to
+// KUidRndisNetworkConnectionRefusalNotifier which defined in rndisuiinterfaces.h
+#define KUidNetworkConnectionRefusalNotifierImp 0x10286A45
+
+#endif // RNDISREFUSALNOTIFIER_HRH
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/rom/rndisauthorizationnotifier.iby Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: RNDIS uplink authorization notifier iby file
+*
+*/
+#ifndef __RNDISAUTHORIZATIONNOTIFIER_IBY
+#define __RNDISAUTHORIZATIONNOTIFIER_IBY
+
+
+REM USB RNDIS UI notifiers ecom plug-in
+
+ECOM_PLUGIN(rndisauthorizationnotifier.dll, rndisauthorizationnotifier.rsc)
+
+#endif //__RNDISAUTHORIZATIONNOTIFIER_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/rom/rndisrefusalnotifier.iby Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,22 @@
+/*
+* 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: RNDIS refusal notifier iby file
+*
+*/
+#ifndef __RNDISREFUSALNOTIFIER_IBY
+#define __RNDISREFUSALNOTIFIER_IBY
+
+ECOM_PLUGIN(rndisrefusalnotifier.dll, rndisrefusalnotifier.rsc)
+
+#endif // __RNDISREFUSALNOTIFIER_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/rndisui/src/rndisauthorizationnotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,116 @@
+/*
+* 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: source file for RNDIS uplink authorization notifier
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+#include <rndis/rndis.h>
+#include <rndis/rndisuiinterfaces.h>
+#include "rndisauthorizationnotifier.hrh"
+#include "rndisauthorizationnotifier.h"
+
+using namespace UsbRndis;
+
+CRndisAuthorizationNotifier* CRndisAuthorizationNotifier::NewLC()
+ {
+ CRndisAuthorizationNotifier* self = new (ELeave)CRndisAuthorizationNotifier();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+CRndisAuthorizationNotifier::CRndisAuthorizationNotifier()
+ {
+ }
+
+void CRndisAuthorizationNotifier::ConstructL()
+ {
+ }
+
+CRndisAuthorizationNotifier::~CRndisAuthorizationNotifier()
+ {
+ }
+
+void CRndisAuthorizationNotifier::Release()
+ {
+ delete this;
+ }
+
+CRndisAuthorizationNotifier::TNotifierInfo CRndisAuthorizationNotifier::RegisterL()
+ {
+ //Return TNotifierInfo, describes the parameters of the notifier
+ iInfo.iUid = TUid::Uid(KUidUplinkAuthNotifierImp);
+ iInfo.iChannel = TUid::Uid(KUidUplinkAuthNotifierImp);
+ iInfo.iPriority = ENotifierPriorityHigh;
+ return iInfo;
+ }
+
+CRndisAuthorizationNotifier::TNotifierInfo CRndisAuthorizationNotifier::Info() const
+ {
+ //Return TNotifierInfo, describes the parameters of the notifier
+ return iInfo;
+ }
+
+TPtrC8 CRndisAuthorizationNotifier::StartL(const TDesC8& /*aBuffer*/)
+ {
+ // Do not support synchronous start, just return.
+ return KNullDesC8();
+ }
+
+void CRndisAuthorizationNotifier::StartL(const TDesC8& /*aBuffer*/, TInt aReplySlot, const RMessagePtr2& aMessage)
+ {
+ // Just to set as DisAllow defaultly ..
+ TRndisUplinkAuthorizationResultPckg selection(ERndisDisallowUplinkAccess);
+ aMessage.Write(aReplySlot, selection);
+ aMessage.Complete(KErrNone);
+ }
+
+void CRndisAuthorizationNotifier::Cancel()
+ {
+ }
+
+TPtrC8 CRndisAuthorizationNotifier::UpdateL(const TDesC8&)
+ {
+ // Do not support update, just return.
+ return KNullDesC8();
+ }
+
+CArrayPtr<MEikSrvNotifierBase2>* NotifierArrayL()
+ {
+ CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = new(ELeave) CArrayPtrFlat<MEikSrvNotifierBase2>(1);
+ CleanupStack::PushL(notifiers);
+ CRndisAuthorizationNotifier* notifier = CRndisAuthorizationNotifier::NewLC();
+ notifiers->AppendL(notifier);
+ CleanupStack::Pop(2, notifiers);
+ return notifiers;
+ }
+
+// ECom plugin entry point
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(KUidUplinkAuthNotifierImp, NotifierArrayL)
+ };
+
+// ECom plugin entry point
+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/usbuis/rndisui/src/rndisrefusalnotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,109 @@
+/*
+* 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: Source file for RNDIS refusal notifier
+*
+*/
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+#include <rndis/rndisuiinterfaces.h>
+#include "rndisrefusalnotifier.hrh"
+#include "rndisrefusalnotifier.h"
+
+using namespace UsbRndis;
+
+//Number of notifier needed.
+const TInt KNotfierCount = 1;
+
+CRndisNetworkConnectionRefusalNotifier* CRndisNetworkConnectionRefusalNotifier::NewLC()
+ {
+ CRndisNetworkConnectionRefusalNotifier* self = new (ELeave) CRndisNetworkConnectionRefusalNotifier;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+CRndisNetworkConnectionRefusalNotifier::CRndisNetworkConnectionRefusalNotifier()
+ {
+ }
+
+CRndisNetworkConnectionRefusalNotifier::~CRndisNetworkConnectionRefusalNotifier()
+ {
+ }
+
+void CRndisNetworkConnectionRefusalNotifier::ConstructL()
+ {
+ }
+
+void CRndisNetworkConnectionRefusalNotifier::Release()
+ {
+ delete this;
+ }
+
+MEikSrvNotifierBase2::TNotifierInfo CRndisNetworkConnectionRefusalNotifier::RegisterL()
+ {
+ iInfo.iUid=TUid::Uid(KUidNetworkConnectionRefusalNotifierImp);
+ iInfo.iChannel = TUid::Uid(KUidNetworkConnectionRefusalNotifierImp);
+ iInfo.iPriority=ENotifierPriorityHigh;
+ return iInfo;
+ }
+
+MEikSrvNotifierBase2::TNotifierInfo CRndisNetworkConnectionRefusalNotifier::Info() const
+ {
+ return iInfo;
+ }
+
+TPtrC8 CRndisNetworkConnectionRefusalNotifier::StartL(const TDesC8& aBuffer)
+ {
+ return aBuffer;
+ }
+
+void CRndisNetworkConnectionRefusalNotifier::StartL(const TDesC8& /*aBuffer*/, TInt /*aReplySlot*/, const RMessagePtr2& aMessage)
+ {
+ aMessage.Complete(KErrNone);
+ }
+
+void CRndisNetworkConnectionRefusalNotifier::Cancel()
+ {
+ }
+
+TPtrC8 CRndisNetworkConnectionRefusalNotifier::UpdateL(const TDesC8& aBuffer)
+ {
+ return aBuffer;
+ }
+
+CArrayPtr<MEikSrvNotifierBase2>* NotifierArrayL()
+ {
+ CArrayPtr<MEikSrvNotifierBase2>* array = new(ELeave) CArrayPtrFlat<MEikSrvNotifierBase2>(KNotfierCount);
+ CleanupStack::PushL(array);
+ array->AppendL(CRndisNetworkConnectionRefusalNotifier::NewLC());
+ CleanupStack::Pop(2, array);
+ return array;
+ }
+
+// ECom plugin entry point
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(KUidNetworkConnectionRefusalNotifierImp, NotifierArrayL)
+ };
+
+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/usbuis/usbui/USBClassChangeUIPlugin/data/1020E472.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,442 @@
+/*
+* 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 "));
+ 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 EEventPanningStarted:
+ case EEventPanningStopped:
+ case EEventFlickStarted:
+ case EEventFlickStopped:
+ case EEventPenDownOnItem:
+ case EEventItemDraggingActioned:
+ {
+ ShowPopUpsL (CurrentItemIndex()) ;
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+*
+*/
+
+//
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/help/rom/usbuihelps_variant.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/EABI/USBUiApiTestU.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/conf/ui_USBUiApiTest.cfg Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,238 @@
+// USB UI tests - total 14 tc
+/////////////////////
+//Ovi->MS
+[Test]
+title Change USB Connection Ovi Suite to MS Manual/KeyDown
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+
+[Test]
+title Change USB Connection Ovi Suite to MS Manual/KeyUp
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow
+pause 500
+presskey global EKeyUpArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyUpArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest USB_CONN_MODE OFF MTP
+delete tester
+[Endtest]
+
+[Test]
+title Change USB Connection Ovi Suite to MTP Manual/KeyDown
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+pause 500
+presskey global EKeyDownArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF MS
+tester TurnLightsOn
+pause 4000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest USB_CONN_MODE OFF PCSUITE
+delete tester
+[Endtest]
+/////////////////////////
+//MS->MTP
+[Test]
+title Change USB Connection MS to MTP Manual
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF MS
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+pause 500
+presskey global EKeyDownArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF MTP
+tester TurnLightsOn
+pause 4000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF MTP
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF MS
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+pause 500
+presskey global EKeyDownArrow
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF MTP
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester 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 LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDownArrow
+presskey global EKeyDevice0
+pause 2000
+presskey global EKeyEnter
+pause 1000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest USB_CONN_MODE OFF MS
+delete tester
+[Endtest]
+/////////////////////////
+//Exit
+[Test]
+title USB Application Cancelled/Device Key 1 Exit
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//Cancel
+[Test]
+title USB Application Cancelled/Options Menu Exit
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDevice0
+pause 500
+presskey global EKeyDownArrow
+presskey global EKeyDownArrow
+presskey global EKeyEnter
+pause 2000
+tester FinishTest CANCELLED
+delete tester
+[Endtest]
+/////////////////////////
+//Help
+[Test]
+title USB Application Cancelled/Help Option Entered/Options Menu Exit
+create USBUiApiTest tester
+tester LaunchUsbUiApp OFF PCSUITE
+tester TurnLightsOn
+pause 4000
+presskey global EKeyDevice0
+pause 500
+presskey global EKeyDownArrow
+pause 500
+presskey global EKeyEnter
+pause 5000
+presskey global EKeyDevice1
+pause 2000
+presskey global EKeyDevice1
+pause 2000
+tester FinishTest CANCELLED
+delete tester
+[Endtest]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/group/USBUiApiTest.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,52 @@
+/*TYPE TESTCLASS*//*
+* 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
+*
+*/
+
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+;
+;
+; Installation file for STIF
+;
+
+; 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\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 Thu Dec 17 09:14:30 2009 +0200
@@ -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:
+;
+;
+; Installation file for STIF
+;
+
+; 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\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
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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
+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.bat Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,19 @@
+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 abld test build armv5
+call makesis USBUiApiTest.pkg
+call signsis USBUiApiTest.sis USBUiApiTest.sisx rd.cer rd-key.pem
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/group/build_sis_phone.bat Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,24 @@
+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 rd.cer rd-key.pem
+del USBUiApiTest_phone.sis
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/inc/USBUiApiTest.h Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,255 @@
+/*
+* 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 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
+
+#ifdef STIF_LOG
+#undef STIF_LOG
+#endif
+
+#define STIF_LOG( s )\
+ {\
+ TBuf<KMaxLogData> traceBuf;\
+ traceBuf.Append( _L( "[STIF_LOG] " ) );\
+ traceBuf.Append( _L( s ) );\
+ iLog->Log( _L( s ) );\
+ RDebug::Print( traceBuf );\
+ }
+
+#define STIF_LOG1( s, v ) \
+ {\
+ TBuf<KMaxLogData> traceBuf;\
+ traceBuf.Append( _L( "[STIF_LOG] " ) );\
+ traceBuf.Append( _L( s ) );\
+ iLog->Log( _L( s ), v );\
+ RDebug::Print( traceBuf, v );\
+ }
+
+#define STIF_LOG2( s, v1, v2 ) \
+ {\
+ TBuf<KMaxLogData> traceBuf;\
+ traceBuf.Append( _L( "[STIF_LOG] " ) );\
+ traceBuf.Append( _L( s ) );\
+ iLog->Log( _L( s ), v1, v2 );\
+ RDebug::Print( traceBuf, v1, v2 );\
+ }
+
+#define STIF_LOG3( s, v1, v2, v3 ) \
+ {\
+ TBuf<KMaxLogData> traceBuf;\
+ traceBuf.Append( _L( "[STIF_LOG] " ) );\
+ traceBuf.Append( _L( s ) );\
+ iLog->Log( _L( s ), v1, v2, v3 );\
+ RDebug::Print( traceBuf, v1, v2, v3 );\
+ }
+
+
+// Logging path
+#ifndef ATS
+_LIT( KUSBUiApiTestLogPath, "\\logs\\testframework\\usb\\" );
+#else
+_LIT( KUSBUiApiTestLogPath, "e:\\testing\\stiflogs\\" );
+#endif
+// 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 TUSBAppTestOption
+ {
+ EAppCancelled = 0,
+ EAskOnConnectionSettingChanged,//1
+ EUsbConnectionModeSettingChanged//2
+ };
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+* 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 LaunchUsbUiApp( CStifItemParser& aItem );
+ virtual TInt FinishTest( CStifItemParser& aItem );
+
+ /**
+ * Method used to log version of test class
+ */
+ void SendTestClassVersion();
+
+ //ADD NEW METHOD DEC HERE
+ //[TestMethods] - Do not remove
+ 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( CStifItemParser& aItem );
+
+ public: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ protected: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ private: // Data
+
+ 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;
+
+ };
+
+#endif // USBUIAPITEST_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbui/tsrc/USBUiApiTest/init/USBUiApiTest.ini Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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= XXXXXXXXX
+# 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 testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,218 @@
+#
+# 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\usb\
+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= XXXXXXXXX
+# 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 testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX 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 Thu Dec 17 09:14:30 2009 +0200
@@ -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: ?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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,493 @@
+/*
+* 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 "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[] =
+ {
+ // Copy this line for every implemented function.
+ // First string is the function name used in TestScripter script file.
+ // Second is the actual implementation member function.
+ ENTRY( "LaunchUsbUiApp", CUSBUiApiTest::LaunchUsbUiApp ),
+ ENTRY( "FinishTest", CUSBUiApiTest::FinishTest ),
+ ENTRY( "TurnLightsOn", CUSBUiApiTest::TurnLightsOn ),
+ //ADD NEW ENTRY HERE
+ // [test cases entries] - Do not remove
+
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::LaunchUsbUiApp
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::LaunchUsbUiApp( CStifItemParser& aItem )
+ {
+ TInt res;
+ TPtrC testAskOnConnectionSettingName( KNullDesC );
+ TPtrC testUsbPersonalityName( KNullDesC );
+ TInt testAskOnConnectionSetting;
+ TInt testUsbPersonalityId;
+
+ res = aItem.GetString( _L( "LaunchUsbUiApp" ), testAskOnConnectionSettingName );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ //STIF_LOG("aItem.GetString testAskOnConnectionSettingName OK");
+
+ res = GetAskOnConnectionOptionFromString( testAskOnConnectionSettingName, testAskOnConnectionSetting );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetAskOnConnectionOptionFromString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ //STIF_LOG1("GetAskOnConnectionOptionFromString OK: %d", testAskOnConnectionSetting);
+
+ res = aItem.GetNextString( testUsbPersonalityName );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetNextString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ //STIF_LOG("aItem.GetNextString testUsbPersonalityName OK");
+
+ res = GetUsbPersonalityOptionFromString( testUsbPersonalityName, testUsbPersonalityId );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetUsbPersonalityOptionFromString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ //STIF_LOG1("GetUsbPersonalityOptionFromString OK: %d",testUsbPersonalityId);
+
+ res = GetUsbSettings( iUsbPersonalityBackup, iAskOnConnectionSettingBackup );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("Failed to backup usb settings with value: %d"), res );
+ return res;
+ }
+ STIF_LOG2("GetUsbSettings OK: %d, %d", iUsbPersonalityBackup, iAskOnConnectionSettingBackup);
+
+ res = SetUsbSettings( testUsbPersonalityId, testAskOnConnectionSetting );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("Changing usb settings failed with value (cenrep): %d"), res );
+ return res;
+ }
+ STIF_LOG2("SetUsbSettings OK: %d, %d", testUsbPersonalityId, testAskOnConnectionSetting);
+
+ iCommandLine->SetCommandL( EApaCommandRun );
+ iCommandLine->SetExecutableNameL( KUsbAppFileName );
+
+ res = iApaLsSession.Connect();
+ if ( res != KErrNone )
+ {
+ iLog->Log( _L("Connecting to application server failed with value: %d"), res );
+ return res;
+ }
+ STIF_LOG("iApaLsSession.Connect OK");
+
+ res = iApaLsSession.StartApp( *iCommandLine );
+ if ( res != KErrNone )
+ {
+ iLog->Log( _L("Starting application failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG("iApaLsSession.StartApp OK");
+
+ if ( !IsUsbAppRunning() )
+ {
+ iLog->Log( _L("Usb application launch error") );
+ iApaLsSession.Close();
+ return KErrGeneral;
+ }
+ STIF_LOG("IsUsbAppRunning OK");
+
+ iLog->Log( _L("Usb application started") );
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::FinishTest
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::FinishTest( CStifItemParser& aItem )
+ {
+ TInt res;
+ TPtrC optionName( KNullDesC );
+ TUSBAppTestOption option;
+ TBool isAppRunning;
+ TPtrC expectedAskOnConnectionSettingName( KNullDesC );
+ TPtrC expectedPersonalityIdSettingName( KNullDesC );
+ TInt actualAskOnConnectionSetting;
+ TInt expectedAskOnConnectionSetting;
+ TInt actualPersonalityIdSetting;
+ TInt expectedPersonalityIdSetting;
+
+ res = aItem.GetString( _L( "FinishTest" ), optionName );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG("aItem.GetString optionName OK");
+
+ res = GetTestOption( optionName, option );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetTestOption failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG1("GetTestOption OK: %d",option);
+
+ if ( option == EAskOnConnectionSettingChanged || option == EUsbConnectionModeSettingChanged )
+ {
+ res = aItem.GetNextString( expectedAskOnConnectionSettingName );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetNextString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG("aItem.GetNextString expectedAskOnConnectionSettingName OK");
+
+ res = GetAskOnConnectionOptionFromString( expectedAskOnConnectionSettingName, expectedAskOnConnectionSetting );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetAskOnConnectionOptionFromString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG1("GetAskOnConnectionOptionFromString OK: %d", expectedAskOnConnectionSetting);
+
+ res = aItem.GetNextString( expectedPersonalityIdSettingName );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetNextString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG("aItem.GetNextString expectedPersonalityIdSettingName OK");
+
+ res = GetUsbPersonalityOptionFromString( expectedPersonalityIdSettingName, expectedPersonalityIdSetting );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("GetUsbPersonalityOptionFromString failed with value: %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG1("GetUsbPersonalityOptionFromString OK %d", expectedPersonalityIdSetting);
+ }
+
+ isAppRunning = IsUsbAppRunning();
+
+ res = GetUsbSettings( actualPersonalityIdSetting, actualAskOnConnectionSetting );
+ if ( res != KErrNone )
+ {
+ iLog -> Log( _L("Getting usb settings failed with value (cenrep): %d"), res );
+ iApaLsSession.Close();
+ return res;
+ }
+ STIF_LOG2("GetUsbSettings OK: %d, %d", actualPersonalityIdSetting, actualAskOnConnectionSetting);
+
+ res = SetUsbSettings( iUsbPersonalityBackup, iAskOnConnectionSettingBackup );
+ if ( res != KErrNone )
+ iLog -> Log( _L("Failed to restore original usb settings!") );
+ STIF_LOG2("SetUsbSettings OK: %d, %d", iUsbPersonalityBackup, iAskOnConnectionSettingBackup);
+
+ iApaLsSession.Close();
+
+ switch( option )
+ {
+ case EAskOnConnectionSettingChanged:
+ case EUsbConnectionModeSettingChanged:
+ iLog -> Log( _L("Actual USB ask on connection setting value: %d, expected: %d"), actualAskOnConnectionSetting, expectedAskOnConnectionSetting );
+ STIF_ASSERT_EQUALS( expectedAskOnConnectionSetting, actualAskOnConnectionSetting );
+ iLog -> Log( _L("Actual USB personality setting value: %d, expected: %d"), actualPersonalityIdSetting, expectedPersonalityIdSetting );
+ STIF_ASSERT_EQUALS( expectedPersonalityIdSetting, actualPersonalityIdSetting );
+ iLog -> Log( _L("USB app is running: %d, expected: %d"), isAppRunning, EFalse );
+ STIF_ASSERT_FALSE( isAppRunning );
+ break;
+ case EAppCancelled:
+ iLog -> Log( _L("USB app is running: %d, expected: %d"), isAppRunning, EFalse );
+ STIF_ASSERT_FALSE( isAppRunning );
+ break;
+ default:
+ return KErrNotFound;
+ }
+
+ iLog -> Log( _L("Test case passed!") );
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CUSBUiApiTest::FinishTest
+// -----------------------------------------------------------------------------
+
+TInt CUSBUiApiTest::GetTestOption( TPtrC aOptionString, TUSBAppTestOption& aOption )
+ {
+ if ( !aOptionString.Compare( _L( "USB_CONN_MODE" ) ) )
+ {
+ aOption = EUsbConnectionModeSettingChanged;
+ iLog -> Log( _L("Test type: EUsbConnectionModeSettingChanged") );
+ }
+ else if ( !aOptionString.Compare( _L( "ASK_ON_CONN" ) ) )
+ {
+ aOption = EAskOnConnectionSettingChanged;
+ iLog -> Log( _L("Test type: EAskOnConnectionSettingChanged") );
+ }
+ else if ( !aOptionString.Compare( _L( "CANCELLED" ) ) )
+ {
+ aOption = EAppCancelled;
+ iLog -> Log( _L("Test type: EAppCancelled") );
+ }
+ else
+ {
+ iLog -> Log( _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;
+ iLog -> Log( _L("Ask on connection option: ON") );
+ }
+ else if ( !aOptionString.Compare( _L( "OFF" ) ) )
+ {
+ aOption = KUsbWatcherChangeOnConnectionOff;
+ iLog -> Log( _L("Ask on connection option: OFF") );
+ }
+ else
+ {
+ iLog -> Log( _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;
+ iLog -> Log( _L("Usb personality option: KUsbPersonalityIdPCSuiteMTP") );
+ }
+ else if ( !aOptionString.Compare( _L( "MS" ) ) )
+ {
+ aOption = KUsbPersonalityIdMS;
+ iLog -> Log( _L("Usb personality option: KUsbPersonalityIdMS") );
+ }
+ else if ( !aOptionString.Compare( _L( "PTP" ) ) )
+ {
+ aOption = KUsbPersonalityIdPTP;
+ iLog -> Log( _L("Usb personality option: KUsbPersonalityIdPTP") );
+ }
+ else if ( !aOptionString.Compare( _L( "MTP" ) ) )
+ {
+ aOption = KUsbPersonalityIdMTP;
+ iLog -> Log( _L("Usb personality option: KUsbPersonalityIdMTP") );
+ }
+ else
+ {
+ iLog -> Log( _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( CStifItemParser& aItem )
+ {
+ TInt res;
+ res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
+ 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/usbuinotifu.def Thu Dec 17 09:14:30 2009 +0200
@@ -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/EABI/usbuinotifu.def Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z13NotifierArrayv @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/data/102068DC.rss Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,265 @@
+/*
+* 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_supported {
+ buf = qtn_usb_otg_warning_partial_supported; }
+
+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; }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/group/bld.inf Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* 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
+usbavkonnotif.mmp
+
+PRJ_TESTMMPFILES
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/group/usbavkonnotif.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,61 @@
+/*
+ * 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: Project definition file for project USBUINotif.
+ *
+ */
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh> //this is needed for RESOURCE_FILES_DIR
+
+TARGET usbavkonnotif.dll
+TARGETTYPE dll
+UID 0x101fdfae 0x102068DD
+TARGETPATH SHARED_LIB_DIR
+
+CAPABILITY CAP_GENERAL_DLL
+VENDORID VID_DEFAULT
+
+SOURCEPATH ../src
+
+SOURCE usbuincableconnectednotifier.cpp usbavkonmain.cpp
+SOURCE usbnotifier.cpp
+
+USERINCLUDE ../inc
+
+SYSTEMINCLUDE ../../inc ../../../inc MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/) //for internal and private API headers
+
+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 aknmemorycardui.lib // for unlocking the MMC
+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
+
+DEBUGLIBRARY flogger.lib // File logging services
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/group/usbuinotif.mmp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* 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: 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 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
+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 aknmemorycardui.lib // for unlocking the MMC
+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
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,125 @@
+/*
+ * 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 <aknlistquerydialog.h>
+#include <AknQueryDialog.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 MEikCommandObserver
+ {
+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);
+
+ /**
+ * Handles the command on USB connected note
+ */
+ void ProcessCommandL(TInt aCommandId);
+
+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
+ * @param aDescription The returned current personality string.
+ * @param aHeader The header string for message query.
+ */
+ void GetPersonalityStringL(HBufC*& aHeader,HBufC*& aDescription );
+
+ /**
+ * Runs the connected discreet note
+ */
+ void RunQueryL();
+
+
+ /**
+ * creates the USB UI setting view
+ * @param aProcessName The process name (USBClassChangeUI.exe)
+ * @param TUidType
+ */
+ void CreateChosenViewL(const TDesC & aProcessName,const TUidType & aUidType) const;
+private:
+ /**
+ * C++ default constructor.
+ */
+ CUSBUICableConnectedNotifier();
+
+ };
+#endif // USBUINCABLECONNECTEDNOTIFIER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotif.hrh Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 UI Queries notifier.
+ *
+ */
+
+#ifndef USBUINQUERIESNOTIFIER_H
+#define USBUINQUERIESNOTIFIER_H
+
+// INCLUDES
+
+#include "usbnotifier.h" // Base class
+#include <aknquerydialog.h> // AVKON component
+#include <aknmemorycarddialog.h>
+
+// CLASS DECLARATION
+
+/**
+ * This class is used to show USB query dialogs.
+ *
+ * @lib
+ */
+NONSHARABLE_CLASS(CUSBUIQueriesNotifier) : public CUSBUINotifierBase,
+ public MAknMemoryCardDialogObserver
+ {
+public:
+ // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static CUSBUIQueriesNotifier* NewL();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUSBUIQueriesNotifier();
+
+public:
+ // from MAknMemoryCardDialogObserver
+
+ /**
+ * To be notified when unlock completed
+ * @param TInt aResult
+ * @return void
+ */
+ void UnlockComplete(TInt aResult);
+
+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
+
+ /**
+ * Unlock the locked memory card
+ * First inform user that the memory card is locked and then show the
+ * memory card dialog for unlocking.
+ * @param aStringHolder The string for the query.
+ * @param aCoverDialogId The dialog ID for the cover UI.
+ * @return KErrNone - user accepted, KErrCancel - End call key pressed
+ */
+ TInt UnlockMemoryCardL(const TDesC& aStringHolder, TInt aCoverDialogId);
+
+ /**
+ * 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
+ // Used for possible Cancel while the dialog is showing
+ CAknMemoryCardDialog* iMemoryCardDialog;
+
+ };
+#endif // USBUINQUERIESNOTIFIER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h Thu Dec 17 09:14:30 2009 +0200
@@ -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);
+
+ /**
+ * 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
+
+ /**
+ * 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,144 @@
+/*
+* 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"
+
+// End of USB_OTG
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/rom/usbuinotif.iby Thu Dec 17 09:14:30 2009 +0200
@@ -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: 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)
+file=ABI_DIR\BUILD_DIR\usbavkonnotif.dll SHARED_LIB_DIR\usbavkonnotif.dll
+
+#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 Thu Dec 17 09:14:30 2009 +0200
@@ -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/usbavkonmain.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,96 @@
+/*
+ * 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: Methods for USB UI notifiers.
+ *
+ */
+
+// INCLUDE FILES
+#include <EikNotApi.h>
+#include <eikenv.h>
+
+#include "usbuincableconnectednotifier.h"
+#include "usbuinqueriesnotifier.h"
+#include "usbuinotifdebug.h"
+
+// CONSTANTS
+const TInt KUSBUINotifierArrayIncrement = 1;
+
+
+// ================= EXPORTED FUNCTIONS =======================================
+
+// ----------------------------------------------------------------------------
+//
+// Instantiate notifiers
+//
+// ----------------------------------------------------------------------------
+
+LOCAL_C void CreateUSBUINotifiersL(
+ CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers )
+ {
+ FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
+
+ CUSBUICableConnectedNotifier* cableConnectedNotifier =
+ CUSBUICableConnectedNotifier::NewL();
+ CleanupStack::PushL( cableConnectedNotifier );
+ aNotifiers->AppendL( cableConnectedNotifier );
+ CleanupStack::Pop( cableConnectedNotifier );
+
+
+ FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
+ }
+
+// ----------------------------------------------------------------------------
+//
+// Lib main entry point: Creates a notifiers array.
+//
+// ----------------------------------------------------------------------------
+
+EXPORT_C 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;
+ }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbnotifier.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,276 @@
+/*
+ * 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 <aknsutils.h>
+#include <usb.h>
+#include <USBUINotif.rsg> // Own resources
+#include <centralrepository.h>
+#include <e32property.h>
+//for loading icons USB fork and empty
+#include <akniconarray.h>
+#include <avkon.mbg>
+#include <AknsConstants.h>
+#include <aknmessagequerydialog.h>
+//for cover display support
+#include <aknmediatorfacade.h>
+#include <secondarydisplay/USBUINotifSecondaryDisplay.h> // Dialog index for cover UI
+#include <akndiscreetpopup.h>
+#include <e32uid.h> // KExecutableImageUid
+#include <usbui.mbg>
+#include "usbuincableconnectednotifier.h" // Own class definition
+#include "usbuinotifdebug.h" // Debugging macros
+#include "usbwatcherinternalcrkeys.h"
+#include "usbpersonalityids.h"
+#include "usbuinotif.hrh"
+
+// Literals
+
+_LIT(KUSBExe, "usbclasschangeui.exe");
+const TInt KUSBUIUid = 0x102068E2;
+_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();
+ 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() "));
+
+ CompleteMessage(KErrCancel);
+ CUSBUINotifierBase::Cancel();
+
+ FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::Cancel() completed"));
+ }
+
+// -----------------------------------------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::GetPersonalityStringL
+// Get the strings for ask on connection message query
+// -----------------------------------------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::GetPersonalityStringL(
+ 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);
+
+ aHeader = StringLoader::LoadL(R_USB_MODE_MSG_HEADER);
+
+ 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()"));
+
+ HBufC* header = NULL;
+ HBufC* description =NULL;
+ GetPersonalityStringL(header, description);
+
+ CleanupStack::PushL(header);
+ CleanupStack::PushL(description);
+
+ TFileName usbUiIconFilename( KFileDrive );
+ usbUiIconFilename += KDC_APP_BITMAP_DIR;
+ usbUiIconFilename += KUSBUIconFileName;
+ CAknDiscreetPopup::ShowGlobalPopupL(*header,*description, KAknsIIDQgnPropUsb, AknIconUtils::AvkonIconFileName(),
+ EMbmAvkonQgn_prop_usb, EMbmAvkonQgn_prop_usb_mask,KAknDiscreetPopupDurationLong, EUSBUICmdDiscreetTapped,( MEikCommandObserver* ) this);
+
+ CompleteMessage(KErrCancel);
+ CleanupStack::PopAndDestroy(description);
+ CleanupStack::PopAndDestroy(header);
+
+ 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
+ repository->Get(KUsbWatcherPersonality, aCurrentPersonality);
+ CleanupStack::PopAndDestroy(repository);
+ FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetCurrentIdL completed"));
+ }
+
+// ----------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::ProcessCommandL()
+// when discreet pop up is tapped the command will be handled here
+// ----------------------------------------------------------------------------
+//
+void CUSBUICableConnectedNotifier::ProcessCommandL(TInt aCommandId)
+ {
+ switch ( aCommandId )
+ {
+ case EUSBUICmdDiscreetTapped:
+ {
+ TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00),TUid::Uid(KUSBUIUid));
+ CreateChosenViewL(KUSBExe(),uidtype);
+ }
+ break;
+ default:
+
+ break;
+ }
+ }
+// ---------------------------------------------------------------------------
+// CUSBUICableConnectedNotifier::CreateChosenViewL()
+// creates the USB UI setting view
+// ---------------------------------------------------------------------------
+//
+ void CUSBUICableConnectedNotifier::CreateChosenViewL(const TDesC & aProcessName,const TUidType & aUidType) const
+ {
+ FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::CreateDesiredViewL() "));
+ RProcess usbUiProcess;
+ User::LeaveIfError(usbUiProcess.Create(aProcessName, KNullDesC, aUidType));
+ usbUiProcess.Resume();
+ usbUiProcess.Close();
+ FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::CreateDesiredViewL() "));
+
+ }
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinmain.cpp Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,146 @@
+/*
+ * 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: Methods for USB UI notifiers
+ *
+ */
+
+// INCLUDE FILES
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include <EikNotApi.h>
+#include <eikenv.h>
+#include <AknNotifierWrapper.h>
+#include <usbuinotif.h>
+
+#include "usbuincableconnectednotifier.h"
+#include "usbuinqueriesnotifier.h"
+
+
+#include "usbuinotifdebug.h"
+#include "usbuinotifotgwarning.h"
+#include "usbuinotifotgerror.h"
+#include "usbuinotifmsmmerror.h"
+
+// CONSTANTS
+const TInt KUSBUINotifierArrayIncrement = 4;
+_LIT( KUSBUINotifdll, "usbavkonnotif.dll" );
+// ================= EXPORTED FUNCTIONS =======================================
+// ----------------------------------------------------------------------------
+//
+// Instantiate notifiers
+//
+// ----------------------------------------------------------------------------
+
+void CreateUSBUINotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
+ {
+ FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
+
+ /* The CableconnectionNotifier is created on the Avkon Wrapper
+ * because it contains the discreet popups which are only possible
+ * to be launched in a UI framework
+ */
+ CAknCommonNotifierWrapper* master =
+ CAknCommonNotifierWrapper::NewL(KCableConnectedNotifierUid,
+ KCableConnectedNotifierUid,
+ MEikSrvNotifierBase2::ENotifierPriorityVHigh,
+ KUSBUINotifdll,
+ 1); // no synchronous reply used.
+ CleanupStack::PushL(master);
+
+ aNotifiers->AppendL(master );
+ CleanupStack::Pop( master );
+ 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[] =
+ {
+#ifdef __EABI__
+ {{0x10281F23},(TFuncPtr)NotifierArray},
+#else
+ {{0x10281F23},NotifierArray},
+#endif
+ };
+
+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 Thu Dec 17 09:14:30 2009 +0200
@@ -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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,199 @@
+/*
+* 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);
+ }
+
+// ----------------------------------------------------------------------------
+// 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 );
+ }
+
+ iMessage = aMessage;
+ iNeedToCompleteMessage = ETrue;
+ iReplySlot = aReplySlot;
+
+ // Get parameters
+ //
+ iErrorId = 0;
+ TPckgC<TInt> pckg( iErrorId );
+ pckg.Set( aBuffer );
+ iErrorId = pckg();
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 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_SUPPORTED);
+ }
+
+// ----------------------------------------------------------------------------
+// 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 );
+ }
+
+ iMessage = aMessage;
+ iNeedToCompleteMessage = ETrue;
+ iReplySlot = aReplySlot;
+
+ // Get parameters
+ //
+ TPckgC<TInt> pckg( iNoteId );
+ pckg.Set( aBuffer );
+ iNoteId = pckg();
+
+ 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 Thu Dec 17 09:14:30 2009 +0200
@@ -0,0 +1,314 @@
+/*
+ * 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;
+ TInt returnValue = KErrNone;
+ // for cover display support
+ TInt coverDialogId = EUSBCoverInvalidDialogId;
+
+ // Choose text and other query attributes
+ //
+ HBufC* stringHolder = GetQueryAttributesLC( coverDialogId, isCancelKey );
+
+ //check if query text string loading was successful
+ if (NULL != stringHolder)
+ {
+ DisableKeylock();
+ SuppressAppSwitching( ETrue );
+ returnValue = QueryUserResponseL( *stringHolder, coverDialogId,
+ isCancelKey );
+ 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)
+ {
+ FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL"));
+ TInt returnValue = KErrNone;
+
+ iUSBQueryDlg = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
+
+ // Show dialog with or without the Cancel
+ //
+ 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)
+ {
+ FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC"));
+ HBufC* stringHolder = NULL; // The text for the query
+ aIsCancelKey = 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;
+ }
+ 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