|
1 /* |
|
2 * Copyright (c) 2006-2007 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: DUN USB configuration accessor and listener |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CDUNUSBCONFIG_H |
|
20 #define C_CDUNUSBCONFIG_H |
|
21 |
|
22 #include <e32property.h> |
|
23 #include <usb/acmconfig.h> |
|
24 #include "DunPlugin.h" |
|
25 |
|
26 enum TUsbConfigState |
|
27 { |
|
28 EUsbConfigStateIdle, |
|
29 EUsbConfigStateWaiting |
|
30 }; |
|
31 |
|
32 /** |
|
33 * Notification interface class to report USB ACM configuration change |
|
34 * |
|
35 * @lib dunusb.lib |
|
36 * @since S60 v3.2 |
|
37 */ |
|
38 NONSHARABLE_CLASS( MDunUsbConfig ) |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Gets called when one or more ACM configurations are added |
|
45 * |
|
46 * @since S60 3.2 |
|
47 * @param aIndex Index (also port number) of added ACM configuration |
|
48 * @return Symbian error code on error, KErrNone otherwise |
|
49 */ |
|
50 virtual TInt NotifyConfigAddition( TInt aIndex ) = 0; |
|
51 |
|
52 /** |
|
53 * Gets called when one or more ACM configurations are removed |
|
54 * |
|
55 * @since S60 3.2 |
|
56 * @param aIndex Index (also port number) of removed ACM configuration |
|
57 * @return Symbian error code on error, KErrNone otherwise |
|
58 */ |
|
59 virtual TInt NotifyConfigRemoval( TInt aIndex ) = 0; |
|
60 |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Class for detecting USB ACM configuration change |
|
65 * |
|
66 * @lib dunutils.lib |
|
67 * @since S60 v3.2 |
|
68 */ |
|
69 NONSHARABLE_CLASS( CDunUsbConfig ) : public CActive |
|
70 { |
|
71 |
|
72 public: |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 * @param aServer Server |
|
77 * @param aCallback Pointer to listener callback |
|
78 * @param aProtocol Protocol number to listen |
|
79 * @return Instance of self |
|
80 */ |
|
81 static CDunUsbConfig* NewL( MDunServerCallback* aServer, |
|
82 MDunUsbConfig* aCallback, |
|
83 TUint8 aProtocol ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 virtual ~CDunUsbConfig(); |
|
89 |
|
90 /** |
|
91 * Resets data to initial values |
|
92 * |
|
93 * @since S60 3.2 |
|
94 * @return None |
|
95 */ |
|
96 void ResetData(); |
|
97 |
|
98 /** |
|
99 * Compares initialized protocol number to configuration by index |
|
100 * |
|
101 * @since S60 3.2 |
|
102 * @param aIndex Index for which to compare protocol number |
|
103 * @param aValidity If initialized protocol matched at aIndex then ETrue |
|
104 * @return Symbian error code on error, KErrNone otherwise |
|
105 */ |
|
106 TInt GetConfigValidityByIndex( TInt aIndex, TBool& aValidity ); |
|
107 |
|
108 /** |
|
109 * Starts listening for ACM configuration changes |
|
110 * |
|
111 * @since S60 3.2 |
|
112 * @return Symbian error code on error, KErrNone otherwise |
|
113 */ |
|
114 TInt IssueRequest(); |
|
115 |
|
116 /** |
|
117 * Stops listening for ACM configuration changes |
|
118 * |
|
119 * @since S60 3.2 |
|
120 * @return Symbian error code on error, KErrNone otherwise |
|
121 */ |
|
122 TInt Stop(); |
|
123 |
|
124 private: |
|
125 |
|
126 CDunUsbConfig( MDunServerCallback* aServer, |
|
127 MDunUsbConfig* aCallback, |
|
128 TUint8 aProtocol ); |
|
129 |
|
130 void ConstructL(); |
|
131 |
|
132 /** |
|
133 * Initializes this class |
|
134 * |
|
135 * @since S60 3.2 |
|
136 * @return None |
|
137 */ |
|
138 void Initialize(); |
|
139 |
|
140 /* |
|
141 * Gets current ACM configuration |
|
142 */ |
|
143 TInt GetConfiguration( TPublishedAcmConfigs& aConfig ); |
|
144 |
|
145 // from base class CActive |
|
146 |
|
147 /** |
|
148 * From CActive. |
|
149 * Gets called when ACM configuration changes |
|
150 * |
|
151 * @since S60 3.2 |
|
152 * @return None |
|
153 */ |
|
154 void RunL(); |
|
155 |
|
156 /** |
|
157 * From CActive. |
|
158 * Gets called on cancel |
|
159 * |
|
160 * @since S60 3.2 |
|
161 * @return None |
|
162 */ |
|
163 void DoCancel(); |
|
164 |
|
165 private: // data |
|
166 |
|
167 /** |
|
168 * Callback to call when notification via MDunServerCallback to be made |
|
169 * Not own. |
|
170 */ |
|
171 MDunServerCallback* iServer; |
|
172 |
|
173 /** |
|
174 * Callback to call when notification(s) via MDunUsbConfig to be made |
|
175 */ |
|
176 MDunUsbConfig* iCallback; |
|
177 |
|
178 /** |
|
179 * Current state of configuration waiting: active or inactive |
|
180 */ |
|
181 TUsbConfigState iConfigState; |
|
182 |
|
183 /* |
|
184 * Protocol number of USB ACM to which listening is done |
|
185 */ |
|
186 TUint8 iProtocol; |
|
187 |
|
188 /** |
|
189 * ACM config from the previous Get() |
|
190 * Used to check whether configs are added or removed and also array data |
|
191 * needed for check in the removal case |
|
192 */ |
|
193 TPublishedAcmConfigs iConfig; |
|
194 |
|
195 /* |
|
196 * ACM configuration property |
|
197 */ |
|
198 RProperty iAcmProperty; |
|
199 |
|
200 /* |
|
201 * Flag to indicate if configuration already received |
|
202 */ |
|
203 TBool iConfigExist; |
|
204 |
|
205 }; |
|
206 |
|
207 #endif // C_CDUNUSBCONFIG_H |