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