|
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 Base class of Notepad Dialogs. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NPDDIALOGBASE_H |
|
20 #define NPDDIALOGBASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknDialog.h> |
|
24 #include <f32file.h> |
|
25 #include "NpdLib.hrh" |
|
26 #include <AknProgressDialog.h> |
|
27 // FORWARD DECLARATIONS |
|
28 class CAknTitlePane; |
|
29 class CSendUi; |
|
30 class CSendAppUi; |
|
31 class CNotepadDialogBase; |
|
32 class CEikonEnv; |
|
33 class CNotepadModel; |
|
34 class CEikEdwin; |
|
35 class CEikMenuPane; |
|
36 class CPlainText; |
|
37 class RFile; |
|
38 class TResourceReader; |
|
39 class CAknProgressDialog; |
|
40 class CMessageData; |
|
41 |
|
42 class CNotepadListDialog; |
|
43 // CLASS DECLARATION |
|
44 /** |
|
45 * Base class of three dialogs in Notepad library. |
|
46 * CNotepadDialogBase is the base class of CNotepadListDialog, |
|
47 * CNotepadEditorDialog and CNotepadViewerDialog. |
|
48 * |
|
49 * @lib NpdLib.lib |
|
50 * @see CNotepadListDialog, CNotepadEditorDialog, CNotepadViewerDialog. |
|
51 */ |
|
52 class CNotepadDialogBase : public CAknDialog |
|
53 { |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 IMPORT_C virtual ~CNotepadDialogBase(); |
|
60 |
|
61 public: // New functions |
|
62 |
|
63 /** |
|
64 * Execute dialog (Internal to NPDLIB). |
|
65 * |
|
66 * @return return code of CEikDailog::ExecuteLD. |
|
67 * @internal |
|
68 */ |
|
69 IMPORT_C TInt ExecuteLD(); |
|
70 |
|
71 protected: // Constructors |
|
72 |
|
73 /** |
|
74 * Second phase constructor. |
|
75 * |
|
76 * @param aReader resource reader already opened for |
|
77 * one of "STRUCT NOTEPAD_LIST_DIALOG", |
|
78 * "STRUCT NOTEPAD_EDITOR_DIALOG", or "STRUCT NOTEPAD_VIEWER_DIALOG". |
|
79 */ |
|
80 void ConstructL(TResourceReader& aReader); |
|
81 |
|
82 protected: // New functions |
|
83 |
|
84 /** |
|
85 * Set text of title pane. |
|
86 * If aTitle is NULL, no operation is done (it never leaves nor panics). |
|
87 * |
|
88 * @param aTitle title string. |
|
89 */ |
|
90 void SetTitleL( const TDesC* aTitle ); |
|
91 |
|
92 /** |
|
93 * Set text of title pane. |
|
94 * |
|
95 * @param aFile file handle. |
|
96 */ |
|
97 void SetFileHandleL(RFile& aFile); |
|
98 |
|
99 /** |
|
100 * Show confirmation query with specified prompt and return the answer. |
|
101 * |
|
102 * @param aPromptResId resource id for the confirmation prompt. |
|
103 * @return ETrue if query confirmed Yes, otherwise EFalse. |
|
104 */ |
|
105 TBool ExecuteConfirmationQueryL(TInt aPromptResId); |
|
106 |
|
107 /** |
|
108 * Show confirmation query with specified prompt and return the answer. |
|
109 * |
|
110 * @param aPrompt prompt text for the confirmation. |
|
111 * @return ETrue if query confirmed Yes, otherwise EFalse. |
|
112 */ |
|
113 TBool ExecuteConfirmationQueryL(TDesC* aPrompt = NULL); |
|
114 |
|
115 |
|
116 /** |
|
117 * Send text using SendUi. |
|
118 * |
|
119 * @param aSendUi CSendUi object. |
|
120 * @param aCommandId, command id of MTM. |
|
121 * @param aDesC text to send. |
|
122 * @param aPlainText CPlainText to send. |
|
123 * @param aFileName file name to send. |
|
124 */ |
|
125 void SendAsL( |
|
126 CSendUi& aSendUi, |
|
127 TInt aCommandId, |
|
128 const TDesC* aDesC, |
|
129 const CPlainText* aPlainText = NULL, |
|
130 const TDesC* aFileName = NULL ); |
|
131 |
|
132 /** |
|
133 * Send text using SendUi. |
|
134 * |
|
135 * @param aSendUi CSendUi object. |
|
136 * @param aCommandId, command id of MTM. |
|
137 * @param aDesC text to send. |
|
138 * @param aPlainText CPlainText to send. |
|
139 * @param aFileName file name to send. |
|
140 */ |
|
141 void SendAsL( |
|
142 CSendUi& aSendUi, |
|
143 TInt aCommandId, |
|
144 TBool aFileExist, |
|
145 const TDesC* aDesC, |
|
146 const CPlainText* aPlainText = NULL ); |
|
147 |
|
148 /** |
|
149 * Send items using SendUi. |
|
150 * |
|
151 * @param aSendUi CSendUi object. |
|
152 * @param aModel CNotepadModel object. |
|
153 * @param aCommandId, command id of MTM. |
|
154 * @param aKeys a key array of items to send. |
|
155 */ |
|
156 TUid SendByKeysL( |
|
157 CSendUi& aSendUi, |
|
158 TInt aCommandId, |
|
159 CNotepadModel& aModel, |
|
160 const RArray<TInt>& aKeys ); |
|
161 |
|
162 /** |
|
163 * Check this dialog if waiting. |
|
164 * |
|
165 * @return ETrue if this is a waiting dialog, otherwize EFalse. |
|
166 */ |
|
167 inline TBool IsWaiting() const; |
|
168 |
|
169 /** |
|
170 * Check whether this dialog is for Notepad application. |
|
171 * |
|
172 * @return ETrue if this is for Notepad, otherwize EFalse. |
|
173 */ |
|
174 inline TBool IsNotepad() const; |
|
175 |
|
176 /** |
|
177 * Check whether this dialog is for Templates application. |
|
178 * |
|
179 * @return ETrue if this is for Templates, otherwize EFalse. |
|
180 */ |
|
181 inline TBool IsTemplates() const; |
|
182 |
|
183 /** |
|
184 * Check whether this dialog is modeless. |
|
185 * |
|
186 * @return ETrue if this is a modeless dialog, otherwize EFalse. |
|
187 */ |
|
188 inline TBool IsModeless(); |
|
189 |
|
190 /** |
|
191 * Check whether this dialog is for Notepad application ListDialog. |
|
192 * |
|
193 * @return ETrue if this is for for Notepad application ListDialog, otherwize EFalse. |
|
194 */ |
|
195 inline TBool IsNoteListDialog() const; |
|
196 |
|
197 /** |
|
198 * Check whether this dialog is for Template List. |
|
199 * |
|
200 * @return ETrue if this is for for Template List, otherwize EFalse. |
|
201 */ |
|
202 inline TBool IsTemplateListDialog() const; |
|
203 |
|
204 /** |
|
205 * Set iTitle text to title pane. |
|
206 * |
|
207 */ |
|
208 void RefreshTitleL(); |
|
209 |
|
210 |
|
211 /** |
|
212 * Insert 'Send' menu item to aMenuPane just |
|
213 * after aCommandId. |
|
214 * |
|
215 * @param aSendUi CSendUi object. |
|
216 * @param aMenuPane menu pane to insert. |
|
217 * @param aCommandId new menu item is added after the position of this. |
|
218 */ |
|
219 void InsertSendMenuItemAfterL( |
|
220 CSendUi& aSendUi, |
|
221 CEikMenuPane& aMenuPane, |
|
222 TInt aCommandId ); |
|
223 |
|
224 /** |
|
225 * For MCE, delayed exit. |
|
226 * |
|
227 * @return ETrue If delayed exit mode. |
|
228 */ |
|
229 inline TBool IsExitDelayedBySendUi() const; |
|
230 |
|
231 protected: // Functions from base classes |
|
232 |
|
233 /** |
|
234 * From CCoeControl. |
|
235 */ |
|
236 void ActivateL(); |
|
237 |
|
238 /** |
|
239 * From MEikCommandObserver |
|
240 * |
|
241 * @param aCommandId command. |
|
242 */ |
|
243 void ProcessCommandL(TInt aCommandId); |
|
244 |
|
245 /** |
|
246 * From MEikDialogPageObserver. |
|
247 * Create customized ListBox. |
|
248 * |
|
249 * @param aControlType id of dialog line. |
|
250 * @return line control info. |
|
251 */ |
|
252 SEikControlInfo CreateCustomControlL(TInt aControlType); |
|
253 |
|
254 private: // New functions |
|
255 |
|
256 /** |
|
257 * Send a file as an attachment. |
|
258 * |
|
259 * The MTM specified by aCommandId must have capability to send |
|
260 * a file as attachment. |
|
261 * |
|
262 * @param aSendUi CSendUi object. |
|
263 * @param aCommandId a command id of send menu item. |
|
264 * @param aFileName a name of the file to be sent. |
|
265 */ |
|
266 void SendFileAsAttachmentL( |
|
267 CSendUi& aSendUi, |
|
268 TInt aCommandId, |
|
269 const TDesC& aFileName ); |
|
270 |
|
271 /** |
|
272 * Send a file as an attachment. |
|
273 * |
|
274 * The MTM specified by aCommandId must have capability to send |
|
275 * a file as attachment. |
|
276 * |
|
277 * @param aSendUi CSendUi object. |
|
278 * @param aCommandId a command id of send menu item. |
|
279 * @param aFileName a name of the file to be sent. |
|
280 */ |
|
281 void SendFileAsAttachmentL( |
|
282 CSendUi& aSendUi, |
|
283 TInt aCommandId, |
|
284 RFile& aFile ); |
|
285 |
|
286 /** |
|
287 * For cleaning up the ENotepadSendUiRunning flag. |
|
288 */ |
|
289 static void CleanupSendUiFlag(TAny *aSelf); |
|
290 |
|
291 /** |
|
292 * Reserved API entry. |
|
293 * |
|
294 * @internal |
|
295 */ |
|
296 IMPORT_C void CNotepadDialogBase_Reserved(); |
|
297 |
|
298 protected: // Data |
|
299 |
|
300 TInt iResId; // dialog ResourceId |
|
301 CEikDialog** iSelfPtr; |
|
302 TBool iMskFlag; |
|
303 |
|
304 private: // inner class |
|
305 |
|
306 /** |
|
307 * CTemporaryFiles is a class for temprary files. |
|
308 * |
|
309 * We must not only close but also |
|
310 * 'Delete' the temorary files even when some function LEAVES while |
|
311 * using it. |
|
312 */ |
|
313 class CTemporaryFiles : public CDesC16ArrayFlat |
|
314 { |
|
315 public: //constructor, destructor |
|
316 CTemporaryFiles(TInt aGranularity, CEikonEnv& aEikonEnv); |
|
317 /** |
|
318 * Destructor. |
|
319 */ |
|
320 virtual ~CTemporaryFiles(); |
|
321 public: // new function |
|
322 /* |
|
323 * CNotepadDialogBase::CTemporaryFiles::AppendL |
|
324 |
|
325 * if you need some code conversion.... |
|
326 * CPlainText::TImportExportParam param; |
|
327 * param.iForeignEncoding = KCharacterSetIdentifierUtf8; // target encoding |
|
328 * CPlainText::TImportExportResult result; |
|
329 * text->ExportTextL(0, stream, param, result); |
|
330 */ |
|
331 void AppendL(const CPlainText& aText); |
|
332 private: // data |
|
333 CEikonEnv& iEnv; // not own |
|
334 public: |
|
335 TBuf16<150> iSendFileName; |
|
336 }; |
|
337 public: |
|
338 /** |
|
339 * CCreateAndAppendFiles is an active object to create and append |
|
340 * attachments. |
|
341 */ |
|
342 NONSHARABLE_CLASS(CCreateAndAppendFiles) : public CActive, public MProgressDialogCallback |
|
343 { |
|
344 public: // constructor, destructor |
|
345 |
|
346 /** |
|
347 * CCreateAndAppendFiles* NewL |
|
348 * @param aReader resource reader already opened for |
|
349 */ |
|
350 static CCreateAndAppendFiles* NewL( |
|
351 CSendUi& aSendAppUi, |
|
352 TInt aCommandId, |
|
353 CNotepadModel& aModel, |
|
354 RArray<TInt> aKeys, |
|
355 CEikonEnv& aEikonEnv, |
|
356 TInt& aBaseFlags, |
|
357 CNotepadDialogBase* aNpdDlgBase, |
|
358 TUid aServiceUId); |
|
359 /** |
|
360 * CCreateAndAppendFiles |
|
361 * @param aReader resource reader already opened for |
|
362 */ |
|
363 CCreateAndAppendFiles( |
|
364 CSendUi& aSendAppUi, |
|
365 TInt aCommandId, |
|
366 CNotepadModel& aModel, |
|
367 //RArray<TInt> aKeys, |
|
368 CEikonEnv& aEikonEnv, |
|
369 TInt& aBaseFlags, |
|
370 CNotepadDialogBase* aNpdDlgBase, |
|
371 TUid aServiceUId); |
|
372 /** |
|
373 * Second phase constructor. |
|
374 * @param aReader resource reader already opened for |
|
375 */ |
|
376 void ConstructL(RArray<TInt> aKeys); |
|
377 |
|
378 /** |
|
379 * Destructor. |
|
380 */ |
|
381 ~CCreateAndAppendFiles(); |
|
382 /** |
|
383 * Creates CAknProgressDialog object and creates a progress bar |
|
384 */ |
|
385 void ShowProgressBarL(); |
|
386 |
|
387 /** |
|
388 * Deletes the CAknProgressDialog object if it is already created. |
|
389 */ |
|
390 void EndProgressDialog(); |
|
391 |
|
392 /** |
|
393 * Attaches the selected notes to the message asynchronously. |
|
394 */ |
|
395 void StartAttachingL(); |
|
396 |
|
397 /** |
|
398 * Call back function called when Dialog is dismissed. |
|
399 */ |
|
400 void DialogDismissedL( TInt aButtonId ); |
|
401 void RunL(); |
|
402 void DoCancel(); |
|
403 |
|
404 private: |
|
405 /** |
|
406 * release memory allocated in the phase of appending Notes to Messaging. |
|
407 */ |
|
408 void ReleaseMemory(); |
|
409 |
|
410 private: // data |
|
411 CSendUi& iSendAppUi; |
|
412 TInt iCommandId; |
|
413 CNotepadModel& iModel; |
|
414 RArray<TInt> iKeys; |
|
415 TInt iTotalCount; |
|
416 CNotepadDialogBase::CTemporaryFiles* iFiles; |
|
417 CPlainText* iText; |
|
418 TInt iCount; |
|
419 TBool iAttaching; |
|
420 TBool iCanceled; |
|
421 CEikonEnv& iEnv; |
|
422 TInt& iBaseFlags; |
|
423 CAknProgressDialog* iProgressBar; |
|
424 CMessageData* imessageData ; |
|
425 RFs iFs; |
|
426 CArrayFixFlat<RFile> *array; |
|
427 RFile ifile1; |
|
428 TUid iServiceUId; |
|
429 CNotepadListDialog *iListDialog; //Not owned |
|
430 |
|
431 }; |
|
432 |
|
433 private: // Data |
|
434 |
|
435 enum TNotepadDialogBaseFlags |
|
436 { |
|
437 ENotepadSendUiRunning = 0x01, |
|
438 ENotepadSendUiDelayedExit = 0x02 |
|
439 }; |
|
440 |
|
441 TDesC* iTitle; // own |
|
442 HBufC* iSavedTitle; // own (copied) |
|
443 CAknTitlePane* iTitlePane; // not own (cached) |
|
444 RFile iFile; |
|
445 |
|
446 TInt iBaseFlags; |
|
447 public: |
|
448 |
|
449 CNotepadDialogBase::CCreateAndAppendFiles* iCreateFile; |
|
450 }; |
|
451 |
|
452 #include "NpdDialogBase.inl" |
|
453 #endif // NPDDIALOGBASE_H |
|
454 |
|
455 // End of File |