Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include <e32property.h>
23 #include "cusbotgwatcher.h"
29 CUsbOtgBaseWatcher::CUsbOtgBaseWatcher(RUsbOtgDriver& aLdd)
30 : CActive(CActive::EPriorityStandard),
34 CActiveScheduler::Add(this);
38 CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher()
44 void CUsbOtgBaseWatcher::Start()
52 CRequestSessionWatcher* CRequestSessionWatcher::NewL(MUsbRequestSessionObserver& aObserver)
55 CRequestSessionWatcher* r = new (ELeave) CRequestSessionWatcher(aObserver);
60 CRequestSessionWatcher::CRequestSessionWatcher(MUsbRequestSessionObserver& aObserver)
61 : CActive(EPriorityStandard),
67 void CRequestSessionWatcher::ConstructL()
70 User::LeaveIfError(iProperty.Define(KUidUsbManCategory, KUsbRequestSessionProperty, RProperty::EInt));
71 User::LeaveIfError(iProperty.Attach(KUidUsbManCategory, KUsbRequestSessionProperty));
72 CActiveScheduler::Add(this);
74 // initial subscription and process current property value
79 void CRequestSessionWatcher::DoCancel()
86 CRequestSessionWatcher::~CRequestSessionWatcher()
91 iProperty.Delete(KUidUsbManCategory, KUsbRequestSessionProperty);
95 void CRequestSessionWatcher::RunL()
98 // resubscribe before processing new value to prevent missing updates
99 iProperty.Subscribe(iStatus);
102 User::LeaveIfError(iProperty.Get(KUidUsbManCategory, KUsbRequestSessionProperty, val));
103 __USBOTGPRINT1(_L(">> CUsbRequestSessionWatcher[%d]"), val);
107 case KUsbManSessionOpen:
109 iObserver.BusRequestL();
113 __USBOTGPRINT(_L("Event ignored"));
118 TInt CRequestSessionWatcher::RunError(TInt aError)
121 __USBOTGPRINT1(_L("CUsbRequestSessionWatcher::RunError[%d]"), aError);
133 CUsbOtgEventWatcher* CUsbOtgEventWatcher::NewL(RUsbOtgDriver& aLdd,
137 CUsbOtgEventWatcher* r = new (ELeave) CUsbOtgEventWatcher(aLdd, aUsbOtg);
142 CUsbOtgEventWatcher::CUsbOtgEventWatcher(RUsbOtgDriver& aLdd,
144 : CUsbOtgBaseWatcher(aLdd),
151 void CUsbOtgEventWatcher::ConstructL()
157 void CUsbOtgEventWatcher::DoCancel()
160 iLdd.CancelOtgEventRequest();
164 CUsbOtgEventWatcher::~CUsbOtgEventWatcher()
170 void CUsbOtgEventWatcher::Post()
173 iLdd.QueueOtgEventRequest(iEvent, iStatus);
177 void CUsbOtgEventWatcher::RunL()
181 TInt r = iStatus.Int();
182 User::LeaveIfError(r);
184 __USBOTGPRINT1(_L(">> CUsbOtgEventWatcher[%x]"), iEvent);
185 User::LeaveIfError(r);
187 iUsbOtg.HandleUsbOtgEvent(iEvent);
191 TInt CUsbOtgEventWatcher::RunError(TInt aError)
194 __USBOTGPRINT1(_L("CUsbRequestSessionWatcher::RunError[%d]"), aError);