usbmgmt/usbmgrtest/t_usbmanager_suite/Stub3CC/src/Stub3CC.cpp
author hgs
Thu, 16 Sep 2010 12:03:29 +0800
changeset 49 93c0009bd947
parent 29 59aa7d6e3e0f
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
/*
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
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
* Adheres to the UsbMan USB Class Controller API and talks to C32
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
* to manage the stub3.CSY that is used to provide a virtual
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
* serial port service to clients
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
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
 @file
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <usb_std.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <es_ini.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <d32usbc.h>
49
93c0009bd947 201036_01
hgs
parents: 29
diff changeset
    28
#include <usb/usbmaninternalconstants.h>
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    29
#include "Stub3CC.h"
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#ifdef __FLOG_ACTIVE
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
_LIT8(KLogComponent, "STUB3CC");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#endif
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
49
93c0009bd947 201036_01
hgs
parents: 29
diff changeset
    36
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    37
#include "OstTraceDefinitions.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    38
#ifdef OST_TRACE_COMPILER_IN_USE
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    39
#include "Stub3CCTraces.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    40
#endif
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    41
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
// Panic category 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
_LIT( Kstub3CcPanicCategory, "Usbstub3Cc" );
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
 * Panic codes for the USB stub3 Class Controller.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
enum Tstub3CcPanic
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
	/** Class called while in an illegal state */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
	EBadApiCall = 0,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	/** Asynchronous function called (not needed, as all requests complete synchronously) */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	EUnusedFunction = 1,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
	/** Error reading ini file. */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	EPanicBadIniFile = 2,		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
	/** Bad value for the iNumberOfstub3Functions member.*/
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
	EPanicBadNumberOfstub3Functions = 3,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
	EPanicUnexpectedStatus,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
	EPanicUnexpectedState
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
	};
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
_LIT16(KIfcName, "SubCC 1 Interface");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
const TInt KMaxPacketTypeInterrupt = 64;	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
const TInt KPollInterval  = 128; 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
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
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
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
 * Constructs a CUsbstub3ClassController object
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
 * @param	aOwner	USB Device that owns and manages the class
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
 * @return	A new CUsbstub3ClassController object
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
CUsbstub3ClassController* CUsbstub3ClassController::NewL(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
	MUsbClassControllerNotify& aOwner)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
	CUsbstub3ClassController* r = new (ELeave) CUsbstub3ClassController(aOwner);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
	CleanupStack::PushL(r);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
	r->ConstructL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	CleanupStack::Pop();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	return r;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
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
 * Destructor
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
CUsbstub3ClassController::~CUsbstub3ClassController()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
	Cancel();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	iTimer.Close();
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
#ifndef __WINS__	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
	iLdd.Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
#endif
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
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
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
 * Constructor.
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
 * @param	aOwner	USB Device that owns and manages the class
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
CUsbstub3ClassController::CUsbstub3ClassController(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	MUsbClassControllerNotify& aOwner)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
	: CUsbClassControllerPlugIn(aOwner, Kstub3StartupPriority),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	iStartDelay(Kstub3CCDefaultDelay),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
	iStopDelay(Kstub3CCDefaultDelay),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
	iFailToStart(EFalse),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
	iFailToStop(EFalse)	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
	iTimer.CreateLocal();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
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
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
 * 2nd Phase Construction.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
void CUsbstub3ClassController::ConstructL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
	//read INI file
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
	TInt ret;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
	CESockIniData* ini = 0;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
	_LIT(KIniFile, "c:\\testdata\\config\\stub3cc.ini");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
	TRAP(ret, ini=CESockIniData::NewL(KIniFile));	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
	if(ret!=KErrNone)		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
		return;	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
	CleanupStack::PushL(ini);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
	TInt val;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
	if ((ini->FindVar(_L("0x10203289"),_L("StartDelay"), val)))
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
		iStartDelay = val;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
	if ((ini->FindVar(_L("0x10203289"),_L("StopDelay"), val)))
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
		iStopDelay = val;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
	if ((ini->FindVar(_L("0x10203289"),_L("FailToStart"), val)) && val!=0)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
		iFailToStart = ETrue;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
	if ((ini->FindVar(_L("0x10203289"),_L("FailToStop"), val)) && val!=0 )
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
		iFailToStop = ETrue;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
	CleanupStack::PopAndDestroy(ini);						
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
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
 * Called by UsbMan when it wants to start the USB stub3 class. This always
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
 * completes immediately.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
 * @param aStatus The caller's request status, filled in with an error code
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
void CUsbstub3ClassController::Start(TRequestStatus& aStatus)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   170
    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_START_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   171
    
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	aStatus = KRequestPending;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	iReportStatus = &aStatus;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
	//If we are already started then just complete the request.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
	if (iState == EUsbServiceStarted)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
		User::RequestComplete(iReportStatus, KErrNone);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   178
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
		return;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
	if (iFailToStart)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
		User::RequestComplete(iReportStatus, KErrGeneral);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   185
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP1 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
		return;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	iState = EUsbServiceStarting;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
#ifndef __WINS__	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
	TInt ret = iLdd.Open(0);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   193
	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START, _L8("Open LDD, ret=%d"), ret );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   194
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
	ret = SetUpInterface();
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   196
	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   197
	        _L8("SetUpInterface(), ret=%d"), ret );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   198
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
#endif	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
	iTimer.After(iStatus, iStartDelay*1000);  //convert from usec to msec
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
	SetActive();
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   204
	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP2 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
 * Called by UsbMan when it wants to stop the USB stub3 class.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
 * @param aStatus The caller's request status: always set to KErrNone
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
void CUsbstub3ClassController::Stop(TRequestStatus& aStatus)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   214
	OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_STOP_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   215
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
	aStatus = KRequestPending;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
	iReportStatus = &aStatus;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
	//If we are already idle then just complete the request.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	if (iState == EUsbServiceIdle)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
		User::RequestComplete(iReportStatus, KErrNone);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   222
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
		return;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
	if (iFailToStop)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
		User::RequestComplete(iReportStatus, KErrGeneral);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   229
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP1 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
		return;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
	iState = EUsbServiceStopping;
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
#ifndef __WINS__	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
	iLdd.Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
#endif
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
	iTimer.After(iStatus, iStopDelay*1000);  //convert from usec to msec
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
	SetActive();
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   242
	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP2 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
 * Gets information about the descriptor which this class provides.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
 * @param aDescriptorInfo Descriptor info structure filled in by this function
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
void CUsbstub3ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   252
    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   253
    
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
	aDescriptorInfo.iLength = Kstub3DescriptorLength;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
	aDescriptorInfo.iNumInterfaces = Kstub3NumberOfInterfacesPerstub3Function;
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   256
	
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   257
	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
 * Standard active object RunL. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
void CUsbstub3ClassController::RunL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   266
    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_RUNL_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   267
    
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   268
    if(iStatus != KErrNone)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   269
        {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   270
            OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   271
                    "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   272
            __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   273
        }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
	switch (iState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
		case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
			iState = EUsbServiceStarted;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
			break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
		case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
			iState = EUsbServiceIdle;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
			break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
		default:	
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   283
		    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   284
		             "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   285
		    User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
	*iReportStatus = KErrNone;	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	User::RequestComplete(iReportStatus, iStatus.Int());	
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   289
	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_RUNL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
 * Standard active object cancellation function. Never called because this
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
 * class has no asynchronous requests.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
void CUsbstub3ClassController::DoCancel()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
	if (IsActive())
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
		iTimer.Cancel();	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
	switch (iState)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
		case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
			iState = EUsbServiceIdle;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
			break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
		case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
			iState = EUsbServiceStarted;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
			break;
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   311
		default:
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   312
		    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_DOCANCEL, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   313
		            "CUsbstub3ClassController::DoCancel panic with error %d", EPanicUnexpectedStatus );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   314
		    User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
	*iReportStatus = KErrNone;		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
	User::RequestComplete(iReportStatus, KErrCancel);	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
	}
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
 * Standard active object error function. Never called because this class has
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
 * no asynchronous requests, and hence its RunL is never called.
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
 * @param aError The error code (unused)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
 * @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
   326
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
TInt CUsbstub3ClassController::RunError(TInt /*aError*/)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   329
    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNERROR, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   330
             "CUsbstub3ClassController::RunError panic with error %d", EUnusedFunction );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   331
    __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EUnusedFunction));
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
	return KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
TInt CUsbstub3ClassController::SetUpInterface()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
 * Set up the interface for use. This involves finding a "Interrupt IN" 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
 * endpoint and, if found, configuring the interface.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   341
    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   342
    
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
	TUsbDeviceCaps dCaps;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
	TInt ret = iLdd.DeviceCaps(dCaps);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   345
	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE,
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   346
	        _L8("\tchecking result of DeviceCaps"));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   347
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
	if ( ret )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   350
        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   351
                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   352
        
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   353
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
		return ret;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
		}
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
	const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
	const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   360
	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP2, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   361
	        _L8("\tiTotalEndpoints = %d"), totalEndpoints );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   362
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
	if ( totalEndpoints < KRequiredNumberOfEndpoints )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   365
        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP3, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   366
                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   367
        
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   368
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP1 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
		return KErrGeneral;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
	// Endpoints
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
	TUsbcEndpointData data[KUsbcMaxEndpoints];
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
	ret = iLdd.EndpointCaps(dataptr);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   376
	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP4,
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   377
	        _L8("\tchecking result of EndpointCaps"));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   378
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
	if ( ret )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   381
        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP5, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   382
                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   383
        
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   384
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP2 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
		return ret;
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
	// Set the active interface
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
	TUsbcInterfaceInfoBuf ifc;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
	TBool epFound = EFalse;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
	for ( TUint i = 0 ; i < totalEndpoints ; i++ )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
		const TUsbcEndpointCaps* caps = &data[i].iCaps;
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   394
		if(!caps)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   395
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   396
                OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP6, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   397
                        "CUsbstub3ClassController::SetUpInterface panic with error %d", 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   398
                        EPanicUnexpectedStatus );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   399
                __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   400
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
		if (data[i].iInUse)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
			continue;
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
		if ((caps->iTypesAndDir & (KUsbEpTypeInterrupt | KUsbEpDirIn)) == 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
			(KUsbEpTypeInterrupt | KUsbEpDirIn))
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
			{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
			// EEndpoint1 is interrupt endpoint
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
			ifc().iEndpointData[0].iType  = KUsbEpTypeInterrupt;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
			ifc().iEndpointData[0].iDir   = KUsbEpDirIn; 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
			//get the max packet size it can potentially support
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
			//it's possible that it can support Isoch (1023) which is greater
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
			//than max for Int at 64
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
			TInt maxSize = Min(caps->MaxPacketSize(), KMaxPacketTypeInterrupt);
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
			ifc().iEndpointData[0].iSize  = maxSize;
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
			ifc().iEndpointData[0].iInterval = KPollInterval; 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
			epFound = ETrue;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
			break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
			}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   426
	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP7, _L8("\tchecking epFound"));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   427
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
	if ( !epFound )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   430
        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP8, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   431
                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral);
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   432
        
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   433
		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP3 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
		return KErrGeneral;
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
	TName ifcName(KIfcName);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
	ifc().iString = &ifcName;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
	ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
	// Codes taken from USBCDC 1.1.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
	ifc().iClass.iClassNum	  = 0x02; // Table 15- Communication Interface Class
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
	ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
	ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   445
	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP9,
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   446
	        _L8("\tabout to call SetInterface"));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   447
	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
	// Zero effectively indicates that alternate interfaces are not used.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
	ret = iLdd.SetInterface(0, ifc);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   451
	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP10, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   452
	        _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   453
	
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   454
	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP4 );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
	return ret;
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
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
// End of file