|
1 /* |
|
2 * Copyright (c) 2004-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CDISCOVERYDLGMANAGER_H |
|
20 #define CDISCOVERYDLGMANAGER_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <aknPopup.h> |
|
24 #include <aknlists.h> |
|
25 #include <f32file.h> |
|
26 #include <AknProgressDialog.h> |
|
27 |
|
28 #include "mdiscoveryobserver.h" |
|
29 #include "mdiscovery.h" |
|
30 |
|
31 class CAknWaitDialog; |
|
32 class CImagePrintAppUi; |
|
33 class MPrintSettings; |
|
34 class CIFFactory; |
|
35 |
|
36 // CONSTANTS |
|
37 const TInt KMaxPrinterNameLength( 84 ); |
|
38 |
|
39 // CLASS DEFINITION |
|
40 /** |
|
41 * |
|
42 * CDiscoveryDlgManager is a class that is responsible of displaying the pop-up |
|
43 * list at the beginning containing the available medias/devices to print to. |
|
44 * |
|
45 */ |
|
46 class CDiscoveryDlgManager |
|
47 : public CBase, |
|
48 public MDiscoveryObserver, |
|
49 public MProgressDialogCallback |
|
50 { |
|
51 public: // Constructors and destructors |
|
52 |
|
53 /** |
|
54 * Two-phase constructor |
|
55 * |
|
56 * @param aDiscovery Discovery IF |
|
57 * |
|
58 * @return Initialized instance of the class |
|
59 */ |
|
60 static CDiscoveryDlgManager* NewL( CIFFactory& aIFFactory ); |
|
61 static CDiscoveryDlgManager* NewLC( CIFFactory& aIFFactory); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 virtual ~CDiscoveryDlgManager(); |
|
67 |
|
68 protected: // Constructors and destructors |
|
69 |
|
70 /** |
|
71 * Default constructor |
|
72 * @param aDiscovery Discovery IF |
|
73 */ |
|
74 CDiscoveryDlgManager(); |
|
75 |
|
76 /** |
|
77 * 2nd phase constructor |
|
78 */ |
|
79 void ConstructL( CIFFactory& aIFFactory ); |
|
80 |
|
81 public: // Methods derived from MDiscoveryObserver |
|
82 |
|
83 void NotifyNewPrintDeviceL( HBufC* aText, TInt aUid, TBool aCached, |
|
84 TPrinterType aType, TUint aVendor ); |
|
85 void DiscoveryError( TInt aErrCode ); |
|
86 void DeviceDiscoveryCompleted(); |
|
87 void RemoveCachedPrinterL( TInt aUid ) ; |
|
88 |
|
89 public: // from MProgressDialogCallback |
|
90 |
|
91 void DialogDismissedL( TInt aButtonId ); |
|
92 |
|
93 public: // New methods |
|
94 |
|
95 /** |
|
96 * Starts the dialog manager, displays pop-up window where |
|
97 * the found printers are placed |
|
98 * |
|
99 * @param aProtocol Specific protocol to searh for. ( all |
|
100 * available as default ) |
|
101 * |
|
102 * @param aHidden True will not launch popup list. This will also |
|
103 * select the found printer to be the printer in use. |
|
104 * ( EFalse as default ). Note that this can only be used |
|
105 * with specific protocol and with BT first found printer |
|
106 * will be selected. |
|
107 * |
|
108 * |
|
109 * @return ETrue = printer has been selected succesfully |
|
110 * EFalse = not |
|
111 */ |
|
112 TBool StartDlgManagerL( TInt aProtocol = 0, TBool aHidden = EFalse); |
|
113 |
|
114 TInt PrinterUid() const; |
|
115 /** |
|
116 * Returns the chosen printer's name |
|
117 */ |
|
118 const TDesC& PrinterName() const; |
|
119 /* |
|
120 * Was the selected printer USB printer |
|
121 */ |
|
122 TBool USBPrinterSelected() const; |
|
123 |
|
124 /* |
|
125 * Canceling discovery and close device popuplist. |
|
126 */ |
|
127 void CancelDiscovery(); |
|
128 |
|
129 private: // New methods |
|
130 |
|
131 /** |
|
132 * Creates the pop-up list around the instance's list box |
|
133 * |
|
134 * @return Initialized instance of the pop-up list |
|
135 */ |
|
136 CAknPopupList* CreatePopupListL(); |
|
137 |
|
138 /** |
|
139 * Adds new device to list, updates popup list |
|
140 * |
|
141 * @param aText Textual description of the new print device |
|
142 * @param aUid Uid that is associated with the print device |
|
143 * @param aCached Is printer cached or not? |
|
144 * @param aType Printer type |
|
145 * @param aVendor Printer brand |
|
146 */ |
|
147 void AddNewDeviceToListL( HBufC* aText, TInt aUid, TBool aCached, |
|
148 TPrinterType aType, TUint aVendor ); |
|
149 |
|
150 /** |
|
151 * Show "restart discovery" query and start the discovery again |
|
152 * if it is so desired |
|
153 */ |
|
154 void RestartDiscoveryL(); |
|
155 |
|
156 /** |
|
157 * Removes cached icons from the list |
|
158 */ |
|
159 void RemoveCachedIconsL(); |
|
160 |
|
161 /** |
|
162 * Adds "search again" text to pop-up list |
|
163 */ |
|
164 void AddSearchAgainTextL(); |
|
165 |
|
166 /** |
|
167 * Pop up a wait note during cancellation operation |
|
168 */ |
|
169 void ShowCancelWaitNoteL(); |
|
170 |
|
171 TBool StartNormalDiscoveryL(); |
|
172 |
|
173 TBool StartHiddenDiscoveryL(); |
|
174 |
|
175 /* |
|
176 * @function AccessPointExistsL |
|
177 * @description Checks if access point is defined |
|
178 * @return TBool |
|
179 */ |
|
180 TBool WlanAccessPointExistsL(); |
|
181 |
|
182 /* |
|
183 * @function TryWlanDiscoveryL |
|
184 * @description Try WLAN discovery |
|
185 * Checks if AP is defined |
|
186 if not, launches WLAN wizard |
|
187 * @return TBool |
|
188 */ |
|
189 TBool TryDeviceDiscoveryL( TUint aProtocols, TBool aSingleDiscovery ); |
|
190 |
|
191 private: // Data |
|
192 |
|
193 // Listbox for popup list |
|
194 CAknSingleGraphicPopupMenuStyleListBox* iListBox; |
|
195 |
|
196 // The popup list |
|
197 CAknPopupList* iPopupList; |
|
198 |
|
199 // Array for profile names |
|
200 CDesCArrayFlat* iListOfDeviceNames; |
|
201 |
|
202 // Pointer to engine discovery interface |
|
203 MDiscovery* iDiscovery; |
|
204 |
|
205 // True if popup window is active |
|
206 TBool iActivePopup; |
|
207 |
|
208 // Array of printer UIDs |
|
209 CArrayFixFlat<TInt>* iUidArray; |
|
210 |
|
211 // Array of printer Protocols |
|
212 CArrayFixFlat<TPrinterType>* iProtocolArray; |
|
213 |
|
214 // Array of printer brands |
|
215 CArrayFixFlat<TUint>* iBrandArray; |
|
216 |
|
217 // Selected printer's name |
|
218 HBufC* iPrinterName; |
|
219 |
|
220 // Supported protocols |
|
221 TUint iSupportedProtocols; |
|
222 |
|
223 // Cancellation wait dialog |
|
224 CAknWaitDialog* iCancellingDialog; |
|
225 |
|
226 // Cancelling state |
|
227 TBool iCancelling; |
|
228 |
|
229 // Discovery status |
|
230 TBool iDiscoveryCompleted; |
|
231 |
|
232 // USB printer id |
|
233 TInt iUsbPrinterID; |
|
234 |
|
235 TBool iUSBPrinterSelected; |
|
236 |
|
237 // Hidden discovery flag |
|
238 TBool iHiddenDiscovery; |
|
239 |
|
240 // Printer found flag |
|
241 TBool iPrinterFound; |
|
242 |
|
243 // Searching cancelled flag |
|
244 TBool iSearchingCancelled; |
|
245 |
|
246 // Wait dialog shown while doing hidden discovery |
|
247 CAknWaitDialog* iHiddenDiscoveryDialog; |
|
248 |
|
249 // Array to store printer names |
|
250 CDesCArray* iNameArray; |
|
251 |
|
252 // Indicates whether discovery searches multiple devices (bt/wlan cases) or not |
|
253 TBool iMultiDiscovery; |
|
254 |
|
255 TInt iCurrentPrinterUid; |
|
256 |
|
257 // Interface for settings |
|
258 MPrintSettings* iSettings; |
|
259 |
|
260 //Contais "Searching" title text for popup dialog |
|
261 HBufC* iSearchingText; |
|
262 |
|
263 //Contais "Select device" title text for popup dialog |
|
264 HBufC* iSelectDeviceText; |
|
265 |
|
266 //Pointer to active title text |
|
267 TPtrC iActiveTitleText; |
|
268 |
|
269 }; |
|
270 |
|
271 #endif // CDISCOVERYDLGMANAGER_H |
|
272 |
|
273 // End of File |