os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/cactivedevicestatenotifierbase.cpp
Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Class definition for Device State Notifier Base Class
27 #include "cactivedevicestatenotifierbase.h"
29 CActiveDeviceStateNotifierBase::CActiveDeviceStateNotifierBase(CBulkOnlyTransport& aBot,
30 MLddDeviceStateNotification& aLddDeviceStateNotification)
34 : CActive(EPriorityStandard),
36 iLddDeviceStateNotification(aLddDeviceStateNotification),
37 iDeviceState(EUsbcNoState),
38 iOldDeviceState(EUsbcNoState)
44 CActiveDeviceStateNotifierBase* CActiveDeviceStateNotifierBase::NewL(CBulkOnlyTransport& aBot,
45 MLddDeviceStateNotification& aLddDeviceStateNotification)
50 CActiveDeviceStateNotifierBase* self = new (ELeave) CActiveDeviceStateNotifierBase(aBot, aLddDeviceStateNotification);
51 CleanupStack::PushL(self);
53 CActiveScheduler::Add(self);
54 CleanupStack::Pop(); // self
59 void CActiveDeviceStateNotifierBase::ConstructL()
64 __FNLOG("CActiveDeviceStateNotifierBase::ConstructL");
68 CActiveDeviceStateNotifierBase::~CActiveDeviceStateNotifierBase()
73 __PRINT(_L("CActiveDeviceStateNotifierBase::~CActiveDeviceStateNotifierBase()"));
74 Cancel(); // base class
78 void CActiveDeviceStateNotifierBase::DoCancel()
83 __PRINT(_L("CActiveDeviceStateNotifierBase::DoCancel()"));
84 iLddDeviceStateNotification.Cancel();
88 void CActiveDeviceStateNotifierBase::RunL()
93 __FNLOG("CActiveDeviceStateNotifierBase::RunL");
94 // This displays the device state.
95 // In a real world program, the user could take here appropriate action (cancel a
96 // transfer request or whatever).
97 __PRINT1(_L("DeviceState Notification = %d"), iDeviceState);
99 if (!(iDeviceState & KUsbAlternateSetting))
101 switch (iDeviceState)
103 case EUsbcDeviceStateUndefined: //0
104 case EUsbcDeviceStateDefault: //3
108 case EUsbcDeviceStateAttached: //1
109 case EUsbcDeviceStatePowered: //2
113 case EUsbcDeviceStateAddress: //4
114 if (iOldDeviceState == EUsbcDeviceStateConfigured)
116 iBot.StopBulkOnlyEndpoint();
120 case EUsbcDeviceStateConfigured: //5
121 if (iOldDeviceState == EUsbcDeviceStateSuspended)
130 case EUsbcDeviceStateSuspended: //6
131 if (iOldDeviceState == EUsbcDeviceStateConfigured)
137 __PRINT(_L("Device State notifier: ***BAD***\n"));
141 iOldDeviceState = iDeviceState;
143 else if (iDeviceState & KUsbAlternateSetting)
145 __PRINT1(_L("Device State notifier: Alternate interface setting has changed: now %d\n"), iDeviceState & ~KUsbAlternateSetting);
151 void CActiveDeviceStateNotifierBase::Activate()
156 __FNLOG("CActiveDeviceStateNotifierBase::Activate");
159 __PRINT(_L("Still active\n"));
162 iLddDeviceStateNotification.Activate(iStatus, iDeviceState);