usbmgmt/usbmgr/usbman/server/SRC/CUsbDummyClassController.cpp
author hgs
Wed, 07 Jul 2010 15:08:54 +0800
changeset 29 59aa7d6e3e0f
parent 0 c9bc50fca66e
child 43 012cc2ee6408
child 48 21625e5de155
permissions -rw-r--r--
201026_03
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
* Implements part of UsbMan USB Class Framework.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
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
 @file
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <usb_std.h>
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <usb/usblogger.h>
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    25
#include "CUsbDummyClassController.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    26
#include "inifile.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    27
#include "OstTraceDefinitions.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    28
#ifdef OST_TRACE_COMPILER_IN_USE
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    29
#include "CUsbDummyClassControllerTraces.h"
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    30
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    32
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
_LIT(KDummyControllerPanic, "UsbDummyCC"); // must be <=16 chars
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
// Panic codes
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
enum
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
	// Bad value for the iSynchronicity member.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
	EDummyPanicBadSynchronicity = 0,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
	// Used for environment errors we do not handle.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
	EDummyPanicUnhandledError = 1,
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
	// Used for bad iStatus and other state errors.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
	EDummyPanicBadState = 2,
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
	// Error reading ini file.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	EDummyPanicBadIniFile = 3,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	// We already have our async request active.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	EDummyPanicAlreadyActive = 4,
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
	// We already have a request outstanding from the device class. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
	EDummyPanicOutstandingRequestFromDevice = 5,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	// Attempt to call Start() when in illegal state
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
	EDummyPanicBadApiCallStart = 6,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
	// Attempt to call Stop() when in illegal state
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
	EDummyPanicBadApiCallStop = 7,
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
const TInt KDummyClassPriority = 1;
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
// Keys for reading the ini file.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
_LIT(KStartup, "Startup");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
_LIT(KShutdown, "Shutdown");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
_LIT(KType, "Type");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
_LIT(KTime, "Time");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
_LIT(KError, "Error");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
_LIT(KSync, "sync");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
_LIT(KAsync, "async");
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
_LIT(KNever, "never");
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
CUsbDummyClassController* CUsbDummyClassController::NewL(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
		MUsbClassControllerNotify& aOwner,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
		TUint aIndex)
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
 * Constructs a CUsbDummyClassController 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
 * @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
    82
 * @param aIndex The index number of the instance
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
 * @return Ownership of a new CUsbDummyClassController object
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    86
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_NEWL_MUSBCLASSCONTROLLERNOTIFY_TUINT_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	CUsbDummyClassController* self = new(ELeave) CUsbDummyClassController(aOwner, aIndex);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	CleanupStack::PushL(self);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
	self->ConstructL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
	CleanupStack::Pop(self);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
    92
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_NEWL_MUSBCLASSCONTROLLERNOTIFY_TUINT_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
	return self;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	}
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
CUsbDummyClassController* CUsbDummyClassController::NewL(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	MUsbClassControllerNotify& aOwner, 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
	TUint aIndex, TInt aPriority)
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
 * Constructs a CUsbDummyClassController object.
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
 * @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
   104
 * @param aIndex The index number of the instance
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
 * @param aPriority The startup priority of the instance
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
 * @return Ownership of a new CUsbDummyClassController object
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
 	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   109
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_NEWL_MUSBCLASSCONTROLLERNOTIFY_TUINT_TINT_ENTRY );
0
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
 	CUsbDummyClassController* self = new(ELeave) CUsbDummyClassController(aOwner, aIndex, aPriority);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	CleanupStack::PushL(self);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
	self->ConstructL();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	CleanupStack::Pop(self);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   115
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_NEWL_MUSBCLASSCONTROLLERNOTIFY_TUINT_TINT_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	return self;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
 	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
CUsbDummyClassController::CUsbDummyClassController(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
		MUsbClassControllerNotify& aOwner,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
		TUint aIndex)
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
 * Constructor.
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
 * @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
   126
 * @param aIndex The index number of the instance
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
 :	CUsbClassControllerBase(aOwner, KDummyClassPriority),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	iIndex(aIndex)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
	iState = EUsbServiceIdle; // needs explicit initialisation as non-zero
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
CUsbDummyClassController::CUsbDummyClassController(
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
		MUsbClassControllerNotify& aOwner,
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
		TUint aIndex, TInt aPriority)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
 * Constructor.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
 * @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
   142
 * @param aIndex The index number of the instance
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
 * @param aPriority a startup priority for the class controller
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
 : 	CUsbClassControllerBase(aOwner, aPriority),
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
 	iIndex(aIndex)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
 	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
 	iState = EUsbServiceIdle; // needs explicit initialisation as non-zero
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
 	}
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
void CUsbDummyClassController::ConstructL()
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
 * Method to perform second phase construction.
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   156
    TInt err = iTimer.CreateLocal();
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   157
    if(err < 0)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   158
        {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   159
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_CONSTRUCTL, "CUsbDummyClassController::ConstructL; iTimer.CreateLocal() error, Leave error=%d", err );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   160
        User::Leave(err);
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   161
        }
0
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
CUsbDummyClassController::~CUsbDummyClassController()
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
 * Destructor.
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
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	Cancel();
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
	iTimer.Close();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	}
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
void CUsbDummyClassController::GetBehaviour(CIniFile& aIniFile, 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
											const TDesC& aSection, 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
											TBehaviour& aBehaviour)
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
 * Reads information from the ini file, from a given section, to the given 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
 * behaviour structure.
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
 * @param aIniFile The ini file to read from.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
 * @param aSection The section to reads from.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
 * @param aBehaviour The behaviour struct to read to.
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   186
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   187
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   188
	OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR,
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   189
	        "CUsbDummyClassController::GetBehaviour;aSection=%S", aSection );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   190
#endif//_DEBUG
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
	TPtrC temp;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
	if ( !aIniFile.FindVar(aSection, KType(), temp) )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   195
		OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   196
		        "CUsbDummyClassController::GetBehaviour;PANICKING: can't find Type item in section %S", aSection );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   197
		OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP2, "CUsbDummyClassController::GetBehaviour; panic code=%d", EDummyPanicBadIniFile );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   198
		User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
	if ( temp == KSync )
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
		aBehaviour.iSynchronicity = ESynchronous;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
	else if ( temp == KAsync )
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
		aBehaviour.iSynchronicity = EAsynchronous;
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
	else if ( temp == KNever )
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
		aBehaviour.iSynchronicity = ENever;
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
	else
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
		OstTraceExt2( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP3, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   215
		        "CUsbDummyClassController::GetBehaviour;PANICKING: bad Type value (%S) in section %S", temp, aSection );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   216
		OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP4, "CUsbDummyClassController::GetBehaviour; panic code=%d", EDummyPanicBadIniFile );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   217
		User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	TInt delay;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
	if ( !aIniFile.FindVar(aSection, KTime(), delay) )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   222
		OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP5, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   223
		        "CUsbDummyClassController::GetBehaviour;PANICKING: can't find Time item in section %S", aSection );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   224
		OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP6, "CUsbDummyClassController::GetBehaviour;panic code=%d", EDummyPanicBadIniFile );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   225
		User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
	aBehaviour.iDelay = delay;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
	if ( !aIniFile.FindVar(aSection, KError(), aBehaviour.iErrorCode) )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   230
		OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP7, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   231
		        "CUsbDummyClassController::GetBehaviour;aSection=%S", aSection );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   232
		OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP8, "CUsbDummyClassController::GetBehaviour;panic code=%d", EDummyPanicBadIniFile );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   233
		User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   235
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
void CUsbDummyClassController::DoGetConfigL()
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
 * Reads the config from the ini file.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   243
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_DOGETCONFIGL_ENTRY );
0
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
	CIniFile* iniFile = CIniFile::NewL(_L("dummy.ini"));
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
	CleanupStack::PushL(iniFile);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
	TName section;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
	// Read startup behaviour
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
	section.Format(_L("%S.%d"), &KStartup(), iIndex);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	GetBehaviour(*iniFile, section, iStartupBehaviour);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	// Read shutdown behaviour
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
	section.Format(_L("%S.%d"), &KShutdown(), iIndex);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
	GetBehaviour(*iniFile, section, iShutdownBehaviour);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
	CleanupStack::PopAndDestroy(iniFile);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   257
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_DOGETCONFIGL_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
void CUsbDummyClassController::GetConfig()
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
 * Reads the config from the ini file.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
 * Note that this is assumed to succeed. Any failure will break the test and 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
 * it's much cleaner to panic out of the test entirely rather than leave it to 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
 * the user to figure out what's gone wrong.
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   268
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_GETCONFIG_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
	// Always use dummy.ini. The entity setting up the test is responsible for 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
	// copying the correct file to c:\\dummy.ini. The first found 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
	// by FindByDir will be used. TODO: enforce c:\\.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
	TRAPD(err, DoGetConfigL());
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
	if ( err != KErrNone )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
		{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   276
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP7, "CUsbDummyClassController::GetConfig;panic code=%d", EDummyPanicUnhandledError );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   277
		User::Panic(KDummyControllerPanic, EDummyPanicUnhandledError);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
	
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   280
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   281
	        "CUsbDummyClassController::GetConfig; Logging dummy class controller behaviour for instance %d", iIndex );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   282
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP1, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   283
	        "CUsbDummyClassController::GetConfig;iStartupBehaviour.iSynchronicity=%d", iStartupBehaviour.iSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   284
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP2, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   285
	        "CUsbDummyClassController::GetConfig;iStartupBehaviour.iDelay.Int()=%d", iStartupBehaviour.iDelay.Int() );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   286
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP3, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   287
	        "CUsbDummyClassController::GetConfig;iStartupBehaviour.iErrorCode=%d", iStartupBehaviour.iErrorCode );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   288
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP4, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   289
	        "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iSynchronicity=%d", iShutdownBehaviour.iSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   290
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP5, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   291
	        "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iDelay.Int()=%d", iShutdownBehaviour.iDelay.Int() );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   292
	OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP6, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   293
	        "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iErrorCode=%d", iShutdownBehaviour.iErrorCode );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   294
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_GETCONFIG_EXIT );
0
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
void CUsbDummyClassController::Start(TRequestStatus& aStatus)
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
 * Called by UsbMan to start this class.
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
 * @param aStatus Will be completed with success or failure.
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   304
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_START_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   305
	
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   306
	//Start() should only be called if the CC is idle or started	
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
	
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   308
	if(!(iState == EUsbServiceIdle || iState == EUsbServiceStarted))
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   309
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   310
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicBadApiCallStart );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   311
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   312
                User::Panic(KDummyControllerPanic, EDummyPanicBadApiCallStart) );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   313
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
	// Get config from ini file. Note that can't be done once in ConstructL 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
	// because then, in the case of a CC which doesn't Stop, we'd never be 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
	// able to shut down USBMAN!
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
	GetConfig();
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
	// NB We enforce that the device doesn't re-post requests on us.
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   321
	if(iReportStatus)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   322
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   323
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP1, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicOutstandingRequestFromDevice );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   324
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   325
                User::Panic(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   326
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
	aStatus = KRequestPending;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
	iReportStatus = &aStatus;
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
	iState = EUsbServiceStarting;
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
	switch ( iStartupBehaviour.iSynchronicity )
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
	case ESynchronous:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
		User::After(iStartupBehaviour.iDelay);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
		iState = EUsbServiceStarted;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
		User::RequestComplete(iReportStatus, iStartupBehaviour.iErrorCode);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
		iReportStatus = NULL;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
		break;
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
	case EAsynchronous:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
		iTimer.After(iStatus, iStartupBehaviour.iDelay);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   343
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   344
		if(IsActive())
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   345
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   346
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP2, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicAlreadyActive );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   347
            User::Panic(KDummyControllerPanic, EDummyPanicAlreadyActive);
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   348
		    }
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   349
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
		SetActive();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
	case ENever:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
		// Don't do anything and never complete
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
		break;
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
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   358
	    OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP3, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   359
	    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   362
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_START_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
	}
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
void CUsbDummyClassController::Stop(TRequestStatus& aStatus)
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
 * Called by UsbMan to stop this class.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
 *
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
 * @param aStatus Will be completed with success or failure.
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   372
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_STOP_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
		
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
	//Stop() should only be called if the CC is Started or Idle
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   375
	if(!(iState == EUsbServiceStarted || iState == EUsbServiceIdle))
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   376
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   377
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicBadApiCallStop );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   378
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   379
                User::Panic(KDummyControllerPanic, EDummyPanicBadApiCallStop));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   380
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
	// Get config from ini file. Note that can't be done once in ConstructL 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
	// because then, in the case of a CC which doesn't Stop, we'd never be 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
	// able to shutdown USBMAN!
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
	GetConfig();
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
	// NB We enforce that the device doesn't re-post requests on us.
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   388
	if(iReportStatus)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   389
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   390
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP_DUP1, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicOutstandingRequestFromDevice );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   391
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   392
                User::Panic(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   393
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
	aStatus = KRequestPending;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
	iReportStatus = &aStatus;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
	iState = EUsbServiceStopping;
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
	switch ( iShutdownBehaviour.iSynchronicity )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
	case ESynchronous:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
		User::After(iShutdownBehaviour.iDelay);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
		iState = EUsbServiceIdle;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
		User::RequestComplete(iReportStatus, iShutdownBehaviour.iErrorCode);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
		iReportStatus = NULL;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
	case EAsynchronous:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
		iTimer.After(iStatus, iShutdownBehaviour.iDelay);
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   410
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   411
    	if(IsActive())
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   412
    	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   413
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP_DUP2, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicAlreadyActive );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   414
            User::Panic(KDummyControllerPanic, EDummyPanicAlreadyActive);
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   415
    	    }
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   416
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
		SetActive();
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
	case ENever:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
		// Don't do anything and never complete
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   425
	    OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP_DUP3, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   426
	    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
		}
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   429
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_STOP_EXIT );
0
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
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
void CUsbDummyClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const
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
 * Returns information about the interfaces supported by this class.
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
 * @param aDescriptorInfo Will be filled in with interface information.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
	{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
	aDescriptorInfo.iNumInterfaces = 0;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
	aDescriptorInfo.iLength = 0;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
void CUsbDummyClassController::RunL()
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
 * Standard active object RunL. 
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
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   448
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_RUNL_ENTRY );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   449
	OstTraceExt2( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_RUNL, "CUsbDummyClassController::RunL;iStatus.Int()=%d;iState=%d", iStatus.Int(), iState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   450
0
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
	if ( iStatus != KErrNone )
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
		// Panic runtime errors from the timer. We can't ignore them, and 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
		// there's no point trying to code round them. This is part of the 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
		// test framework and if it's failing we want to alert the user 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
		// without faffing around. (It invalidates the test.)
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   458
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP1, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicUnhandledError );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   459
        User::Panic(KDummyControllerPanic, EDummyPanicUnhandledError);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
		}								  
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   462
	if(!iReportStatus)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   463
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   464
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP2, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   465
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   466
                User::Panic(KDummyControllerPanic, EDummyPanicBadState));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   467
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
	switch ( iState )
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
		{
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
	case EUsbServiceStarting:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
		// Completion of asynchronous startup...
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   473
		if(iStartupBehaviour.iSynchronicity != EAsynchronous)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   474
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   475
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP3, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   476
            __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   477
                    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   478
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
		iState = EUsbServiceStarted;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
		User::RequestComplete(iReportStatus, iStartupBehaviour.iErrorCode);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
		iReportStatus = NULL;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
		break;
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
	case EUsbServiceStopping:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
		// Completion of asynchronous shutdown...
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   486
		if(iShutdownBehaviour.iSynchronicity != EAsynchronous)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   487
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   488
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP4, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   489
            __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   490
                    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   491
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
		iState = EUsbServiceIdle;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
		User::RequestComplete(iReportStatus, iShutdownBehaviour.iErrorCode);
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
		iReportStatus = NULL;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
	case EUsbServiceIdle:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
	case EUsbServiceStarted:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   500
	    OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP5, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   501
	    User::Panic(KDummyControllerPanic, EDummyPanicBadState);
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
		break;
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
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   505
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_RUNL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
	}
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
void CUsbDummyClassController::DoCancel()
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
 * Standard active object cancellation function. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   513
	OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_DOCANCEL_ENTRY );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
	// Note that CActive::Cancel does not call DoCancel unless we are active. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
	// Therefore we are at this point active. Therefore, we should have 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
	// iReportStatus pointing to something. This is true whether we are in 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
	// our destructor or being cancelled by the device. It is also true that 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
	// (for us to be active at all) our synchronicity should be set to async 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
	// and the timer must have been CreateLocal'd successfully.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
	// Cancel may be called in one of the following situations: 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
	// 1/ In our destructor. 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
	// 2/ The device wants to cancel us in the middle of a Start before 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
	// issuing a Stop (or vice versa). Note that the device may cancel us in 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
	// the middle of a Start, then immediately issue another Start.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
	
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
	// Cancel our own asynchronous operation.
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   529
#ifdef _DEBUG
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   530
	if(!iTimer.Handle())
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   531
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   532
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState ); 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   533
                User::Panic(KDummyControllerPanic, EDummyPanicBadState);
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   534
	    }
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   535
#endif
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
	iTimer.Cancel();
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
	// Update our iState. If we're starting, then roll back to idle. If we're 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
	// stopping, role back to started. Nothing else is legal.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
	switch ( iState )
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
	case EUsbServiceStarting:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   543
		if(iStartupBehaviour.iSynchronicity != EAsynchronous)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   544
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   545
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP1, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   546
            __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   547
                    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   548
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
		iState = EUsbServiceIdle;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
	case EUsbServiceStopping:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   553
		if(iShutdownBehaviour.iSynchronicity != EAsynchronous)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   554
		    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   555
            OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP2, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadSynchronicity );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   556
            __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   557
                    User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   558
		    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
		iState = EUsbServiceStarted;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
		break;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
	case EUsbServiceIdle:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
	case EUsbServiceStarted:
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
	default:
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   565
	    OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP3, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   566
	    User::Panic(KDummyControllerPanic, EDummyPanicBadState);
0
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
		}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   570
	// Complete the client's request.
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   571
	if(!iReportStatus)
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   572
	    {
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   573
        OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP4, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   574
        __ASSERT_DEBUG(EFalse, 
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   575
                User::Panic(KDummyControllerPanic, EDummyPanicBadState));
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   576
	    }
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
	User::RequestComplete(iReportStatus, KErrCancel); 
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
	iReportStatus = NULL;
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   579
	OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_DOCANCEL_EXIT );
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
TInt CUsbDummyClassController::RunError(TInt /*aError*/)
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
/**
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
 * Standard active object error-handling function. 
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
 * Should return KErrNone to avoid an active scheduler panic. This function
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
 * should never be called as there is another mechanism for catching errors.
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
 */
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
	{
29
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   590
    OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNERROR, "CUsbDummyClassController::RunError;panic code=%d", EDummyPanicBadState );
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   591
    __ASSERT_DEBUG(EFalse,
59aa7d6e3e0f 201026_03
hgs
parents: 0
diff changeset
   592
            User::Panic(KDummyControllerPanic, EDummyPanicBadState));
0
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
	return KErrNone;
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
	}
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
//
c9bc50fca66e Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
// End of file