59
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
49
|
17 |
|
|
18 |
#include "usbstatewatcher.h"
|
|
19 |
#include <e32cmn.h>
|
|
20 |
#include "testmanager.h"
|
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "usbstatewatcherTraces.h"
|
|
24 |
#endif
|
|
25 |
|
|
26 |
|
|
27 |
CUsbStateWatcher* CUsbStateWatcher::NewL(CUsbChargingArmTest& aUsbChargingArm)
|
|
28 |
{
|
|
29 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_NEWL_ENTRY );
|
|
30 |
CUsbStateWatcher* self = new(ELeave) CUsbStateWatcher(aUsbChargingArm);
|
|
31 |
CleanupStack::PushL(self);
|
|
32 |
self->ConstructL();
|
|
33 |
CleanupStack::Pop(self);
|
|
34 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_NEWL_EXIT );
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
|
|
38 |
CUsbStateWatcher::~CUsbStateWatcher()
|
|
39 |
{
|
|
40 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_CUSBSTATEWATCHER_ENTRY );
|
|
41 |
Cancel();
|
|
42 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_CUSBSTATEWATCHER_EXIT );
|
|
43 |
}
|
|
44 |
|
|
45 |
CUsbStateWatcher::CUsbStateWatcher(CUsbChargingArmTest& aUsbChargingArm)
|
|
46 |
: CActive(EPriorityStandard)
|
|
47 |
, iUsbChargingArm(aUsbChargingArm)
|
|
48 |
{
|
|
49 |
OstTraceFunctionEntry0( DUP1_CUSBSTATEWATCHER_CUSBSTATEWATCHER_ENTRY );
|
|
50 |
CActiveScheduler::Add(this);
|
|
51 |
OstTraceFunctionExit0( DUP1_CUSBSTATEWATCHER_CUSBSTATEWATCHER_EXIT );
|
|
52 |
}
|
|
53 |
|
|
54 |
void CUsbStateWatcher::ConstructL()
|
|
55 |
{
|
|
56 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_CONSTRUCTL_ENTRY );
|
|
57 |
GetAndShowDeviceStateL();
|
|
58 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_CONSTRUCTL_EXIT );
|
|
59 |
}
|
|
60 |
|
|
61 |
void CUsbStateWatcher::DoCancel()
|
|
62 |
{
|
|
63 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_DOCANCEL_ENTRY );
|
|
64 |
iUsbChargingArm.Usb().DeviceStateNotificationCancel();
|
|
65 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_DOCANCEL_EXIT );
|
|
66 |
}
|
|
67 |
|
|
68 |
void CUsbStateWatcher::RunL()
|
|
69 |
{
|
|
70 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_RUNL_ENTRY );
|
|
71 |
GetAndShowDeviceStateL();
|
|
72 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_RUNL_EXIT );
|
|
73 |
}
|
|
74 |
|
|
75 |
void CUsbStateWatcher::GetAndShowDeviceStateL()
|
|
76 |
{
|
|
77 |
OstTraceFunctionEntry0( CUSBSTATEWATCHER_GETANDSHOWDEVICESTATEL_ENTRY );
|
|
78 |
TUsbDeviceState deviceState;
|
|
79 |
User::LeaveIfError(iUsbChargingArm.Usb().GetDeviceState(deviceState));
|
|
80 |
if(deviceState != iDeviceState)
|
|
81 |
{
|
|
82 |
deviceState = iDeviceState;
|
|
83 |
}
|
|
84 |
iUsbChargingArm.ShowUsbDeviceState(deviceState);
|
|
85 |
|
|
86 |
iUsbChargingArm.Usb().DeviceStateNotification(0xffffffff, iDeviceState, iStatus);
|
|
87 |
SetActive();
|
|
88 |
OstTraceFunctionExit0( CUSBSTATEWATCHER_GETANDSHOWDEVICESTATEL_EXIT );
|
|
89 |
}
|
|
90 |
|