|
1 /* |
|
2 * Copyright (c) 2002 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: Declaration of Notepad Viewer Dialog class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NPDVIEWERDIALOG_H |
|
20 #define NPDVIEWERDIALOG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <charconv.h> |
|
24 #include <centralrepository.h> |
|
25 #include <cenrepnotifyhandler.h> |
|
26 #include <itemfinderobserver.h> |
|
27 #include "NpdDialogBase.h" |
|
28 #include "NpdLoadFileAO.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CNotepadRichTextEditor; |
|
32 class CEikDialog; |
|
33 class CSendUi; |
|
34 class CItemFinder; |
|
35 class CFindItemMenu; |
|
36 class CPlainText; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 /** |
|
40 * Dialog of viewer mode. |
|
41 * CNotepadViewerDialog is a dialog for Notepad viewer. |
|
42 * |
|
43 * @see CNotepadDialogBase |
|
44 */ |
|
45 class CNotepadViewerDialog : public CNotepadDialogBase, |
|
46 public MCenRepNotifyHandlerCallback, |
|
47 public MAknItemFinderObserver, |
|
48 public MProgressDialogCallback, |
|
49 public MNotepadLoadFileObserver |
|
50 |
|
51 { |
|
52 public: // Constructor and destructor |
|
53 |
|
54 /** |
|
55 * Constructor. |
|
56 * |
|
57 * @param resource id of type STRUCT NOTEPAD_VIEWER_DIALOG |
|
58 * @param aSelfPtr pointer to pointer of this |
|
59 * @return Newly constructed CNotepadViewerDialog object. |
|
60 * @internal |
|
61 */ |
|
62 IMPORT_C static CNotepadViewerDialog* NewL( |
|
63 const TInt aResId, |
|
64 CEikDialog** aSelfPtr ); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 IMPORT_C virtual ~CNotepadViewerDialog(); |
|
70 |
|
71 public: // New functions |
|
72 |
|
73 /** |
|
74 * Execute a dialog. |
|
75 * |
|
76 * @return exit status value of CEikDialog's ExecuteLD. |
|
77 * @internal |
|
78 */ |
|
79 //IMPORT_C TInt ExecuteLD(); |
|
80 |
|
81 /** |
|
82 * Set information of the file to be shown. |
|
83 * |
|
84 * @param aFileName text file to view. |
|
85 * @param aTitle TitlePane string (if NULL, Title will be FileName). |
|
86 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding). |
|
87 * @param aEncoding encoding of the File |
|
88 * (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue). |
|
89 * @internal |
|
90 */ |
|
91 IMPORT_C void SetFileL( |
|
92 const TDesC& aFilename, |
|
93 const TDesC* aTitle = NULL, |
|
94 TBool aGuessEncoding = EFalse, |
|
95 TUint aEncoding = KCharacterSetIdentifierIso88591); |
|
96 |
|
97 /** |
|
98 * Set information of the file to be shown. |
|
99 * |
|
100 * @param aFile file handle. |
|
101 * @param aTitle TitlePane string (if NULL, Title will be FileName). |
|
102 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding). |
|
103 * @param aEncoding encoding of the File. |
|
104 * @internal |
|
105 */ |
|
106 IMPORT_C void SetFileL( |
|
107 RFile& aFile, |
|
108 const TDesC* aTitle = NULL, |
|
109 TBool aGuessEncoding = EFalse, |
|
110 TUint aEncoding = KCharacterSetIdentifierIso88591); |
|
111 |
|
112 /** |
|
113 * Load contents of the file into the viewer. |
|
114 * |
|
115 * @internal |
|
116 */ |
|
117 IMPORT_C void LoadFileL(); |
|
118 |
|
119 /** |
|
120 * Load contents of the file into the viewer. |
|
121 * |
|
122 * @param aFile file handle. |
|
123 * @internal |
|
124 */ |
|
125 IMPORT_C void LoadFileL(RFile& aFile); |
|
126 |
|
127 /** |
|
128 * Set information of the file to be shown and load it. |
|
129 * |
|
130 * @param aFileName text file to view. |
|
131 * @param aTitle TitlePane string (if NULL, Title will be FileName). |
|
132 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding). |
|
133 * @param aEncoding encoding of the File |
|
134 * @internal |
|
135 */ |
|
136 IMPORT_C void OpenFileL( |
|
137 const TDesC& aFilename, |
|
138 const TDesC* aTitle = NULL, |
|
139 TBool aGuessEncoding = EFalse, |
|
140 TUint aEncoding = KCharacterSetIdentifierIso88591); |
|
141 |
|
142 /** |
|
143 * Set information of the file to be shown and load it. |
|
144 * |
|
145 * @param aFile file handle. |
|
146 * @param aTitle TitlePane string (if NULL, Title will be FileName). |
|
147 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding). |
|
148 * @param aEncoding encoding of the File |
|
149 * @internal |
|
150 */ |
|
151 IMPORT_C void OpenFileL( |
|
152 RFile& aFile, |
|
153 const TDesC* aTitle = NULL, |
|
154 TBool aGuessEncoding = EFalse, |
|
155 TUint aEncoding = KCharacterSetIdentifierIso88591); |
|
156 |
|
157 /** |
|
158 * Set information of the descriptor to be shown. |
|
159 * |
|
160 * @param aFileName text file to view. |
|
161 */ |
|
162 void InitDescriptorViewerL( |
|
163 HBufC** aContentPointer, |
|
164 TInt& aReturnStatus, |
|
165 TBool aReadOnly, |
|
166 const TDesC& aText, |
|
167 const TDesC& aTitle, |
|
168 const TDesC& aDelConfirmation |
|
169 ); |
|
170 |
|
171 /** |
|
172 * Set the state of automatic highlighting |
|
173 * @param aSwitchON, ETrue if automatic highlighting is to used, otherwise EFalse |
|
174 */ |
|
175 void SetAutomaticHighlightL( const TBool aSwitchON ); |
|
176 |
|
177 /** |
|
178 * Reads the shared data value used to initialize automatic highlighting |
|
179 * @return TBool, ETrue if automatic highlighting is to be used |
|
180 */ |
|
181 void ReadAutoHlCenRepValueAndSetNotifyL(); |
|
182 |
|
183 protected: // Functions from base classes |
|
184 |
|
185 /** |
|
186 * From CEikDialog. |
|
187 */ |
|
188 TBool OkToExitL( TInt aButtonId ) ; |
|
189 |
|
190 /** |
|
191 * From MCenRepNotifyHandlerCallback |
|
192 * Handles the incoming notifications of key changes |
|
193 * @param aId, Key that has changed |
|
194 * @param aNewValue, New value of the key |
|
195 */ |
|
196 void HandleNotifyInt( TUint32 aId, TInt aNewValue ); |
|
197 |
|
198 /** |
|
199 * From MCenRepNotifyHandlerCallback |
|
200 * Handles the notifier errors |
|
201 * @param aId, Key that has changed |
|
202 * @param aNewValue, New value of the key |
|
203 */ |
|
204 void HandleNotifyError( |
|
205 TUint32 aId, |
|
206 TInt aError, |
|
207 CCenRepNotifyHandler* aHandler ); |
|
208 |
|
209 /** |
|
210 * From CCoeControl |
|
211 * |
|
212 * @param aType event type. |
|
213 */ |
|
214 void HandleResourceChange(TInt aType); |
|
215 |
|
216 /** |
|
217 * From CCoeControl. |
|
218 * Called when SizeChanged. |
|
219 */ |
|
220 void SizeChanged(); |
|
221 public: |
|
222 void HandleDialogPointerEventL( const TPointerEvent& aPointerEvent ); |
|
223 |
|
224 void HandleFindItemEventL( |
|
225 const CItemFinder::CFindItemExt& aItem, |
|
226 MAknItemFinderObserver::TEventFlag aEvent, |
|
227 TUint aFlags ); |
|
228 |
|
229 public: // From MProgressDialogCallback |
|
230 void DialogDismissedL( TInt aButtonId ); |
|
231 |
|
232 public: // From MNotepadLoadFileObserver |
|
233 /** |
|
234 * Notify the observer that load file completed. |
|
235 * @param aErrCode the result of load file completed. |
|
236 * @since 5.2 |
|
237 */ |
|
238 void NotifyCompletedL( TInt aErrCode ); |
|
239 |
|
240 private: // New function |
|
241 |
|
242 /** |
|
243 * Show "Attachement saved" note. |
|
244 */ |
|
245 void ShowConfirmationNoteL(); |
|
246 /** |
|
247 * Handle Phone number calls |
|
248 */ |
|
249 void HandleNumberCallL(); |
|
250 |
|
251 private: // Functions from base classes |
|
252 |
|
253 void ConstructL(TResourceReader& rr); |
|
254 |
|
255 /** |
|
256 * From CEikDialog. |
|
257 */ |
|
258 void PostLayoutDynInitL(); |
|
259 |
|
260 /** |
|
261 * From CCoeControl. |
|
262 */ |
|
263 void ActivateL(); |
|
264 |
|
265 /** |
|
266 * From CCoeControl |
|
267 * |
|
268 * @param aKeyEvent key event which includes ScanCode etc. |
|
269 * @param aType event type ( up, in, down...). |
|
270 */ |
|
271 TKeyResponse OfferKeyEventL( |
|
272 const TKeyEvent& aKeyEvent, |
|
273 TEventCode aType); |
|
274 |
|
275 /** |
|
276 * From CCoeControl. |
|
277 * |
|
278 * @param aContext TCoeHelpContext. |
|
279 */ |
|
280 void GetHelpContext(TCoeHelpContext& aContext) const; |
|
281 |
|
282 /** |
|
283 * From MEikCommandObserver |
|
284 * |
|
285 * @param aCommandId command. |
|
286 */ |
|
287 void ProcessCommandL(TInt aCommandId); |
|
288 |
|
289 /** |
|
290 * From MEikMenuObserver. |
|
291 * |
|
292 * @param aResourceId resource id. |
|
293 * @param menu pane object. |
|
294 */ |
|
295 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
296 |
|
297 /** |
|
298 * From MEikMenuObserver. |
|
299 * |
|
300 * @param aResourceId resource id. |
|
301 * @param menu bar object. |
|
302 */ |
|
303 void DynInitMenuBarL(TInt aResourceId,CEikMenuBar* aMenuBar); |
|
304 |
|
305 private: // Reserved |
|
306 |
|
307 /** |
|
308 * Reserved API entry. |
|
309 * |
|
310 * @internal |
|
311 */ |
|
312 IMPORT_C void CNotepadViewerDialog_Reserved(); |
|
313 |
|
314 private: |
|
315 |
|
316 /** |
|
317 * Callback function for CPeriodic |
|
318 * |
|
319 * @param TAny* args. |
|
320 */ |
|
321 static TInt TimerCallbackL(TAny* aPtr); |
|
322 |
|
323 /** |
|
324 * Called in callback function to exit the dialog |
|
325 */ |
|
326 void ExitDialogOnTimerExpireL(); |
|
327 |
|
328 /** |
|
329 * Clean the progress dialog |
|
330 * @since 5.2 |
|
331 */ |
|
332 void CleanProgressDialogL(); |
|
333 |
|
334 /** |
|
335 * load the file step by step |
|
336 * @param aFile the file object to load |
|
337 * @since 5.2 |
|
338 */ |
|
339 void LoadFileByStepsL(RFile& aFile); |
|
340 |
|
341 private: // Data |
|
342 |
|
343 enum TNotepadViewerFlags |
|
344 { |
|
345 ENotepadMenuByOkKey = 0x02, |
|
346 EMenuByItemActication = 0x04 |
|
347 }; |
|
348 CNotepadRichTextEditor* iEditor; // not own (dialog own) |
|
349 HBufC* iFilename; // own |
|
350 RFile * iFile; |
|
351 HBufC** iContentPointer; // not owned |
|
352 TBool iFileExist; |
|
353 TPtrC iContent; |
|
354 TPtrC iTitle; |
|
355 TPtrC iDelConfirmation; |
|
356 TInt* iReturnValue; |
|
357 TUint iEncoding; |
|
358 TInt iStatus; |
|
359 TBool iGuessEncoding; |
|
360 |
|
361 // Used to flag whether viewer is handling file or descriptor passed |
|
362 // from calling application. This changes option menu items somewhat. |
|
363 TBool iDescriptorViewer; |
|
364 |
|
365 // Used in conjunction with iDescriptorViewer flag to determine |
|
366 // whether "Edit" option menu item should be visible. |
|
367 TBool iEditable; |
|
368 |
|
369 CSendUi* iSendUi; // own |
|
370 TUint16 iFlags; |
|
371 |
|
372 CItemFinder* iAutoFinder; // own |
|
373 CFindItemMenu* iFindMenu; // own |
|
374 TBool iTaskSwapperFlag; |
|
375 |
|
376 // flag for forward locked content |
|
377 TBool iForwardLocked; |
|
378 TBool iAutomaticHlValue; |
|
379 TBool iAutomaticHlInitialized; |
|
380 // Central Repository session |
|
381 CRepository* iCenRepSession; |
|
382 // Notifier to listen changes of offline state |
|
383 CCenRepNotifyHandler* iNotifier; |
|
384 CPeriodic* iPeriodicTimer; |
|
385 |
|
386 // Own: Active object for load file asynchronous |
|
387 CNotepadLoadFileAO* iLoadFileAO; |
|
388 |
|
389 // Own: Progress dialog for load file |
|
390 CAknProgressDialog* iProgressDialogLoadfile; |
|
391 |
|
392 }; |
|
393 |
|
394 #endif // NPDVIEWERDIALOG_H |
|
395 |
|
396 // End of File |