usbmgmt/usbmgr/usbman/server/SRC/CUsbDevice.cpp
author hgs
Thu, 16 Sep 2010 12:03:29 +0800
changeset 49 93c0009bd947
parent 48 21625e5de155
permissions -rw-r--r--
201036_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
     2
* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* Implements the main object of Usbman that manages all the USB Classes
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
* and the USB Logical Device (via CUsbDeviceStateWatcher).
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
 @file
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <cusbclasscontrolleriterator.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <cusbclasscontrollerbase.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <cusbclasscontrollerplugin.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <bafl/sysutil.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <e32svr.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <e32base.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <e32std.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <f32file.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <barsc.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <barsread.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include <bautils.h>
48
21625e5de155 201035_01
hgs
parents: 29
diff changeset
    34
#ifndef __DUMMY_LDD__
21625e5de155 201035_01
hgs
parents: 29
diff changeset
    35
#include <cusbmanextensionplugin.h>
21625e5de155 201035_01
hgs
parents: 29
diff changeset
    36
#else
21625e5de155 201035_01
hgs
parents: 29
diff changeset
    37
#include <cusbmanextensionplugindummy.h>
21625e5de155 201035_01
hgs
parents: 29
diff changeset
    38
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include <e32property.h> //Publish & Subscribe header
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    40
#ifdef USE_DUMMY_CLASS_CONTROLLER
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    41
#include "CUsbDummyClassController.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    42
#endif
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    43
#include "MUsbDeviceNotify.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    44
#include "UsbSettings.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    45
#include "CUsbServer.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    46
#include "UsbUtils.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    47
#include "CUsbDevice.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    48
#include "CUsbDeviceStateWatcher.h"
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
    49
#include "cusbchargingporttypewatcher.h"
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include "CPersonality.h"
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    51
#include "usbmancenrepmanager.h"
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
    52
#include "usbmanprivatecrkeys.h"
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    54
#include "OstTraceDefinitions.h"
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    55
#ifdef OST_TRACE_COMPILER_IN_USE
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    56
#include "CUsbDeviceTraces.h"
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    57
#endif
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    58
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    59
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
_LIT(KUsbLDDName, "eusbc"); //Name used in call to User::LoadLogicalDevice
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
_LIT(KUsbLDDFreeName, "Usbc"); //Name used in call to User::FreeLogicalDevice
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// Panic category only used in debug builds
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
#ifdef _DEBUG
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
_LIT(KUsbDevicePanicCategory, "UsbDevice");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
#endif
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
 * Panic codes for the USB Device Class
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
enum TUsbDevicePanic
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
	/** Class called while in an illegal state */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
	EBadAsynchronousCall = 0,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
	EConfigurationError,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
	EResourceFileNotFound,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
	/** ConvertUidsL called with an array that is not empty */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
	EUidArrayNotEmpty,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
	};
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
CUsbDevice* CUsbDevice::NewL(CUsbServer& aUsbServer)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
 * Constructs a CUsbDevice object.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
 * @return	A new CUsbDevice object
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    90
    OstTraceFunctionEntry0( CUSBDEVICE_NEWL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
	CUsbDevice* r = new (ELeave) CUsbDevice(aUsbServer);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
	CleanupStack::PushL(r);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	r->ConstructL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	CleanupStack::Pop(r);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
    96
	OstTraceFunctionExit0( CUSBDEVICE_NEWL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
	return r;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
CUsbDevice::~CUsbDevice()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
 * Destructor.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   106
    OstTraceFunctionEntry0( CUSBDEVICE_CUSBDEVICE_DES_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
	// Cancel any outstanding asynchronous operation.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
	Cancel();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
	delete iUsbClassControllerIterator;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	iSupportedClasses.ResetAndDestroy();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
	iSupportedPersonalities.ResetAndDestroy();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	iSupportedClassUids.Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	iExtensionPlugins.ResetAndDestroy();
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   117
	
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   118
	delete iCenRepManager;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   119
	
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   120
	delete  iDeviceConfiguration.iManufacturerName;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   121
	delete  iDeviceConfiguration.iProductName;  
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
	if(iEcom)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
		iEcom->Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
	REComSession::FinalClose();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
	// Free any memory allocated to the list of observers. Note that
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
	// we don't want to call ResetAndDestroy, because we don't own
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	// the observers themselves.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
	iObservers.Reset();
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   131
#ifdef SYMBIAN_USB_BATTERYCHARGING_V1_1	
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   132
	iChargingObservers.Reset();
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   133
	delete iChargerTypeWatcher;
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   134
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   136
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
#ifndef __WINS__
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   138
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_CUSBDEVICE, "CUsbDevice::~CUsbDevice;about to delete device state watcher @ %08x", (TUint32)iDeviceStateWatcher );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   139
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
	delete iDeviceStateWatcher;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   141
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CUSBDEVICE_DUP1, "CUsbDevice::~CUsbDevice;deleted device state watcher" );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
	iLdd.Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   145
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CUSBDEVICE_DUP2, "CUsbDevice::~CUsbDevice;Freeing logical device" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   146
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
	TInt err = User::FreeLogicalDevice(KUsbLDDFreeName);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
	//Putting the LOGTEXT2 inside the if statement prevents a compiler
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
	//warning about err being unused in UREL builds.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
	if(err)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   152
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CUSBDEVICE_DUP3, "CUsbDevice::~CUsbDevice; User::FreeLogicalDevice returned err=%d", err );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
		}
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   154
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
#endif	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
	delete iDefaultSerialNumber;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   158
	OstTraceFunctionExit0( CUSBDEVICE_CUSBDEVICE_DES_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
CUsbDevice::CUsbDevice(CUsbServer& aUsbServer)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
	: CActive(EPriorityStandard)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
	, iDeviceState(EUsbDeviceStateUndefined)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
	, iServiceState(EUsbServiceIdle)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
	, iUsbServer(aUsbServer)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
	, iPersonalityCfged(EFalse)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
 * Constructor.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	CActiveScheduler::Add(this);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
void CUsbDevice::ConstructL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
 * Performs 2nd phase construction of the USB device.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   181
	OstTraceFunctionEntry0( CUSBDEVICE_CONSTRUCTL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
	iEcom = &(REComSession::OpenL());
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
	iUsbClassControllerIterator = new(ELeave) CUsbClassControllerIterator(iSupportedClasses);
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   186
	iCenRepManager = CUsbManCenRepManager::NewL(*this);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   188
	iDeviceConfiguration.iManufacturerName   = HBufC::NewL(KUsbStringDescStringMaxSize);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   189
	iDeviceConfiguration.iProductName        = HBufC::NewL(KUsbStringDescStringMaxSize);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   190
#ifndef __OVER_DUMMYUSBDI__	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
#ifndef __WINS__
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   192
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL, "CUsbDevice::ConstructL; About to load LDD" );
48
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   193
#ifndef __DUMMY_LDD__	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	TInt err = User::LoadLogicalDevice(KUsbLDDName);
48
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   195
#else
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   196
	TInt err = KErrNone;
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   197
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
	if (err != KErrNone && err != KErrAlreadyExists)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   200
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP10, "CUsbDevice::ConstructL;err=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   201
		User::Leave(err);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   204
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP1, "CUsbDevice::ConstructL; About to open LDD" );	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   205
	err = iLdd.Open(0);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   206
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   207
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   208
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP9, "CUsbDevice::ConstructL;iLdd.Open(0) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   209
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   210
	    }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   211
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP2, "CUsbDevice::ConstructL; LDD opened" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   212
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
	// hide bus from host while interfaces are being set up
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
	iLdd.DeviceDisconnectFromHost();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
	// Does the USC support cable detection while powered off? If no, then 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
	// call PowerUpUdc when RUsb::Start finishes, as is obvious. If yes, we 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	// delay calling PowerUpUdc until both the service state is 'started' and 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
	// the device state is not undefined. This is to save power in the UDC 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
	// when there's no point it being powered.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
	TUsbDeviceCaps devCapsBuf;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   223
	err = iLdd.DeviceCaps(devCapsBuf);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   224
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   225
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   226
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP11, "CUsbDevice::ConstructL;iLdd.DeviceCaps(devCapsBuf) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   227
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   228
	    }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   229
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
	if ( devCapsBuf().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   232
        OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP3, "CUsbDevice::ConstructL: UDC supports cable detect when unpowered" );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
		iUdcSupportsCableDetectWhenUnpowered = ETrue;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   237
        OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP4, "CUsbDevice::ConstructL; UDC does not support cable detect when unpowered" );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
	TUsbcDeviceState deviceState;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   241
	err = iLdd.DeviceStatus(deviceState);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   242
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   243
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   244
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP13, "CUsbDevice::ConstructL;iLdd.DeviceStatus(deviceState) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   245
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   246
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
	SetDeviceState(deviceState);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   248
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP5, "CUsbDevice::ConstructL; Got device state" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   249
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	iDeviceStateWatcher = CUsbDeviceStateWatcher::NewL(*this, iLdd);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	iDeviceStateWatcher->Start();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   254
#ifdef SYMBIAN_USB_BATTERYCHARGING_V1_1	
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   255
	iChargerTypeWatcher = CUsbChargingPortTypeWatcher::NewL(*this, iLdd);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   256
	iChargerTypeWatcher->Start();
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   257
#endif	
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
   258
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
	// Get hold of the default serial number in the driver
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
	// This is so it can be put back in place when a device that sets a
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
	// different serial number (through the P&S key) is stopped
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
	iDefaultSerialNumber = HBufC16::NewL(KUsbStringDescStringMaxSize);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
	TPtr16 serNum = iDefaultSerialNumber->Des();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
	err = iLdd.GetSerialNumberStringDescriptor(serNum);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
	if (err == KErrNotFound)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
		delete iDefaultSerialNumber;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
		iDefaultSerialNumber = NULL;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   269
		OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP6, "CUsbDevice::ConstructL; No default serial number" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   270
		
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   274
        if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   275
            {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   276
            OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP12, "CUsbDevice::ConstructL;error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   277
            User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   278
            }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   279
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   280
		OstTraceExt1( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP7, "CUsbDevice::ConstructL;serNum=%S", serNum );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   281
#endif //_DEBUG  
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   284
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_CONSTRUCTL_DUP8, "CUsbDevice::ConstructL; UsbDevice::ConstructL() finished" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   285
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
#endif
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   287
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
#ifndef __OVER_DUMMYUSBDI__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	InstantiateExtensionPluginsL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
#endif
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   292
	OstTraceFunctionExit0( CUSBDEVICE_CONSTRUCTL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
void CUsbDevice::InstantiateExtensionPluginsL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   297
    OstTraceFunctionEntry0( CUSBDEVICE_INSTANTIATEEXTENSIONPLUGINSL_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   298
    
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
	const TUid KUidExtensionPluginInterface = TUid::Uid(KUsbmanExtensionPluginInterfaceUid);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
	RImplInfoPtrArray implementations;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
	const TEComResolverParams noResolverParams;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
	REComSession::ListImplementationsL(KUidExtensionPluginInterface, noResolverParams, KRomOnlyResolverUid, implementations);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
	CleanupResetAndDestroyPushL(implementations);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   304
	OstTrace1( TRACE_FLOW, CUSBDEVICE_INSTANTIATEEXTENSIONPLUGINSL, "CUsbDevice::InstantiateExtensionPluginsL;Number of implementations of extension plugin interface: %d", implementations.Count() );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   305
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
	for (TInt i=0; i<implementations.Count(); i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
		{
48
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   309
#ifndef __DUMMY_LDD__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
		CUsbmanExtensionPlugin* plugin = CUsbmanExtensionPlugin::NewL(implementations[i]->ImplementationUid(), *this);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
		CleanupStack::PushL(plugin);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
		iExtensionPlugins.AppendL(plugin); // transfer ownership to iExtensionPlugins
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
		CleanupStack::Pop(plugin);
48
21625e5de155 201035_01
hgs
parents: 29
diff changeset
   314
#endif
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   315
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_INSTANTIATEEXTENSIONPLUGINSL_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   316
		        "CUsbDevice::InstantiateExtensionPluginsL;Added extension plugin with UID 0x%08x", 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   317
		        implementations[i]->ImplementationUid().iUid );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   318
		
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
	CleanupStack::PopAndDestroy(&implementations);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   322
	OstTraceFunctionExit0( CUSBDEVICE_INSTANTIATEEXTENSIONPLUGINSL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
   	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
void CUsbDevice::EnumerateClassControllersL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
 * Loads all USB class controllers at startup.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   334
	OstTraceFunctionEntry0( CUSBDEVICE_ENUMERATECLASSCONTROLLERSL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
#ifdef USE_DUMMY_CLASS_CONTROLLER
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
	//create a TLinearOrder to supply the comparison function, Compare(), to be used  
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
	//to determine the order to add class controllers
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
	TLinearOrder<CUsbClassControllerBase> order(CUsbClassControllerBase::Compare);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
	// For GT171 automated tests, create three instances of the dummy class 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
	// controller, which will read their behaviour from an ini file. Do not 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
	// make any other class controllers.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
	for ( TUint ii = 0 ; ii < 3 ; ii++ )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
		AddClassControllerL(CUsbDummyClassController::NewL(*this, ii), order);	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   348
	TInt err = iUsbClassControllerIterator->First();   
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   349
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   350
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   351
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_ENUMERATECLASSCONTROLLERSL_DUP2, "CUsbDevice::EnumerateClassControllersL;iUsbClassControllerIterator->First() with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   352
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   353
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
	    
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
#else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
	// Add a class controller statically.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
	// The next line shows how to add a class controller, CUsbExampleClassController,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
	// statically
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
	// AddClassControllerL(CUsbExampleClassController::NewL(*this),order);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
	// Load class controller plug-ins
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
	RImplInfoPtrArray implementations;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
	const TEComResolverParams noResolverParams;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
	REComSession::ListImplementationsL(KUidUsbPlugIns, noResolverParams, KRomOnlyResolverUid, implementations);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
  	CleanupResetAndDestroyPushL(implementations);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
  	
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   371
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_ENUMERATECLASSCONTROLLERSL, "CUsbDevice::EnumerateClassControllersL;Number of implementations to load %d", implementations.Count() );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
	for (TInt i=0; i<implementations.Count(); i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   375
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_ENUMERATECLASSCONTROLLERSL_DUP1, "CUsbDevice::EnumerateClassControllersL;Adding class controller with UID %x", implementations[i]->ImplementationUid().iUid );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   376
        const TUid uid = implementations[i]->ImplementationUid();
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   377
		TInt err = iSupportedClassUids.Append(uid);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   378
		if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   379
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   380
            OstTrace1( TRACE_NORMAL, CUSBDEVICE_ENUMERATECLASSCONTROLLERSL_DUP3, "CUsbDevice::EnumerateClassControllersL;iSupportedClassUids.Append(uid) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   381
            User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   382
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
		}	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
			
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
	CleanupStack::PopAndDestroy(&implementations);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
#endif // USE_DUMMY_CLASS_CONTROLLER
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   388
	OstTraceFunctionExit0( CUSBDEVICE_ENUMERATECLASSCONTROLLERSL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
void CUsbDevice::AddClassControllerL(CUsbClassControllerBase* aClassController, 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
									TLinearOrder<CUsbClassControllerBase> aOrder)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
 * Adds a USB class controller to the device. The controller will now be
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
 * managed by this device. Note that the class controller, aClassController, is now
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
 * owned by this function and can be destroyed by it.  Calling functions do not need to 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
 * destroy the class controller. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
 * @param	aClassController	Class to be managed
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
 * @param   aOrder              Specifies order CUsbClassControllerBase objects are to be
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
 *                              added
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   404
	OstTraceFunctionEntry0( CUSBDEVICE_ADDCLASSCONTROLLERL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
	TInt rc = KErrNone;	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
	if(isPersonalityCfged()) // do not take into account priorities
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
		rc = iSupportedClasses.Append(aClassController);	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
		rc = iSupportedClasses.InsertInOrderAllowRepeats(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
		aClassController, aOrder);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
		} 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
	if (rc != KErrNone) 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
		// Avoid memory leak by deleting class controller if the append fails.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
		delete aClassController;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   423
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_ADDCLASSCONTROLLERL, "CUsbDevice::AddClassControllerL;Leave rc=%d", rc );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   424
		User::Leave(rc);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   426
	OstTraceFunctionExit0( CUSBDEVICE_ADDCLASSCONTROLLERL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
void CUsbDevice::RegisterObserverL(MUsbDeviceNotify& aObserver)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
 * Register an observer of the device.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
 * Presently, the device supports watching state.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
 * @param	aObserver	New Observer of the device
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   437
	OstTraceFunctionEntry0( CUSBDEVICE_REGISTEROBSERVERL_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   438
	TInt err = iObservers.Append(&aObserver);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   439
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   440
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   441
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_REGISTEROBSERVERL, "CUsbDevice::RegisterObserverL;iObservers.Append(&aObserver) with err=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   442
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   443
	    }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   444
	OstTraceFunctionExit0( CUSBDEVICE_REGISTEROBSERVERL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
void CUsbDevice::DeRegisterObserver(MUsbDeviceNotify& aObserver)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
 * De-registers an existing device observer.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
 * @param	aObserver	The existing device observer to be de-registered
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   455
	OstTraceFunctionEntry0( CUSBDEVICE_DEREGISTEROBSERVER_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
	TInt index = iObservers.Find(&aObserver);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
	if (index >= 0)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
		iObservers.Remove(index);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   461
	OstTraceFunctionExit0( CUSBDEVICE_DEREGISTEROBSERVER_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
void CUsbDevice::StartL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
 * Start the USB Device and all its associated USB classes.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
 * Reports errors and state changes via observer interface.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   471
	OstTraceFunctionEntry0( CUSBDEVICE_STARTL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
	Cancel();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
	SetServiceState(EUsbServiceStarting);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
	TRAPD(err, SetDeviceDescriptorL());
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
	if ( err != KErrNone )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   479
		SetServiceState(EUsbServiceIdle);	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   480
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_STARTL, "CUsbDevice::StartL;Leave with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   481
		User::Leave(err);		
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
	iLastError = KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
	StartCurrentClassController();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   486
	OstTraceFunctionExit0( CUSBDEVICE_STARTL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
void CUsbDevice::Stop()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
 * Stop the USB device and all its associated USB classes.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   494
	OstTraceFunctionEntry0( CUSBDEVICE_STOP_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
	Cancel();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
	SetServiceState(EUsbServiceStopping);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
	iLastError = KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
	StopCurrentClassController();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   501
	OstTraceFunctionExit0( CUSBDEVICE_STOP_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
void CUsbDevice::SetServiceState(TUsbServiceState aState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
 * Change the device's state and report the change to the observers.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
 * @param	aState	New state that the device is moving to
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   511
    OstTraceFunctionEntry0( CUSBDEVICE_SETSERVICESTATE_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   512
    
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   513
	OstTraceExt2( TRACE_NORMAL, CUSBDEVICE_SETSERVICESTATE, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   514
	        "CUsbDevice::SetServiceState;iServiceState=%d;aState=%d", iServiceState, aState );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   515
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
	if (iServiceState != aState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
		// Change state straight away in case any of the clients check it
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
		TUsbServiceState oldState = iServiceState;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
		iServiceState = aState;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
		TUint length = iObservers.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
		for (TUint i = 0; i < length; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
			iObservers[i]->UsbServiceStateChange(LastError(), oldState,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
				iServiceState);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
		if (iServiceState == EUsbServiceIdle)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
			iUsbServer.LaunchShutdownTimerIfNoSessions();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   533
	OstTraceFunctionExit0( CUSBDEVICE_SETSERVICESTATE_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
void CUsbDevice::SetDeviceState(TUsbcDeviceState aState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
 * The CUsbDevice::SetDeviceState method
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
 * Change the device's state and report the change to the observers
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
 * @internalComponent
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
 * @param	aState	New state that the device is moving to
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   546
	OstTraceFunctionEntry0( CUSBDEVICE_SETDEVICESTATE_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   547
	OstTraceExt2( TRACE_NORMAL, CUSBDEVICE_SETDEVICESTATE, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   548
	        "CUsbDevice::SetDeviceState;aState=%d;iDeviceState=%d", aState, iDeviceState );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
	TUsbDeviceState state;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
	switch (aState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
	case EUsbcDeviceStateUndefined:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
		state = EUsbDeviceStateUndefined;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
	case EUsbcDeviceStateAttached:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
		state = EUsbDeviceStateAttached;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
	case EUsbcDeviceStatePowered:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
		state = EUsbDeviceStatePowered;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
	case EUsbcDeviceStateDefault:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
		state = EUsbDeviceStateDefault;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
	case EUsbcDeviceStateAddress:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
		state = EUsbDeviceStateAddress;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
	case EUsbcDeviceStateConfigured:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
		state = EUsbDeviceStateConfigured;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
	case EUsbcDeviceStateSuspended:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
		state = EUsbDeviceStateSuspended;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
	default:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
		return;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
	if (iDeviceState != state)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
		{
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   580
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
#ifndef __WINS__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
		if (iDeviceState == EUsbDeviceStateUndefined &&
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
			iUdcSupportsCableDetectWhenUnpowered &&
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
			iServiceState == EUsbServiceStarted)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
			// We just changed state away from undefined. Hence the cable must
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
			// now be attached (if it wasn't before). If the UDC supports
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
			// cable detection when unpowered, NOW is the right time to power
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
			// it up (so long as usbman is fully started).
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
			(void)PowerUpAndConnect(); // We don't care about any errors here.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
			}
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   592
#endif
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   593
#endif // __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
		// Change state straight away in case any of the clients check it
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
		TUsbDeviceState oldState = iDeviceState;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
		iDeviceState = state;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
		TUint length = iObservers.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
		for (TUint i = 0; i < length; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
			iObservers[i]->UsbDeviceStateChange(LastError(), oldState, iDeviceState);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   604
	OstTraceFunctionExit0( CUSBDEVICE_SETDEVICESTATE_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
 * Callback called by CDeviceHandler when the USB bus has sucessfully
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
 * completed a ReEnumeration (restarted all services).
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
void CUsbDevice::BusEnumerationCompleted()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   613
	OstTraceFunctionEntry0( CUSBDEVICE_BUSENUMERATIONCOMPLETED_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
	// Has the start been cancelled?
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
	if (iServiceState == EUsbServiceStarting)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
		SetServiceState(EUsbServiceStarted);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   622
        OstTrace0( TRACE_NORMAL, CUSBDEVICE_BUSENUMERATIONCOMPLETED, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   623
                "CUsbDevice::BusEnumerationCompleted;    Start has been cancelled!" );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   625
	OstTraceFunctionExit0( CUSBDEVICE_BUSENUMERATIONCOMPLETED_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
void CUsbDevice::BusEnumerationFailed(TInt aError)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
 * Callback called by CDeviceHandler when the USB bus has
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
 * completed an ReEnumeration (Restarted all services) with errors
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
 * @param	aError	Error that has occurred during Re-enumeration
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   636
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_BUSENUMERATIONFAILED, "CUsbDevice::BusEnumerationFailed;aError=%d", aError );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   637
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
	iLastError = aError;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
	if (iServiceState == EUsbServiceStarting)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
		SetServiceState(EUsbServiceStopping);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
		StopCurrentClassController();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   647
		OstTrace0( TRACE_NORMAL, CUSBDEVICE_BUSENUMERATIONFAILED_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   648
		        "CUsbDevice::BusEnumerationFailed;    Start has been cancelled!" );		
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
void CUsbDevice::StartCurrentClassController()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
 * Called numerous times to start all the USB classes.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   658
	OstTraceFunctionEntry0( CUSBDEVICE_STARTCURRENTCLASSCONTROLLER_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
	iUsbClassControllerIterator->Current()->Start(iStatus);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
	SetActive();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   662
	OstTraceFunctionExit0( CUSBDEVICE_STARTCURRENTCLASSCONTROLLER_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
void CUsbDevice::StopCurrentClassController()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
 * Called numerous times to stop all the USB classes.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   670
	OstTraceFunctionEntry0( CUSBDEVICE_STOPCURRENTCLASSCONTROLLER_ENTRY );	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
	iUsbClassControllerIterator->Current()->Stop(iStatus);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
	SetActive();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   674
	OstTraceFunctionExit0( CUSBDEVICE_STOPCURRENTCLASSCONTROLLER_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
Utility function to power up the UDC and connect the
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
device to the host.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
TInt CUsbDevice::PowerUpAndConnect()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   683
	OstTraceFunctionEntry0( CUSBDEVICE_POWERUPANDCONNECT_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   684
	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   685
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_POWERUPANDCONNECT, "CUsbDevice::PowerUpAndConnect;Powering up UDC..." );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   686
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
	TInt res = iLdd.PowerUpUdc();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   688
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_POWERUPANDCONNECT_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   689
	        "CUsbDevice::PowerUpAndConnect;PowerUpUdc res = %d", res );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   690
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
	res = iLdd.DeviceConnectToHost();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   692
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_POWERUPANDCONNECT_DUP2, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   693
	        "CUsbDevice::PowerUpAndConnect;DeviceConnectToHost res = %d", res );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   694
	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   695
	OstTraceFunctionExit0( CUSBDEVICE_POWERUPANDCONNECT_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
	return res;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
void CUsbDevice::RunL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
 * Called when starting or stopping a USB class has completed, successfully or
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
 * otherwise. Continues with the process of starting or stopping until all
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
 * classes have been completed.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   706
    OstTraceFunctionEntry0( CUSBDEVICE_RUNL_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   707
    OstTrace1( TRACE_NORMAL, CUSBDEVICE_RUNL, "CUsbDevice::RunL;iStatus.Int()=%d", iStatus.Int() );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   709
    TInt err = iStatus.Int();
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   710
    if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   711
        {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   712
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_RUNL_DUP4, "CUsbDevice::RunL;iStatus.Int() with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   713
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   714
        }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
	switch (iServiceState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
	case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
		if (iUsbClassControllerIterator->Next() == KErrNotFound)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
			{
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   721
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
#ifndef __WINS__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
			if (!iUdcSupportsCableDetectWhenUnpowered || iDeviceState != EUsbDeviceStateUndefined)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
				{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
				// We've finished starting the classes. We can just power up the UDC
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
				// now: there's no need to re-enumerate, because we soft disconnected
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
				// earlier. This will also do a soft connect.
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   728
				OstTrace0( TRACE_NORMAL, CUSBDEVICE_RUNL_DUP1, "CUsbDevice::RunL;Finished starting classes: powering up UDC" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   729
				
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
				// It isn't an error if this call fails. This will happen, for example,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
				// in the case where there are no USB classes defined.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
				(void)PowerUpAndConnect();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
				}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
#endif
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   736
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
			// If we're not running on target, we can just go to "started".
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
			SetServiceState(EUsbServiceStarted);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
		else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
			StartCurrentClassController();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
	case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
		if (iUsbClassControllerIterator->Previous() == KErrNotFound)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
			// if stopping classes, hide the USB interface from the host
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   750
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
#ifndef __WINS__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
			iLdd.DeviceDisconnectFromHost();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
			// Restore the default serial number 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
			if (iDefaultSerialNumber)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
				{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
				TInt res = iLdd.SetSerialNumberStringDescriptor(*iDefaultSerialNumber);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   758
				OstTrace1( TRACE_NORMAL, CUSBDEVICE_RUNL_DUP2, "CUsbDevice::RunL;Restore default serial number res = %d", res );				
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
				}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
			else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
				{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
				TInt res = iLdd.RemoveSerialNumberStringDescriptor();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   763
				OstTrace1( TRACE_NORMAL, CUSBDEVICE_RUNL_DUP3, "CUsbDevice::RunL;Remove serial number res = %d", res );				
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
				}
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   765
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   766
#endif				
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
#endif			
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
			SetServiceState(EUsbServiceIdle);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
		else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
			StopCurrentClassController();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   777
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   778
        OstTrace1( TRACE_FATAL, CUSBDEVICE_RUNL_DUP5, "CUsbDevice::RunL;Panic reason=%d", EBadAsynchronousCall );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   779
        __ASSERT_DEBUG( EFalse, User::Panic(KUsbDevicePanicCategory, EBadAsynchronousCall) );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   780
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   783
	OstTraceFunctionExit0( CUSBDEVICE_RUNL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
void CUsbDevice::DoCancel()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
 * Standard active object cancellation function. If we're starting or stopping
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
 * a USB class, cancels it. If we're not, then we shouldn't be active and hence
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
 * this function being called is a programming error.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   793
	OstTraceFunctionEntry0( CUSBDEVICE_DOCANCEL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
	switch (iServiceState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
	case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
	case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
		iUsbClassControllerIterator->Current()->Cancel();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   803
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   804
        OstTrace1( TRACE_FATAL, CUSBDEVICE_DOCANCEL, "CUsbDevice::DoCancel;Panic reason=%d", EBadAsynchronousCall );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   805
        __ASSERT_DEBUG( EFalse, User::Panic(KUsbDevicePanicCategory, EBadAsynchronousCall ) );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   808
	OstTraceFunctionExit0( CUSBDEVICE_DOCANCEL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
TInt CUsbDevice::RunError(TInt aError)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
 * Standard active object RunError function. Handles errors which occur when
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
 * starting and stopping the USB class objects.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
 * @param aError The error which occurred
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
 * @return Always KErrNone, to avoid an active scheduler panic
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   820
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_RUNERROR, "CUsbDevice::RunError;aError=%d", aError );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   821
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
	iLastError = aError;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
	switch (iServiceState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
	case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
	case EUsbServiceStarted:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
		// An error has happened while we're either started or starting, so
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
		// we have to stop all the classes which were successfully started.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
		if ((iUsbClassControllerIterator->Current()->State() ==
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
				EUsbServiceIdle) &&
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
			(iUsbClassControllerIterator->Previous() == KErrNotFound))
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
			SetServiceState(EUsbServiceIdle);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
		else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
			SetServiceState(EUsbServiceStopping);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
			StopCurrentClassController();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
	case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
		// Argh, we've got problems. Let's stop as many classes as we can.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
		if (iUsbClassControllerIterator->Previous() == KErrNotFound)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
			SetServiceState(EUsbServiceIdle);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
		else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
			StopCurrentClassController();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   853
        OstTrace1( TRACE_FATAL, CUSBDEVICE_RUNERROR_DUP1, "CUsbDevice::RunError;Panic reason=%d", EBadAsynchronousCall );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   854
        __ASSERT_DEBUG( EFalse, User::Panic(KUsbDevicePanicCategory, EBadAsynchronousCall ) );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
	return KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
CUsbClassControllerIterator* CUsbDevice::UccnGetClassControllerIteratorL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
 * Function used by USB classes to get an iterator over the set of classes
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
 * owned by this device. Note that the caller takes ownership of the iterator
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
 * which this function returns.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
 * @return A new iterator
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   870
	OstTraceFunctionEntry0( CUSBDEVICE_UCCNGETCLASSCONTROLLERITERATORL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
	return new (ELeave) CUsbClassControllerIterator(iSupportedClasses);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
void CUsbDevice::UccnError(TInt aError)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
 * Function called by USB classes to notify the device of a fatal error. In
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
 * this situation, we should just stop all the classes we can.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
 * @param aError The error that's occurred
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   883
	OstTraceFunctionEntry0( CUSBDEVICE_UCCNERROR_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
	RunError(aError);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   886
	OstTraceFunctionExit0( CUSBDEVICE_UCCNERROR_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   890
#ifdef _DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
void CUsbDevice::PrintDescriptor(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   893
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR, "CUsbDevice::PrintDescriptor;iLength=%d", aDeviceDescriptor.iLength );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   894
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP1, "CUsbDevice::PrintDescriptor;iDescriptorType=%d", aDeviceDescriptor.iDescriptorType );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   895
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP2, "CUsbDevice::PrintDescriptor;iBcdUsb=0x%04x", aDeviceDescriptor.iBcdUsb );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   896
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP3, "CUsbDevice::PrintDescriptor;iDeviceClass=0x%02x", aDeviceDescriptor.iDeviceClass );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   897
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP4, "CUsbDevice::PrintDescriptor;iDeviceSubClass=0x%02x", aDeviceDescriptor.iDeviceSubClass );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   898
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP5, "CUsbDevice::PrintDescriptor;iDeviceProtocol=0x%02x", aDeviceDescriptor.iDeviceProtocol );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   899
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP6, "CUsbDevice::PrintDescriptor;iMaxPacketSize=0x%02x", aDeviceDescriptor.iMaxPacketSize );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
	
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   901
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP7, "CUsbDevice::PrintDescriptor;iIdVendor=0x%04x", aDeviceDescriptor.iIdVendor );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   902
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP8, "CUsbDevice::PrintDescriptor;iProductId=0x%04x", aDeviceDescriptor.iProductId );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   903
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP9, "CUsbDevice::PrintDescriptor;iBcdDevice=0x%04x", aDeviceDescriptor.iBcdDevice );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   904
	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   905
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP10, "CUsbDevice::PrintDescriptor;iManufacturer=0x%04x", aDeviceDescriptor.iManufacturer );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   906
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP11, "CUsbDevice::PrintDescriptor;iSerialNumber=0x%04x", aDeviceDescriptor.iSerialNumber );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   907
	OstTrace1( TRACE_DUMP, CUSBDEVICE_PRINTDESCRIPTOR_DUP12, "CUsbDevice::PrintDescriptor;iNumConfigurations=0x%04x", aDeviceDescriptor.iNumConfigurations );	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
#endif
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
//
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
void CUsbDevice::SetDeviceDescriptorL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
 * Modifies the USB device descriptor.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   916
	OstTraceFunctionEntry0( CUSBDEVICE_SETDEVICEDESCRIPTORL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   918
#if !defined(__OVER_DUMMYUSBDI__) && !defined(__WINS__)
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
	TInt desSize = 0;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
	iLdd.GetDeviceDescriptorSize(desSize);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   922
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETDEVICEDESCRIPTORL, "CUsbDevice::SetDeviceDescriptorL;UDeviceDescriptorSize = %d", desSize );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
	HBufC8* deviceBuf = HBufC8::NewLC(desSize);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
	TPtr8   devicePtr = deviceBuf->Des();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
	devicePtr.SetLength(0);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
	TInt ret = iLdd.GetDeviceDescriptor(devicePtr);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
	if (ret != KErrNone)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   931
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETDEVICEDESCRIPTORL_DUP1, "CUsbDevice::SetDeviceDescriptorL;Unable to fetch device descriptor. Error: %d", ret );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   932
		User::Leave(ret);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
	TUsbDeviceDescriptor* deviceDescriptor = reinterpret_cast<TUsbDeviceDescriptor*>(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
		const_cast<TUint8*>(devicePtr.Ptr()));
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
#else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
	// Create an empty descriptor to allow the settings
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
	// to be read in from the resource file
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
	TUsbDeviceDescriptor descriptor;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   944
	TUsbDeviceDescriptor* deviceDescriptor = &descriptor;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   945
	
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   946
#endif // __OVER_DUMMYUSBDI__ && _WINS_
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
	if (iPersonalityCfged)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
		SetUsbDeviceSettingsFromPersonalityL(*deviceDescriptor);		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   954
        OstTrace0( TRACE_NORMAL, CUSBDEVICE_SETDEVICEDESCRIPTORL_DUP3, 
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   955
                "CUsbDevice::SetDeviceDescriptorL;USB configuration is not read" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   956
        User::Leave(KErrNotFound);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
	
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   959
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
#ifndef __WINS__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
	ret = iLdd.SetDeviceDescriptor(devicePtr);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
	if (ret != KErrNone)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   965
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETDEVICEDESCRIPTORL_DUP2, "CUsbDevice::SetDeviceDescriptorL;Unable to set device descriptor. Error: %d", ret );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   966
		User::Leave(ret);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
	CleanupStack::PopAndDestroy(deviceBuf);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   971
#endif
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
   972
#endif // __OVER_DUMMYUSBDI__
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   973
	OstTraceFunctionExit0( CUSBDEVICE_SETDEVICEDESCRIPTORL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
void CUsbDevice::SetUsbDeviceSettingsDefaultsL(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
 * Set the device settings defaults, as per the non-resource
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   979
 * version of the USB manager
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
 * @param aDeviceDescriptor The device descriptor for the USB device
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
	aDeviceDescriptor.iDeviceClass		= KUsbDefaultDeviceClass;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
	aDeviceDescriptor.iDeviceSubClass	= KUsbDefaultDeviceSubClass;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
	aDeviceDescriptor.iDeviceProtocol	= KUsbDefaultDeviceProtocol;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
	aDeviceDescriptor.iIdVendor			= KUsbDefaultVendorId;
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
   988
	aDeviceDescriptor.iProductId		= KUsbDefaultProductId;
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   991
void CUsbDevice::SetUsbDeviceSettingsFromPersonalityL(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
 * Configure the USB device from the current personality.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
 * @param aDeviceDescriptor The device descriptor for the USB device
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   997
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
   998
	OstTraceFunctionEntry0( CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
	// First, use the default values
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1001
	OstTrace0( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;Setting default values for the configuration" );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1002
	SetUsbDeviceSettingsDefaultsL(aDeviceDescriptor);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1003
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
	// Now try to get the configuration from the current personality
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1005
    aDeviceDescriptor.iDeviceClass          = iCurrentPersonality->DeviceClass();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1006
    aDeviceDescriptor.iDeviceSubClass       = iCurrentPersonality->DeviceSubClass();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1007
    aDeviceDescriptor.iDeviceProtocol       = iCurrentPersonality->DeviceProtocol();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1008
    aDeviceDescriptor.iIdVendor             = iDeviceConfiguration.iVendorId;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1009
    aDeviceDescriptor.iProductId            = iCurrentPersonality->ProductId();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1010
    aDeviceDescriptor.iBcdDevice            = iCurrentPersonality->BcdDevice();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1011
    aDeviceDescriptor.iNumConfigurations    = iCurrentPersonality->NumConfigurations();	
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1012
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1014
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1015
#ifndef __WINS__
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1016
	TInt err = iLdd.SetManufacturerStringDescriptor(*(iDeviceConfiguration.iManufacturerName));
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1017
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1018
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1019
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP7, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;iLdd.SetManufacturerStringDescriptor(*(iCurrentPersonality->Manufacturer())) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1020
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1021
	    }  
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1022
	err = iLdd.SetProductStringDescriptor(*(iDeviceConfiguration.iProductName));
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1023
    if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1024
        {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1025
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP6, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;iLdd.SetProductStringDescriptor(*(iCurrentPersonality->Product())) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1026
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1027
        }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1028
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
	//Read the published serial number. The key is the UID KUidUsbmanServer = 0x101FE1DB
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
	TBuf16<KUsbStringDescStringMaxSize> serNum;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
	TInt r = RProperty::Get(KUidSystemCategory,0x101FE1DB,serNum);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
	if(r==KErrNone)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1035
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1036
		OstTraceExt1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP1, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;Setting published SerialNumber: %S", serNum );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1037
#endif//_DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
		//USB spec doesn't give any constraints on what constitutes a valid serial number.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1039
		//As long as it is a string descriptor it is valid.
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1040
		err = iLdd.SetSerialNumberStringDescriptor(serNum);	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1041
		if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1042
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1043
            OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP3, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;iLdd.SetSerialNumberStringDescriptor(serNum) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1044
            User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1045
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1047
#ifdef _DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
	else
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1050
		OstTrace0( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP2, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;SerialNumber has not been published" );	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1052
#endif // _DEBUG
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1053
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1054
#endif
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1055
#endif // __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1058
#ifdef _DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
	PrintDescriptor(aDeviceDescriptor);		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1061
#ifndef __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1062
#ifndef __WINS__
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
	TBuf16<KUsbStringDescStringMaxSize> wideString;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1064
	TInt tmp = iLdd.GetConfigurationStringDescriptor(wideString);	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1065
	if(tmp < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1066
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1067
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP5, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;iLdd.GetConfigurationStringDescriptor(wideString) with error=%d", tmp );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1068
        User::Leave(tmp);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1069
	    }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1070
	OstTraceExt1( TRACE_NORMAL, CUSBDEVICE_SETUSBDEVICESETTINGSFROMPERSONALITYL_DUP4, "CUsbDevice::SetUsbDeviceSettingsFromPersonalityL;Configuration is:%S", wideString );
25
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1071
#endif
4ddb65515edd 201022_05
hgs
parents: 0
diff changeset
  1072
#endif // __OVER_DUMMYUSBDI__
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1074
#endif // _DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
void CUsbDevice::TryStartL(TInt aPersonalityId)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
 * Start all USB classes associated with the personality identified
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
 * by aPersonalityId. Reports errors and state changes via observer 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
 * interface.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
 * @param aPersonalityId a personality id
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1086
	OstTraceFunctionEntry0( CUSBDEVICE_TRYSTARTL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
	SetCurrentPersonalityL(aPersonalityId);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
	SelectClassControllersL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
	SetServiceState(EUsbServiceStarting);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
	TRAPD(err, SetDeviceDescriptorL());
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1093
	if ( err != KErrNone )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1095
		SetServiceState(EUsbServiceIdle);	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1096
		OstTrace1( TRACE_NORMAL, CUSBDEVICE_TRYSTARTL, "CUsbDevice::TryStartL;leave with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1097
		User::Leave(err);		
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1100
	iLastError = KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
	StartCurrentClassController();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1102
 	OstTraceFunctionExit0( CUSBDEVICE_TRYSTARTL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
 	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
TInt CUsbDevice::CurrentPersonalityId() const
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1106
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1107
 * @return the current personality id
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1110
	OstTraceFunctionEntry0( CUSBDEVICE_CURRENTPERSONALITYID_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1111
 	return iCurrentPersonality->PersonalityId();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1113
 	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1114
const RPointerArray<CPersonality>& CUsbDevice::Personalities() const
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1115
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1116
 * @return a const reference to RPointerArray<CPersonality>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1117
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1119
	OstTraceFunctionEntry0( CUSBDEVICE_PERSONALITIES_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
 	return iSupportedPersonalities;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
 	} 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
 	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
const CPersonality* CUsbDevice::GetPersonality(TInt aPersonalityId) const
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
 * Obtains a handle to the CPersonality object whose id is aPersonalityId
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
 * @param aPeraonalityId a personality id
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
 * @return a const pointer to the CPersonality object whose id is aPersonalityId if found
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
 * or 0 otherwise.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1132
	OstTraceFunctionEntry0( CUSBDEVICE_GETPERSONALITY_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1134
	TInt count = iSupportedPersonalities.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1135
	for (TInt i = 0; i < count; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
		if (iSupportedPersonalities[i]->PersonalityId() == aPersonalityId)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
			{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1139
			OstTraceFunctionExit0( CUSBDEVICE_GETPERSONALITY_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1140
			return iSupportedPersonalities[i];
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
	
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1144
	OstTraceFunctionExit0( CUSBDEVICE_GETPERSONALITY_EXIT_DUP1 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
	return 0;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
void CUsbDevice::SetCurrentPersonalityL(TInt aPersonalityId)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
 * Sets the current personality to the personality with id aPersonalityId
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1153
	OstTraceFunctionEntry0( CUSBDEVICE_SETCURRENTPERSONALITYL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
	const CPersonality* personality = GetPersonality(aPersonalityId);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
	if (!personality)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1157
		OstTrace0( TRACE_NORMAL, CUSBDEVICE_SETCURRENTPERSONALITYL, "CUsbDevice::SetCurrentPersonalityL;Personality id not found" );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1158
		User::Leave(KErrNotFound);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
	iCurrentPersonality = personality;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1162
 	OstTraceFunctionExit0( CUSBDEVICE_SETCURRENTPERSONALITYL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
	
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1165
void CUsbDevice::ValidatePersonalities()
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
 * Verifies all class controllers associated with each personality are loaded.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
 * Leave if validation fails.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1170
	{
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1171
	OstTraceFunctionEntry0( CUSBDEVICE_VALIDATEPERSONALITIES_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
	TInt personalityCount = iSupportedPersonalities.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
	for (TInt i = 0; i < personalityCount; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
		{
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1176
		const RArray<CPersonalityConfigurations::TUsbClasses>& classes = iSupportedPersonalities[i]->SupportedClasses();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1177
		TInt uidCount = classes.Count();
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
		for (TInt j = 0; j < uidCount; j++)	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
			TInt ccCount = iSupportedClassUids.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
			TInt k;
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1182
		    OstTrace1( TRACE_NORMAL, CUSBDEVICE_VALIDATEPERSONALITIES_DUP1, "CUsbDevice::ValidatePersonalities;iSupportedClassUids Count = %d", ccCount );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1183
			for (k = 0; k < ccCount; k++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
				{
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1185
                OstTraceExt4( TRACE_NORMAL, CUSBDEVICE_VALIDATEPERSONALITIES_DUP2, "CUsbDevice::ValidatePersonalities;iSupportedClassUids %d %x classes %d %x", k, iSupportedClassUids[k].iUid, j, classes[j].iClassUid.iUid );
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1186
				if (iSupportedClassUids[k] == classes[j].iClassUid)
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1187
					{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1188
					break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
					}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
				}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
			if (k == ccCount)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1192
				{
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1193
				OstTrace1( TRACE_FATAL, CUSBDEVICE_VALIDATEPERSONALITIES, "CUsbDevice::ValidatePersonalities; Validation failed, class %x not supported", classes[j].iClassUid.iUid );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1194
				// Previously leaves here. But this causes that USB doesn't work.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1195
				// Now this function will only be called in debug version and only shows some information.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1196
				// The behaviour is a little different with before but should be ok.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1197
				// After the device image is verified, this error will never happen at run time.
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
				}					
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
			}	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
		}
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1201
	OstTraceFunctionExit0( CUSBDEVICE_VALIDATEPERSONALITIES_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
Converts text string with UIDs to array of Uint
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
If there is an error during the conversion, this function will not clean-up,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
so there may still be UIDs allocated in the RArray.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1209
@param aStr Reference to a string containing one or more UIDs in hex
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
@param aUIDs On return array of UIDs parsed from the input string
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
@panic EUidArrayNotEmpty if the RArray passed in is not empty
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
void CUsbDevice::ConvertUidsL(const TDesC& aStr, RArray<TUint>& aUidArray)	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1215
    OstTraceFunctionEntry0( CUSBDEVICE_CONVERTUIDSL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
	// Function assumes that aUIDs is empty
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1217
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1218
    if(aUidArray.Count() != 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1219
        {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1220
        OstTrace1( TRACE_FATAL, CUSBDEVICE_CONVERTUIDSL, "CUsbDevice::ConvertUidsL;Panic reason=%d", EUidArrayNotEmpty );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1221
        User::Panic(KUsbDevicePanicCategory, EUidArrayNotEmpty);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1222
        }
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1223
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1225
	TLex input(aStr);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
	// Scan through string to find UIDs
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
	// Need to do this at least once, as no UID in the string is an error
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
	do 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1230
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1231
		// Find first hex digit
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
		while (!(input.Eos() || input.Peek().IsHexDigit()))
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
			input.Inc();	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1235
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1236
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1237
		// Convert and add to array
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1238
		TUint val;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1239
		TInt err = input.Val(val,EHex);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1240
		if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1241
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1242
            OstTrace1( TRACE_NORMAL, CUSBDEVICE_CONVERTUIDSL_DUP1, "CUsbDevice::ConvertUidsL;input.Val(val,EHex) with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1243
            User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1244
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1245
		aUidArray.AppendL(val);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1246
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1247
	while (!input.Eos());	
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1248
	OstTraceFunctionExit0( CUSBDEVICE_CONVERTUIDSL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1249
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1250
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1251
void CUsbDevice::ReadPersonalitiesL()
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1252
    {    
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1253
    OstTraceFunctionEntry0( CUSBDEVICE_READPERSONALITIESL_ENTRY );
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1254
    TPtrC16 sysUtilModelName;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1255
    TPtrC16 sysUtilManuName;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1256
    
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1257
    iPersonalityCfged = EFalse;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1258
    
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1259
    iCenRepManager->ReadDeviceConfigurationL(iDeviceConfiguration);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1260
    
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1261
    iCenRepManager->ReadPersonalitiesL(iSupportedPersonalities);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1262
    
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1263
    //update info for SetManufacturer & SetProduct
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1264
    CDeviceTypeInformation* deviceInfo = SysUtil::GetDeviceTypeInfoL();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1265
    CleanupStack::PushL(deviceInfo);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1266
    TInt gotSysUtilModelName = deviceInfo->GetModelName(sysUtilModelName);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1267
    TInt gotSysUtilManuName = deviceInfo->GetManufacturerName(sysUtilManuName);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1268
    
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1269
    //To overlap info 
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1270
    if (gotSysUtilManuName == KErrNone)
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1271
        {
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1272
        iDeviceConfiguration.iManufacturerName->Des().Copy(sysUtilManuName); 
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1273
        }
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1274
        
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1275
    if (gotSysUtilModelName == KErrNone)
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1276
        {
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1277
        iDeviceConfiguration.iProductName->Des().Copy(sysUtilModelName);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1278
        }
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1279
    CleanupStack::PopAndDestroy(deviceInfo);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1280
    iPersonalityCfged = ETrue;
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1281
    OstTraceFunctionExit0( CUSBDEVICE_READPERSONALITIESL_EXIT );
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1282
    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1283
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
void CUsbDevice::SelectClassControllersL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
 * Selects class controllers for the current personality
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1288
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1289
	OstTraceFunctionEntry0( CUSBDEVICE_SELECTCLASSCONTROLLERSL_ENTRY );
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1290
    const RArray<CPersonalityConfigurations::TUsbClasses>& classes = iCurrentPersonality->SupportedClasses();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1291
	RArray<TUid> classUids;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1292
	CleanupClosePushL( classUids ); 
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1293
    TInt classCount = classes.Count();
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1294
	for(TInt classIndex = 0; classIndex<classCount; ++classIndex)
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1295
	    {
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1296
        TUid uid = classes[classIndex].iClassUid;
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1297
        classUids.AppendL(uid);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1298
	    }
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1299
	
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1300
	CreateClassControllersL(classUids);
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1301
	
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1302
    CleanupStack::PopAndDestroy( &classUids );
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1303
	OstTraceFunctionExit0( CUSBDEVICE_SELECTCLASSCONTROLLERSL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1305
#ifdef USE_DUMMY_CLASS_CONTROLLER	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
void CUsbDevice::CreateClassControllersL(const RArray<TUid>& /* aClassUids*/)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1307
#else 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1308
void CUsbDevice::CreateClassControllersL(const RArray<TUid>& aClassUids)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
#endif
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
 * Creates a class controller object for each class uid
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1313
 * @param aClassUids an array of class uids
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1314
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1315
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1316
	OstTraceFunctionEntry0( CUSBDEVICE_CREATECLASSCONTROLLERSL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1317
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1318
#ifndef USE_DUMMY_CLASS_CONTROLLER
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1319
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1320
	//create a TLinearOrder to supply the comparison function, Compare(), to be used  
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1321
	//to determine the order to add class controllers
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1322
	TLinearOrder<CUsbClassControllerBase> order(CUsbClassControllerBase::Compare);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1323
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1324
	TInt count = aClassUids.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1325
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1326
	// destroy any class controller objects in iSupportedClasses and reset it for reuse
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1327
	iSupportedClasses.ResetAndDestroy();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1328
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_CREATECLASSCONTROLLERSL, "CUsbDevice::CreateClassControllersL;aClassUids.Count() = %d", count );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1329
	for (TInt i = 0; i < count; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1330
		{ 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1331
		CUsbClassControllerPlugIn* plugIn = CUsbClassControllerPlugIn::NewL(aClassUids[i], *this);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1332
		AddClassControllerL(reinterpret_cast<CUsbClassControllerBase*>(plugIn), order);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1333
		} 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1334
#endif // USE_DUMMY_CLASS_CONTROLLER	
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1335
	TInt err = iUsbClassControllerIterator->First();	
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1336
	if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1337
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1338
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_CREATECLASSCONTROLLERSL_DUP1, "CUsbDevice::CreateClassControllersL;iUsbClassControllerIterator->First() with error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1339
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1340
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
void CUsbDevice::SetDefaultPersonalityL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1344
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1345
 * Sets default personality. Used for Start request.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1347
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1348
	OstTraceFunctionEntry0( CUSBDEVICE_SETDEFAULTPERSONALITYL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1350
	TInt smallestId = iSupportedPersonalities[0]->PersonalityId();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1351
 	TInt count = iSupportedPersonalities.Count();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1352
 	for (TInt i = 1; i < count; i++)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
 		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
 		if(iSupportedPersonalities[i]->PersonalityId() < smallestId)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1355
 			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
 			smallestId = iSupportedPersonalities[i]->PersonalityId();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
 			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1358
 		}
26
f3a1ae528dee 201025_03
hgs
parents: 25
diff changeset
  1359
    
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1360
	SetCurrentPersonalityL(smallestId);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1361
	SelectClassControllersL();
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1362
	OstTraceFunctionExit0( CUSBDEVICE_SETDEFAULTPERSONALITYL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1363
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1364
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1365
void CUsbDevice::LoadFallbackClassControllersL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1366
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1367
 * Load class controllers for fallback situation:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1368
 * no personalities are configured.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1369
 * This method inserts all class controllers to 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
 * the list from which they will be either all started
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
 * or stopped
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1372
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1374
	OstTraceFunctionEntry0( CUSBDEVICE_LOADFALLBACKCLASSCONTROLLERSL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
 	SetDeviceDescriptorL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
	CreateClassControllersL(iSupportedClassUids);
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1377
 	OstTraceFunctionExit0( CUSBDEVICE_LOADFALLBACKCLASSCONTROLLERSL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
 	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
RDevUsbcClient& CUsbDevice::MuepoDoDevUsbcClient()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
 * Inherited from MUsbmanExtensionPluginObserver - Function used by plugins to
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
 * retrieve our handle to the LDD
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
 * @return The LDD handle
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1388
	return iLdd;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1389
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1391
void CUsbDevice::MuepoDoRegisterStateObserverL(MUsbDeviceNotify& aObserver)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1392
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1393
 * Inherited from MUsbmanExtensionPluginObserver - Function used by plugins to
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
 * register themselves for notifications of device/service state changes.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
 * @param aObserver New Observer of the device
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 26
diff changeset
  1399
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_MUEPODOREGISTERSTATEOBSERVERL, "CUsbDevice::MuepoDoRegisterStateObserverL;aObserver = 0x%08x", &aObserver );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
	RegisterObserverL(aObserver);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1401
	}
49
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1402
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1403
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1404
#ifdef SYMBIAN_USB_BATTERYCHARGING_V1_1
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1405
void CUsbDevice::MuepoDoRegisterChargingObserverL(MUsbChargingNotify& aObserver)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1406
/**
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1407
 * Inherited from MUsbmanExtensionPluginObserver - Function used by plugins to
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1408
 * register themselves for notifications of charging changes.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1409
 *
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1410
 * @param aObserver New Observer of the device
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1411
 */
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1412
	{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1413
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_MUEPODOREGISTERCHARGINGOBSERVERL, "CUsbDevice::MuepoDoRegisterChargingObserverL;aObserver = 0x%08x", &aObserver );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1414
	RegisterChargingInfoObserverL(aObserver);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1415
	}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1416
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1417
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1418
void CUsbDevice::RegisterChargingInfoObserverL(MUsbChargingNotify& aObserver)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1419
/**
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1420
 * Register an observer of charging.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1421
 * Presently, the device supports watching state.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1422
 *
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1423
 * @param	aObserver	New Observer of the charging
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1424
 */
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1425
	{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1426
	OstTraceFunctionEntry0( CUSBDEVICE_REGISTERCHARGINGINFOOBSERVERL_ENTRY );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1427
	TInt err = iChargingObservers.Append(&aObserver);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1428
	if(err < 0)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1429
	    {
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1430
        OstTrace1( TRACE_NORMAL, CUSBDEVICE_REGISTERCHARGINGINFOOBSERVERL, "CUsbDevice::RegisterObserverL;iObservers.Append(&aObserver) with err=%d", err );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1431
        User::Leave(err);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1432
	    }
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1433
	OstTraceFunctionExit0( CUSBDEVICE_REGISTERCHARGINGINFOOBSERVERL_EXIT );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1434
	}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1435
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1436
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1437
void CUsbDevice::DeRegisterChargingInfoObserver(MUsbChargingNotify& aObserver)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1438
/**
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1439
 * De-registers an existing charging observer.
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1440
 *
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1441
 * @param	aObserver	The existing device observer to be de-registered
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1442
 */
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1443
	{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1444
	OstTraceFunctionEntry0( CUSBDEVICE_DEREGISTERCHARGINGINFOOBSERVERL_ENTRY );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1445
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1446
	TInt index = iChargingObservers.Find(&aObserver);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1447
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1448
	if (index >= 0)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1449
		iObservers.Remove(index);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1450
	OstTraceFunctionExit0( CUSBDEVICE_DEREGISTERCHARGINGINFOOBSERVERL_EXIT );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1451
	}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1452
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1453
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1454
void CUsbDevice::SetChargingPortType(TUsbcChargingPortType aChargingPortType)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1455
	{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1456
	OstTraceFunctionEntry0( CUSBDEVICE_SETCHARGINGPORTTYPE_ENTRY );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1457
	TUint length = iChargingObservers.Count();
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1458
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1459
	for (TUint i = 0; i < length; i++)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1460
		{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1461
		iChargingObservers[i]->UsbChargingPortType(aChargingPortType);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1462
		}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1463
	OstTraceFunctionExit0( CUSBDEVICE_SETCHARGINGPORTTYPE_EXIT );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1464
	}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1465
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1466
void CUsbDevice::PeerDeviceMaxPower(TUint aCurrent)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1467
	{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1468
	OstTraceFunctionEntry0( CUSBDEVICE_PEERDEVICEMAXPOWER_ENTRY );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1469
	OstTrace1( TRACE_NORMAL, CUSBDEVICE_PEERDEVICEMAXPOWER_DUP, "CUsbDevice::PeerDeviceMaxPower with aCurrent=%d", aCurrent);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1470
	TUint length = iChargingObservers.Count();
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1471
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1472
	for (TUint i = 0; i < length; i++)
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1473
		{
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1474
		iChargingObservers[i]->PeerDeviceMaxPower(aCurrent);
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1475
		}		
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1476
	OstTraceFunctionExit0( CUSBDEVICE_PEERDEVICEMAXPOWER_EXIT );
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1477
	}
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1478
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1479
#endif
93c0009bd947 201036_01
hgs
parents: 48
diff changeset
  1480