|
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: Monitors ID pin change |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_USBIDPINOBSERVER_H |
|
20 #define C_USBIDPINOBSERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32property.h> |
|
24 |
|
25 /** |
|
26 * Obserber has to implement this interface to get ID Pin change notifications |
|
27 * |
|
28 */ |
|
29 NONSHARABLE_CLASS( MUsbIdPinObserver) |
|
30 { |
|
31 public: |
|
32 |
|
33 /** |
|
34 * IdPin disappeared |
|
35 */ |
|
36 virtual void IdPinOffL() = 0; |
|
37 |
|
38 /** |
|
39 * IdPin appeared |
|
40 */ |
|
41 virtual void IdPinOnL() = 0; |
|
42 |
|
43 /** |
|
44 * IdPin error |
|
45 * @param aError error code |
|
46 */ |
|
47 virtual void IdPinErrorL(TInt aError) = 0; |
|
48 |
|
49 |
|
50 }; |
|
51 |
|
52 /** |
|
53 * Class observes ID-PIN property |
|
54 * |
|
55 */ |
|
56 NONSHARABLE_CLASS( CUsbIdPinObserver) : public CActive |
|
57 { |
|
58 |
|
59 public: |
|
60 enum TState |
|
61 { |
|
62 EIdPinOff = 0, EIdPinOn = 1 |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 * @return instance of the objects of this class |
|
68 */ |
|
69 static CUsbIdPinObserver* NewL(); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 virtual ~CUsbIdPinObserver(); |
|
75 |
|
76 /** |
|
77 * Returns current state of the IdPin |
|
78 * @return state |
|
79 */ |
|
80 TState IdPin() /* not const - read comment in cpp*/; |
|
81 |
|
82 /** |
|
83 * Add observer |
|
84 * @param aObserver Observer |
|
85 */ |
|
86 void SubscribeL(MUsbIdPinObserver* aObserver); |
|
87 |
|
88 /** |
|
89 * Remove observer |
|
90 * @param aObserver Observer |
|
91 */ |
|
92 void UnsubscribeL(MUsbIdPinObserver* aObserver); |
|
93 |
|
94 private: |
|
95 |
|
96 // From CActive |
|
97 /** |
|
98 * Request completed |
|
99 */ |
|
100 void RunL(); |
|
101 |
|
102 /** |
|
103 * Request cancelled |
|
104 */ |
|
105 void DoCancel(); |
|
106 |
|
107 /** |
|
108 * RunL leaved |
|
109 * @param errorcode from RunL |
|
110 * @return errorcode |
|
111 */ |
|
112 TInt RunError(TInt aError); |
|
113 |
|
114 private: |
|
115 |
|
116 /** |
|
117 * Default constructor. |
|
118 */ |
|
119 CUsbIdPinObserver(); |
|
120 |
|
121 /** |
|
122 * 2nd phase constructor. |
|
123 */ |
|
124 void ConstructL(); |
|
125 |
|
126 private: |
|
127 // data |
|
128 |
|
129 /** |
|
130 * The observer reports state changes to its own observers |
|
131 * Own |
|
132 */ |
|
133 RPointerArray<MUsbIdPinObserver> iObservers; |
|
134 |
|
135 /** |
|
136 * The observer observes property change |
|
137 */ |
|
138 RProperty iIdPin; |
|
139 |
|
140 }; |
|
141 |
|
142 #endif // C_USBIDPINOBSERVER_H |