2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Declaration of Notepad Library APIs.
25 #include <ConeResLoader.h>
29 const TInt KNotepadPseudoKeyIdForNewNote(-1);
31 // FORWARD DECLARATIONS
35 class CNotepadTableModel;
40 * APIs of Notepad library.
41 * CNotepadApi provides APIs for other modules.
45 class CNotepadApi : public CBase
49 /* Enum for the status of the memos.
50 * ENpdDataEdited : Data is edited in the Editor dialog of the opened memo.
51 * ENpdDataDeleted : Data is deleted in the Editor dialog of the opened memo.
52 * ENpdDataErased : Data is erased in the Editor dialog of the opened memo.*/
60 public: // Constuctors and destructor
64 * Add a resource file of NpdLib.
66 * @return constructed CNotepadApi object.
68 IMPORT_C static CNotepadApi* NewL();
71 * Constructor, returned value is also kept on the CleanupStack.
72 * Add a resource file of NpdLib.
74 * @return constructed CNotepadApi object.
76 IMPORT_C static CNotepadApi* NewLC();
80 * Remove a resource file of NpdLib.
82 IMPORT_C virtual ~CNotepadApi();
84 public: // API functions
89 * No need for a pre-allocated buffer.
90 * Return NULL if the popup list is canceled or there is no memo.
91 * Caller owns the returned HBufC object.
93 * @param aTitle Optional title text.
94 * @return fetched string, (NULL if canceled or no memo).
96 IMPORT_C static HBufC* FetchMemoL(
97 const TDesC* aTitle = NULL);
102 * No need for a pre-allocated buffer.
103 * Return NULL if the popup list is canceled or there is no template.
104 * Caller owns the returned HBufC object.
106 * @param aTitle Optional title text.
107 * @return fetched string, (NULL if canceled or no templates).
109 IMPORT_C static HBufC* FetchTemplateL(
110 const TDesC* aTitle = NULL);
113 * Execute MCE's "List of templates".
115 * @return CEikDialog's exit status.
117 IMPORT_C static TInt ExecTemplatesL();
120 * Execute a file viewer dialog.
122 * @param aFileName text file to view.
123 * @param aTitle TitlePane string (if NULL, Title will be FileName).
124 * @param aDoWait Use wait dialog if ETrue.
125 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
126 * @param aEncoding encoding of the File
127 * (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
128 * @return CEikDialog's exit status.
130 IMPORT_C static TInt ExecFileViewerL(
131 const TDesC& aFileName,
132 const TDesC* aTitle = NULL,
133 const TBool aDoWait = ETrue,
134 TBool aGuessEncoding = EFalse,
135 TUint aEncoding = KCharacterSetIdentifierIso88591);
138 * Execute a file viewer dialog.
140 * @param aFile file handle.
141 * @param aTitle TitlePane string (if NULL, Title will be FileName).
142 * @param aDoWait Use wait dialog if ETrue.
143 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
144 * @param aEncoding encoding of the File
145 * (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
146 * @return CEikDialog's exit status.
148 IMPORT_C static TInt ExecFileViewerL(
150 const TDesC* aTitle = NULL,
151 const TBool aDoWait = ETrue,
152 TBool aGuessEncoding = EFalse,
153 TUint aEncoding = KCharacterSetIdentifierIso88591);
156 * Save text as a memo.
158 * @param aText memo text to save.
160 IMPORT_C static void AddContentL(const TDesC& aText);
163 * Probe a memo (API for Pinboard).
165 * @param aKey a serial number of memo.
166 * @return ETrue if exists, EFalse otherwise.
168 IMPORT_C static TBool ExistsMemoL(const TInt aKey);
171 * Get number of templates.
173 * Return an error code (less than zero) if any trouble.
175 * @return number of templates. returns error code (less than zero)
178 IMPORT_C static TInt NumberOfTemplates();
181 * Save contents of a specified file as a memo.
183 * @param aFileName the name of a file to be saved.
185 IMPORT_C static void SaveFileAsMemoL(const TDesC& aFileName);
188 * Save contents of a specified file as a memo.
190 * @param aFile the file handle.
192 IMPORT_C static void SaveFileAsMemoL(RFile& aFile);
195 * Save contents of a specified file as a memo.
197 * @param aFileName the name of a file to be saved.
198 * @param aEncoding The character encoding used in the file.
200 IMPORT_C static void SaveFileAsMemoL(const TDesC& aFileName, const TUint aEncoding);
203 * Save contents of a specified file as a memo.
205 * @param aFile the file handle.
206 * @param aEncoding The character encoding used in the file.
208 IMPORT_C static void SaveFileAsMemoL(RFile& aFile, const TUint aEncoding);
211 * Return internal Dialog object. (Internal to NpdLib)
215 IMPORT_C CEikDialog* Dialog();
218 * Return internal Model object. (Internal to NpdLib)
221 IMPORT_C CNotepadModel* Model();
224 * Create CNotepadListDialog.
226 * @param aResId resource id of type NOTEPAD_LIST_DIALOG.
228 IMPORT_C void CreateListDialogL(TInt aResId);
231 * Create CNotepadViewerDialog.
233 * @param aFileName filename to view.
234 * @param aTitle title pane (if NULL, filename is used).
235 * @param aDoWait create waiting dialog if ETrue.
236 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
237 * @param aEncoding encoding of the File
238 * (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
240 IMPORT_C void CreateViewerDialogL(
241 const TDesC& aFileName,
244 TBool aGuessEncoding = EFalse,
245 TUint aEncoding = KCharacterSetIdentifierIso88591);
248 * Create CNotepadViewerDialog.
250 * @param aFile file handle.
251 * @param aTitle title pane (if NULL, filename is used).
252 * @param aDoWait create waiting dialog if ETrue.
253 * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
254 * @param aEncoding encoding of the File
255 * (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
257 IMPORT_C void CreateViewerDialogL(
261 TBool aGuessEncoding = EFalse,
262 TUint aEncoding = KCharacterSetIdentifierIso88591);
265 * Create CNotepadViewerDialog.
267 * @param aDoWait create waiting dialog if ETrue.
269 IMPORT_C void CreateViewerDialogL(const TBool aDoWait);
272 * Create CNotepadModel.
274 * @param aResId resource id of type NOTEPAD_MODEL.
276 IMPORT_C void CreateModelL(TInt aResId);
279 * Probe a memo (API for Pinboard).
280 * This method is more efficient than ExistsMemoL
281 * when it is neccessary to probe many memos at a time.
283 * @param aKey a serial number of memo.
284 * @return ETrue if exists, EFalse otherwise.
286 IMPORT_C TBool ProbeMemoL(const TInt aKey);
289 * Execute text viewer dialog for read only text
291 * @param aText the text to be viewed.
292 * @param aTitle Title of the viewer dialog. If null, application default is used instead.
293 * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
294 * @return KErrNone or one of the global error codes.
296 IMPORT_C static TInt ExecReadOnlyTextViewerL(
298 const TDesC& aTitle = KNullDesC,
299 const TDesC& aDeleteConfirmationText = KNullDesC
303 * Execute text viewer dialog for editable text
305 * @param aReturnStatus KErrGeneral (-1) if the text was deleted. KErrNone otherwise
306 * @param aText the text to be viewed
307 * @param aTitle Title of the viewer dialog. If null, application default is used instead.
308 * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
309 * @return Pointer to modified text. Returns null if text was not edited..
311 IMPORT_C static HBufC* ExecTextViewerL(
314 const TDesC& aTitle = KNullDesC,
315 const TDesC& aDeleteConfirmationText = KNullDesC
319 * Execute text editor dialog
321 * @param aReturnStatus KErrGeneral (-1) if document was deleted, KErrNone otherwise.
322 * @param aText descriptor that holds the initial text. If null, editor starts empty
323 * @param aTitle Title of the editor dialog. If null, application default is used instead.
324 * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
325 * @return pointer to modified text.
327 IMPORT_C static HBufC* ExecTextEditorL(
329 const TDesC& aText = KNullDesC,
330 const TDesC& aTitle = KNullDesC,
331 const TDesC& aDeleteConfirmationText = KNullDesC
334 private: // Constructor
336 * private c++ constructor.
340 private: // New functions
343 * Creates text viewer dialog for editable text
345 * @param aReturnStatus KErrGeneral (-1) if the text was deleted. KErrNone otherwise
346 * @param aReadOnly indicates whether text is readonly or editable
347 * @param aText the text to be viewed
348 * @param aTitle Title of the viewer dialog. If null, application default is used instead.
349 * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
350 * @return Pointer to modified text. Returns null if text was not edited..
352 IMPORT_C void CreateTextViewerDialogL(
353 HBufC **aContentPointer,
357 const TDesC& aTitle = KNullDesC,
358 const TDesC& aDeleteConfirmationText = KNullDesC
362 * Creates text editor dialog
364 * @param aReturnStatus KErrGeneral (-1) if document was deleted, KErrNone otherwise.
365 * @param aText descriptor that holds the initial text. If null, editor starts empty
366 * @param aTitle Title of the editor dialog. If null, application default is used instead.
367 * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
368 * @return pointer to modified text.
370 IMPORT_C void CreateTextEditorDialogL(
371 HBufC **aContentPointer,
373 const TDesC& aText = KNullDesC,
374 const TDesC& aTitle = KNullDesC,
375 const TDesC& aDeleteConfirmationText = KNullDesC
381 * @param aTitle title of popup list.
382 * @param aModelResId resource id of type NOTEPAD_MODEL.
383 * @param aPromptResId resource id of prompt text, which is used when
385 * @param aEmptyTextResId resource id of empty text.
386 * @return fetched content, NULL if canceled or no entry.
392 TInt aEmptyTextResId = 0 );
397 * Reserved API entry.
400 IMPORT_C virtual void CNotepadApi_Reserved();
403 * Reserved API entry.
406 IMPORT_C static void CNotepadApi_Reserved_Static();
410 CCoeEnv* iEnv; // not own
411 CEikDialog* iDialog; // not own
412 CNotepadModel* iModel; // own
413 RConeResourceLoader iResourceLoader;