|
1 /* |
|
2 * Copyright (c) 2008-2009 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 */ |
|
17 |
|
18 |
|
19 #include "cusbhostwatcher.h" |
|
20 #include <usb/usblogger.h> |
|
21 #include "cusbhost.h" |
|
22 |
|
23 |
|
24 #ifdef __FLOG_ACTIVE |
|
25 _LIT8(KLogComponent, "hoststatewatcher"); |
|
26 #endif |
|
27 |
|
28 /* |
|
29 * Base class for USB Host watchers |
|
30 */ |
|
31 CActiveUsbHostWatcher::CActiveUsbHostWatcher(RUsbHostStack& aUsbHostStack, |
|
32 MUsbHostObserver& aOwner, |
|
33 TUint aWatcherId): |
|
34 CActive(CActive::EPriorityStandard), |
|
35 iUsbHostStack(aUsbHostStack), |
|
36 iOwner(aOwner), |
|
37 iWatcherId(aWatcherId) |
|
38 { |
|
39 LOG_FUNC |
|
40 CActiveScheduler::Add(this); |
|
41 } |
|
42 |
|
43 CActiveUsbHostWatcher::~CActiveUsbHostWatcher() |
|
44 { |
|
45 LOG_FUNC |
|
46 Cancel(); |
|
47 } |
|
48 |
|
49 void CActiveUsbHostWatcher::RunL() |
|
50 { |
|
51 LOG_FUNC |
|
52 |
|
53 ASSERT(iStatus.Int() == KErrNone); |
|
54 iOwner.NotifyHostEvent(iWatcherId); |
|
55 Post(); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 /* |
|
61 * Monitors host events (attach/load/detach) |
|
62 */ |
|
63 CActiveUsbHostEventWatcher* CActiveUsbHostEventWatcher::NewL( |
|
64 RUsbHostStack& aUsbHostStack, |
|
65 MUsbHostObserver& aOwner, |
|
66 TDeviceEventInformation& aHostEventInfo) |
|
67 { |
|
68 CActiveUsbHostEventWatcher* self = new (ELeave) CActiveUsbHostEventWatcher(aUsbHostStack,aOwner,aHostEventInfo); |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 CActiveUsbHostEventWatcher::CActiveUsbHostEventWatcher( |
|
74 RUsbHostStack& aUsbHostStack, |
|
75 MUsbHostObserver& aOwner, |
|
76 TDeviceEventInformation& aHostEventInfo) |
|
77 :CActiveUsbHostWatcher(aUsbHostStack, |
|
78 aOwner, |
|
79 KHostEventMonitor) |
|
80 , iHostEventInfo(aHostEventInfo) |
|
81 |
|
82 { |
|
83 LOG_FUNC |
|
84 } |
|
85 |
|
86 CActiveUsbHostEventWatcher::~CActiveUsbHostEventWatcher() |
|
87 { |
|
88 LOG_FUNC |
|
89 Cancel(); |
|
90 } |
|
91 |
|
92 void CActiveUsbHostEventWatcher::Post() |
|
93 { |
|
94 LOG_FUNC |
|
95 |
|
96 iUsbHostStack.NotifyDeviceEvent(iStatus, iHostEventInfo); |
|
97 SetActive(); |
|
98 } |
|
99 |
|
100 void CActiveUsbHostEventWatcher::DoCancel() |
|
101 { |
|
102 LOG_FUNC |
|
103 |
|
104 iUsbHostStack.NotifyDeviceEventCancel(); |
|
105 } |
|
106 |
|
107 |
|
108 /* |
|
109 * Monitors device monitor events |
|
110 */ |
|
111 |
|
112 CActiveUsbHostMessageWatcher* CActiveUsbHostMessageWatcher::NewL( |
|
113 RUsbHostStack& aUsbHostStack, |
|
114 MUsbHostObserver& aOwner, |
|
115 TInt& aHostMessage) |
|
116 { |
|
117 CActiveUsbHostMessageWatcher* self = new (ELeave)CActiveUsbHostMessageWatcher(aUsbHostStack,aOwner,aHostMessage); |
|
118 return self; |
|
119 } |
|
120 |
|
121 CActiveUsbHostMessageWatcher::~CActiveUsbHostMessageWatcher() |
|
122 { |
|
123 LOG_FUNC |
|
124 |
|
125 Cancel(); |
|
126 } |
|
127 |
|
128 CActiveUsbHostMessageWatcher::CActiveUsbHostMessageWatcher( |
|
129 RUsbHostStack& aUsbHostStack, |
|
130 MUsbHostObserver& aOwner, |
|
131 TInt& aHostMessage) |
|
132 :CActiveUsbHostWatcher(aUsbHostStack, |
|
133 aOwner, |
|
134 KHostMessageMonitor) |
|
135 , iHostMessage(aHostMessage) |
|
136 { |
|
137 LOG_FUNC |
|
138 } |
|
139 |
|
140 void CActiveUsbHostMessageWatcher::Post() |
|
141 { |
|
142 LOG_FUNC |
|
143 |
|
144 iUsbHostStack.NotifyDevmonEvent(iStatus, iHostMessage); |
|
145 SetActive(); |
|
146 } |
|
147 |
|
148 |
|
149 void CActiveUsbHostMessageWatcher::DoCancel() |
|
150 { |
|
151 LOG_FUNC |
|
152 |
|
153 iUsbHostStack.NotifyDevmonEventCancel(); |
|
154 } |
|
155 |