epoc32/include/app/NpdApi.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description:  Declaration of Notepad Library APIs.
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@4
    18
williamr@4
    19
#ifndef NPDAPI_H
williamr@4
    20
#define NPDAPI_H
williamr@4
    21
williamr@4
    22
// INCLUDES
williamr@4
    23
#include <e32base.h>
williamr@4
    24
#include <charconv.h>
williamr@4
    25
#include <ConeResLoader.h>
williamr@4
    26
#include <f32file.h>
williamr@4
    27
williamr@4
    28
// CONSTANTS
williamr@4
    29
const TInt KNotepadPseudoKeyIdForNewNote(-1);
williamr@4
    30
williamr@4
    31
// FORWARD DECLARATIONS
williamr@4
    32
class CCoeEnv;
williamr@4
    33
class CEikDialog;
williamr@4
    34
class CNotepadModel;
williamr@4
    35
class CNotepadTableModel;
williamr@4
    36
class CPlainText;
williamr@4
    37
williamr@4
    38
// CLASS DECLARATION
williamr@4
    39
/**
williamr@4
    40
* APIs of Notepad library.
williamr@4
    41
* CNotepadApi provides APIs for other modules.
williamr@4
    42
*
williamr@4
    43
* @lib NpdLib.lib
williamr@4
    44
*/
williamr@4
    45
class CNotepadApi : public CBase
williamr@4
    46
    {
williamr@4
    47
    public:
williamr@4
    48
    
williamr@4
    49
    	/* Enum for the status of the memos.
williamr@4
    50
    	*  ENpdDataEdited : Data is edited in the Editor dialog of the opened memo.
williamr@4
    51
    	*  ENpdDataDeleted : Data is deleted in the Editor dialog of the opened memo.
williamr@4
    52
    	*  ENpdDataErased : Data is erased in the Editor dialog of the opened memo.*/
williamr@4
    53
        enum 
williamr@4
    54
            {
williamr@4
    55
            ENpdDataEdited = 0,
williamr@4
    56
            ENpdDataDeleted,        
williamr@4
    57
            ENpdDataErased
williamr@4
    58
            };
williamr@4
    59
williamr@4
    60
    public: // Constuctors and destructor
williamr@4
    61
williamr@4
    62
        /**
williamr@4
    63
        * Constructor.
williamr@4
    64
        * Add a resource file of NpdLib.
williamr@4
    65
        *
williamr@4
    66
        * @return constructed CNotepadApi object.
williamr@4
    67
        */
williamr@4
    68
        IMPORT_C static CNotepadApi* NewL();
williamr@4
    69
williamr@4
    70
        /**
williamr@4
    71
        * Constructor, returned value is also kept on the CleanupStack.
williamr@4
    72
        * Add a resource file of NpdLib.
williamr@4
    73
        *
williamr@4
    74
        * @return constructed CNotepadApi object.
williamr@4
    75
        */
williamr@4
    76
        IMPORT_C static CNotepadApi* NewLC();
williamr@4
    77
williamr@4
    78
        /**
williamr@4
    79
        * Destructor.
williamr@4
    80
        * Remove a resource file of NpdLib.
williamr@4
    81
        */
williamr@4
    82
        IMPORT_C virtual ~CNotepadApi();
williamr@4
    83
williamr@4
    84
    public: // API functions
williamr@4
    85
williamr@4
    86
        /**
williamr@4
    87
        * Fetch a memo.
williamr@4
    88
        *
williamr@4
    89
        * No need for a pre-allocated buffer.
williamr@4
    90
        * Return NULL if the popup list is canceled or there is no memo.
williamr@4
    91
        * Caller owns the returned HBufC object.
williamr@4
    92
        *
williamr@4
    93
        * @param aTitle Optional title text.
williamr@4
    94
        * @return fetched string, (NULL if canceled or no memo).
williamr@4
    95
        */
williamr@4
    96
        IMPORT_C static HBufC* FetchMemoL(
williamr@4
    97
            const TDesC* aTitle = NULL);
williamr@4
    98
williamr@4
    99
        /**
williamr@4
   100
        * Fetch a template.
williamr@4
   101
        *
williamr@4
   102
        * No need for a pre-allocated buffer.
williamr@4
   103
        * Return NULL if the popup list is canceled or there is no template.
williamr@4
   104
        * Caller owns the returned HBufC object.
williamr@4
   105
        *
williamr@4
   106
        * @param aTitle Optional title text.
williamr@4
   107
        * @return fetched string, (NULL if canceled or no templates).
williamr@4
   108
        */
williamr@4
   109
        IMPORT_C static HBufC* FetchTemplateL(
williamr@4
   110
            const TDesC* aTitle = NULL);
williamr@4
   111
williamr@4
   112
        /**
williamr@4
   113
        * Execute MCE's "List of templates".
williamr@4
   114
        *
williamr@4
   115
        * @return CEikDialog's exit status.
williamr@4
   116
        */
williamr@4
   117
        IMPORT_C static TInt ExecTemplatesL();
williamr@4
   118
williamr@4
   119
        /**
williamr@4
   120
        * Execute a file viewer dialog.
williamr@4
   121
        *
williamr@4
   122
        * @param aFileName text file to view.
williamr@4
   123
        * @param aTitle  TitlePane string (if NULL, Title will be FileName).
williamr@4
   124
        * @param aDoWait Use wait dialog if ETrue.
williamr@4
   125
        * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
williamr@4
   126
        * @param aEncoding encoding of the File
williamr@4
   127
        *   (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
williamr@4
   128
        * @return CEikDialog's exit status.
williamr@4
   129
        */
williamr@4
   130
        IMPORT_C static TInt ExecFileViewerL(
williamr@4
   131
            const TDesC& aFileName, 
williamr@4
   132
            const TDesC* aTitle = NULL,
williamr@4
   133
            const TBool aDoWait = ETrue,
williamr@4
   134
            TBool aGuessEncoding = EFalse,
williamr@4
   135
            TUint aEncoding = KCharacterSetIdentifierIso88591);
williamr@4
   136
williamr@4
   137
        /**
williamr@4
   138
        * Execute a file viewer dialog.
williamr@4
   139
        *
williamr@4
   140
        * @param aFile file handle.
williamr@4
   141
        * @param aTitle  TitlePane string (if NULL, Title will be FileName).
williamr@4
   142
        * @param aDoWait Use wait dialog if ETrue.
williamr@4
   143
        * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
williamr@4
   144
        * @param aEncoding encoding of the File
williamr@4
   145
        *   (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
williamr@4
   146
        * @return CEikDialog's exit status.
williamr@4
   147
        */
williamr@4
   148
        IMPORT_C static TInt ExecFileViewerL(
williamr@4
   149
            RFile& aFile, 
williamr@4
   150
            const TDesC* aTitle = NULL,
williamr@4
   151
            const TBool aDoWait = ETrue,
williamr@4
   152
            TBool aGuessEncoding = EFalse,
williamr@4
   153
            TUint aEncoding = KCharacterSetIdentifierIso88591);
williamr@4
   154
williamr@4
   155
        /**
williamr@4
   156
        * Save text as a memo.
williamr@4
   157
        *
williamr@4
   158
        * @param aText    memo text to save.
williamr@4
   159
        */
williamr@4
   160
        IMPORT_C static void AddContentL(const TDesC& aText);
williamr@4
   161
williamr@4
   162
        /**
williamr@4
   163
        * Probe a memo (API for Pinboard).
williamr@4
   164
        *
williamr@4
   165
        * @param aKey a serial number of memo.
williamr@4
   166
        * @return ETrue if exists, EFalse otherwise.
williamr@4
   167
        */
williamr@4
   168
        IMPORT_C static TBool ExistsMemoL(const TInt aKey);
williamr@4
   169
williamr@4
   170
        /**
williamr@4
   171
        * Get number of templates.
williamr@4
   172
        *
williamr@4
   173
        * Return an error code (less than zero) if any trouble.
williamr@4
   174
        *
williamr@4
   175
        * @return number of templates. returns error code (less than zero)
williamr@4
   176
        *     if any trouble.
williamr@4
   177
        */
williamr@4
   178
        IMPORT_C static TInt NumberOfTemplates();
williamr@4
   179
williamr@4
   180
        /**
williamr@4
   181
        * Save contents of a specified file as a memo.
williamr@4
   182
        *
williamr@4
   183
        * @param aFileName the name of a file to be saved.
williamr@4
   184
        */
williamr@4
   185
        IMPORT_C static void SaveFileAsMemoL(const TDesC& aFileName);
williamr@4
   186
williamr@4
   187
        /**
williamr@4
   188
        * Save contents of a specified file as a memo.
williamr@4
   189
        *
williamr@4
   190
        * @param aFile the file handle.
williamr@4
   191
        */
williamr@4
   192
        IMPORT_C static void SaveFileAsMemoL(RFile& aFile);
williamr@4
   193
williamr@4
   194
       	/**
williamr@4
   195
        * Save contents of a specified file as a memo.
williamr@4
   196
        *
williamr@4
   197
        * @param aFileName the name of a file to be saved.
williamr@4
   198
        * @param aEncoding The character encoding used in the file.
williamr@4
   199
       	*/
williamr@4
   200
        IMPORT_C static void SaveFileAsMemoL(const TDesC& aFileName, const TUint aEncoding);
williamr@4
   201
williamr@4
   202
       	/**
williamr@4
   203
        * Save contents of a specified file as a memo.
williamr@4
   204
        *
williamr@4
   205
        * @param aFile the file handle.
williamr@4
   206
        * @param aEncoding The character encoding used in the file.
williamr@4
   207
       	*/
williamr@4
   208
        IMPORT_C static void SaveFileAsMemoL(RFile& aFile, const TUint aEncoding);
williamr@4
   209
        
williamr@4
   210
        /**
williamr@4
   211
        * Return internal Dialog object. (Internal to NpdLib)
williamr@4
   212
        *
williamr@4
   213
        * @internal 
williamr@4
   214
        */
williamr@4
   215
        IMPORT_C CEikDialog* Dialog();
williamr@4
   216
williamr@4
   217
        /**
williamr@4
   218
        * Return internal Model object. (Internal to NpdLib)
williamr@4
   219
        *
williamr@4
   220
        */
williamr@4
   221
        IMPORT_C CNotepadModel* Model();
williamr@4
   222
williamr@4
   223
        /**
williamr@4
   224
        * Create CNotepadListDialog.
williamr@4
   225
        *
williamr@4
   226
        * @param aResId resource id of type NOTEPAD_LIST_DIALOG.
williamr@4
   227
        */
williamr@4
   228
        IMPORT_C void CreateListDialogL(TInt aResId);
williamr@4
   229
williamr@4
   230
        /**
williamr@4
   231
        * Create CNotepadViewerDialog.
williamr@4
   232
        *
williamr@4
   233
        * @param aFileName filename to view.
williamr@4
   234
        * @param aTitle title pane (if NULL, filename is used).
williamr@4
   235
        * @param aDoWait create waiting dialog if ETrue.
williamr@4
   236
        * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
williamr@4
   237
        * @param aEncoding encoding of the File
williamr@4
   238
        *     (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
williamr@4
   239
        */
williamr@4
   240
        IMPORT_C void CreateViewerDialogL(
williamr@4
   241
            const TDesC& aFileName, 
williamr@4
   242
            const TDesC* aTitle,
williamr@4
   243
            const TBool aDoWait,
williamr@4
   244
            TBool aGuessEncoding = EFalse,
williamr@4
   245
            TUint aEncoding = KCharacterSetIdentifierIso88591);
williamr@4
   246
williamr@4
   247
        /**
williamr@4
   248
        * Create CNotepadViewerDialog.
williamr@4
   249
        *
williamr@4
   250
        * @param aFile file handle.
williamr@4
   251
        * @param aTitle title pane (if NULL, filename is used).
williamr@4
   252
        * @param aDoWait create waiting dialog if ETrue.
williamr@4
   253
        * @param aGuessEncoding guess encoding if ETrue (ignore aEncoding).
williamr@4
   254
        * @param aEncoding encoding of the File
williamr@4
   255
        *     (default ISO-8859-1. This is ignored if aGuessEncoding is ETrue).
williamr@4
   256
        */
williamr@4
   257
        IMPORT_C void CreateViewerDialogL(
williamr@4
   258
            RFile& aFile, 
williamr@4
   259
            const TDesC* aTitle,
williamr@4
   260
            const TBool aDoWait,
williamr@4
   261
            TBool aGuessEncoding = EFalse,
williamr@4
   262
            TUint aEncoding = KCharacterSetIdentifierIso88591);
williamr@4
   263
williamr@4
   264
        /**
williamr@4
   265
        * Create CNotepadViewerDialog.
williamr@4
   266
        *
williamr@4
   267
        * @param aDoWait create waiting dialog if ETrue.
williamr@4
   268
        */
williamr@4
   269
        IMPORT_C void CreateViewerDialogL(const TBool aDoWait);
williamr@4
   270
williamr@4
   271
        /**
williamr@4
   272
        * Create CNotepadModel.
williamr@4
   273
        *
williamr@4
   274
        * @param aResId resource id of type NOTEPAD_MODEL.
williamr@4
   275
        */
williamr@4
   276
        IMPORT_C void CreateModelL(TInt aResId);
williamr@4
   277
williamr@4
   278
        /**
williamr@4
   279
        * Probe a memo (API for Pinboard).
williamr@4
   280
        * This method is more efficient than ExistsMemoL
williamr@4
   281
        * when it is neccessary to probe many memos at a time.
williamr@4
   282
        *
williamr@4
   283
        * @param aKey a serial number of memo.
williamr@4
   284
        * @return ETrue if exists, EFalse otherwise.
williamr@4
   285
        */
williamr@4
   286
        IMPORT_C TBool ProbeMemoL(const TInt aKey);
williamr@4
   287
williamr@4
   288
        /**
williamr@4
   289
        * Execute text viewer dialog for read only text
williamr@4
   290
        *
williamr@4
   291
        * @param aText the text to be viewed. 
williamr@4
   292
        * @param aTitle Title of the viewer dialog. If null, application default is used instead.
williamr@4
   293
        * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
williamr@4
   294
        * @return KErrNone or one of the global error codes. 
williamr@4
   295
        */
williamr@4
   296
        IMPORT_C static TInt ExecReadOnlyTextViewerL(
williamr@4
   297
            const TDesC& aText, 
williamr@4
   298
            const TDesC& aTitle = KNullDesC, 
williamr@4
   299
            const TDesC& aDeleteConfirmationText = KNullDesC
williamr@4
   300
            );
williamr@4
   301
williamr@4
   302
        /**
williamr@4
   303
        * Execute text viewer dialog for editable text 
williamr@4
   304
        *
williamr@4
   305
        * @param aReturnStatus KErrGeneral (-1) if the text was deleted. KErrNone otherwise 
williamr@4
   306
        * @param aText the text to be viewed
williamr@4
   307
        * @param aTitle Title of the viewer dialog. If null, application default is used instead.
williamr@4
   308
        * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
williamr@4
   309
        * @return Pointer to modified text. Returns null if text was not edited.. 
williamr@4
   310
        */
williamr@4
   311
        IMPORT_C static HBufC* ExecTextViewerL(
williamr@4
   312
            TInt& aReturnStatus, 
williamr@4
   313
            const TDesC& aText, 
williamr@4
   314
            const TDesC& aTitle = KNullDesC, 
williamr@4
   315
            const TDesC& aDeleteConfirmationText = KNullDesC
williamr@4
   316
            );
williamr@4
   317
williamr@4
   318
        /**
williamr@4
   319
        * Execute text editor dialog 
williamr@4
   320
        *
williamr@4
   321
        * @param aReturnStatus KErrGeneral (-1) if document was deleted, KErrNone otherwise.
williamr@4
   322
        * @param aText descriptor that holds the initial text. If null, editor starts empty
williamr@4
   323
        * @param aTitle Title of the editor dialog. If null, application default is used instead.
williamr@4
   324
        * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
williamr@4
   325
        * @return pointer to modified text. 
williamr@4
   326
        */
williamr@4
   327
        IMPORT_C static HBufC* ExecTextEditorL(
williamr@4
   328
            TInt& aReturnStatus,  
williamr@4
   329
            const TDesC& aText = KNullDesC, 
williamr@4
   330
            const TDesC& aTitle = KNullDesC, 
williamr@4
   331
            const TDesC& aDeleteConfirmationText = KNullDesC
williamr@4
   332
            );
williamr@4
   333
williamr@4
   334
    private: // Constructor
williamr@4
   335
         /**
williamr@4
   336
        * private c++ constructor.
williamr@4
   337
        */
williamr@4
   338
        CNotepadApi();
williamr@4
   339
williamr@4
   340
    private: // New functions
williamr@4
   341
williamr@4
   342
        /**
williamr@4
   343
        * Creates text viewer dialog for editable text 
williamr@4
   344
        *
williamr@4
   345
        * @param aReturnStatus KErrGeneral (-1) if the text was deleted. KErrNone otherwise 
williamr@4
   346
        * @param aReadOnly indicates whether text is readonly or editable 
williamr@4
   347
        * @param aText the text to be viewed
williamr@4
   348
        * @param aTitle Title of the viewer dialog. If null, application default is used instead.
williamr@4
   349
        * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
williamr@4
   350
        * @return Pointer to modified text. Returns null if text was not edited.. 
williamr@4
   351
        */
williamr@4
   352
        IMPORT_C void CreateTextViewerDialogL(
williamr@4
   353
            HBufC **aContentPointer,
williamr@4
   354
            TInt& aReturnStatus,
williamr@4
   355
            TBool aReadOnly,
williamr@4
   356
            const TDesC& aText, 
williamr@4
   357
            const TDesC& aTitle = KNullDesC, 
williamr@4
   358
            const TDesC& aDeleteConfirmationText = KNullDesC
williamr@4
   359
            );
williamr@4
   360
williamr@4
   361
        /**
williamr@4
   362
        * Creates text editor dialog 
williamr@4
   363
        *
williamr@4
   364
        * @param aReturnStatus KErrGeneral (-1) if document was deleted, KErrNone otherwise.
williamr@4
   365
        * @param aText descriptor that holds the initial text. If null, editor starts empty
williamr@4
   366
        * @param aTitle Title of the editor dialog. If null, application default is used instead.
williamr@4
   367
        * @param aDeleteConfirmationText Confirmation text shown if user chooses to delete the document
williamr@4
   368
        * @return pointer to modified text. 
williamr@4
   369
        */
williamr@4
   370
        IMPORT_C void CreateTextEditorDialogL(
williamr@4
   371
            HBufC **aContentPointer,
williamr@4
   372
            TInt& aReturnStatus,
williamr@4
   373
            const TDesC& aText = KNullDesC, 
williamr@4
   374
            const TDesC& aTitle = KNullDesC, 
williamr@4
   375
            const TDesC& aDeleteConfirmationText = KNullDesC
williamr@4
   376
            );
williamr@4
   377
williamr@4
   378
        /**
williamr@4
   379
        * Show PopupList.
williamr@4
   380
        *
williamr@4
   381
        * @param aTitle title of popup list.
williamr@4
   382
        * @param aModelResId resource id of type NOTEPAD_MODEL.
williamr@4
   383
        * @param aPromptResId resource id of prompt text, which is used when
williamr@4
   384
        *    aTitle is NULL.
williamr@4
   385
        * @param aEmptyTextResId resource id of empty text.
williamr@4
   386
        * @return fetched content, NULL if canceled or no entry.
williamr@4
   387
        */
williamr@4
   388
        HBufC* DoPopupListL(
williamr@4
   389
            const TDesC* aTitle, 
williamr@4
   390
            TInt aModelResId,
williamr@4
   391
            TInt aPromptResId, 
williamr@4
   392
            TInt aEmptyTextResId = 0 );
williamr@4
   393
williamr@4
   394
    private: // Reserved
williamr@4
   395
williamr@4
   396
        /**
williamr@4
   397
        * Reserved API entry.
williamr@4
   398
        * @internal
williamr@4
   399
        */
williamr@4
   400
        IMPORT_C virtual void CNotepadApi_Reserved();
williamr@4
   401
williamr@4
   402
        /**
williamr@4
   403
        * Reserved API entry.
williamr@4
   404
        * @internal
williamr@4
   405
        */
williamr@4
   406
        IMPORT_C static void CNotepadApi_Reserved_Static();
williamr@4
   407
williamr@4
   408
    private: // Data
williamr@4
   409
williamr@4
   410
        CCoeEnv* iEnv; // not own
williamr@4
   411
        CEikDialog* iDialog; // not own
williamr@4
   412
        CNotepadModel* iModel; // own
williamr@4
   413
        RConeResourceLoader iResourceLoader;
williamr@4
   414
williamr@4
   415
    };
williamr@4
   416
williamr@4
   417
#endif // NPDAPI_H
williamr@4
   418
williamr@4
   419
// End of File
williamr@4
   420