|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #ifndef CUSBOTG_H |
|
18 #define CUSBOTG_H |
|
19 |
|
20 class CUsbOtgEventWatcher; |
|
21 class CRequestSessionWatcher; |
|
22 |
|
23 class MUsbRequestSessionObserver |
|
24 { |
|
25 public: |
|
26 virtual void BusRequestL() = 0; |
|
27 }; |
|
28 |
|
29 |
|
30 class ROtgStateChangeNotifier |
|
31 { |
|
32 public: |
|
33 ROtgStateChangeNotifier(); |
|
34 ~ROtgStateChangeNotifier(); |
|
35 |
|
36 void Register(const RMessage2& aMessage); |
|
37 void DoNotifyL(); |
|
38 void DoCancelL(); |
|
39 |
|
40 private: |
|
41 void CompleteNotifierL(TInt); |
|
42 |
|
43 private: |
|
44 /** Notification service */ |
|
45 RMessage2 iMessage; |
|
46 /** Flag to indicate that media change notification is active */ |
|
47 TBool iRegistered; |
|
48 }; |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 class CUsbOtg: public CBase, |
|
55 public MUsbRequestSessionObserver |
|
56 { |
|
57 public: |
|
58 enum TOtgState {KOtgStateStart, |
|
59 KOtgStateAPlugInserted, |
|
60 KOtgStateSessionOpen, |
|
61 KOtgStateSessionClose}; |
|
62 |
|
63 |
|
64 public: |
|
65 static CUsbOtg* NewL(); |
|
66 ~CUsbOtg(); |
|
67 protected: |
|
68 CUsbOtg(); |
|
69 void ConstructL(); |
|
70 |
|
71 public: |
|
72 |
|
73 // MUsbRequestSessionObserver |
|
74 void BusRequestL(); |
|
75 |
|
76 void HandleUsbOtgEvent(RUsbOtgDriver::TOtgEvent aEvent); |
|
77 |
|
78 TBool DeviceInserted(); |
|
79 void NotifyChange(const RMessage2& aMessage); |
|
80 void NotifyChangeCancel(); |
|
81 TInt BusDrop(); |
|
82 |
|
83 private: |
|
84 void StartL(); |
|
85 void Stop(); |
|
86 |
|
87 |
|
88 private: |
|
89 TOtgState iOtgState; |
|
90 RUsbOtgDriver iUsbOtgDriver; |
|
91 |
|
92 CUsbOtgEventWatcher* iOtgEventWatcher; |
|
93 |
|
94 CRequestSessionWatcher* iRequestSessionWatcher; |
|
95 |
|
96 ROtgStateChangeNotifier iNotifier; |
|
97 }; |
|
98 |
|
99 #endif |