Purpose

The purpose of Notepad Library API is to access Notepad's functionality from another client application. It provides functions such as handling the memos, handling the templates, viewing and saving the text files. This document is valid for S60 3rd Edition, Feature Pack 2.

API description

Notepad Library API is used to get the number of templates available, fetch the details of templates from the list and to execute those. Similarly it is used to fetch, create or probe a memo. Also it can be used to open a text file, save the contents or text files as a memo.

Use cases

There are four use cases of Notepad Library API:

  • Handling templates

  • Handling memos

  • Viewing files

  • Opening Editor

API class structure

Class diagram of the Notepad Library API


Class diagram of the Notepad Library API

Using Notepad Library API

Handling templates

FetchTemplateL static function from Notepad Library API can be used for fetching the templates. See usage example of the FetchTemplateL function below.

             
              //Returns NULL if the popup list is cancelled or there is no template. aTitle is Optional parameter for title.
              

HBufC* buf = CNotepadApi::FetchTemplateL( aTitle );

The ExecTemplatesL static function from Notepad Library API can be used for executing the Templates. See usage example of the ExecTemplatesL function below.

             
              //Returns exit status.
              

CNotepadApi::ExecTemplatesL();
Related APIs
  • ExecTemplatesL
  • FetchTemplateL

Handling memos

The FetchMemoL static function from Notepad Library API can be used for fetching the memos. See usage example of the FetchMemoL function below.

             
              //Returns NULL if the popup list is cancelled or there is no memo. aTitle is Optional parameter for title.
              

HBufC* desc = CNotepadApi::FetchMemoL( aTitle );
Related APIs
  • FetchMemoL

Viewing files

The ExecFileViewerL static function from Notepad Library API can be used for showing the contents of text file. See usage example of the ExecFileViewerL function using the file handle below.

             
              //Creates non-wait/waiting CNotepadViewerDialog. 
              
//Following snippet of code Creates waiting dialog with given file name.
//file is a handle of opened aFileName file. aTitle TitlePane string, if it is NULL then Title will be FileName.
//aDoWait is used for non-wait/waiting dialog.
// aGuessEncoding guess encoding if ETrue, it ignores charconvCharsetID. charconvCharsetID encoding of the File, default is ISO-8859-1 and returns Dialog's exit status.

RFs fileSession;
RFile file;
User::LeaveIfError(fileSession.Connect());
CleanupClosePushL(fileSession);
User::LeaveIfError(file.Open(fileSession, aFileName, EFileRead));
CleanupClosePushL(file);

CNotepadApi::ExecFileViewerL( file, 
NULL, ETrue, EFalse, charconvCharsetID );

Another overloaded ExecFileViewerL static function from Notepad Library API can also be used for showing the contents of text file. In the previous code snippet the file handle is used as a parameter. In the following usage example of the ExecFileViewerL function the file name is used as a parameter.

             
              // filename is the name of the file to open by Notepad Library API.
              
CNotepadApi::ExecFileViewerL( fileName );
Related APIs
  • ExecFileViewerL

Opening Editor

The ExecTextEditorL static function from Notepad Library API can be used for opening the editor. See usage example of the ExecTextEditorL function below.

             
              //aReturnStatus is the return status, returns KErrGeneral (-1) if document was deleted and KErrNone in other case. aDescription parameter tells about the initial text. If null, editor starts empty. title is the title of the editor dialog. delConf Confirmation text is shown if user chooses to delete the document. This function returns pointer to the modified text.
              

HBufC* desc = CNotepadApi::ExecTextEditorL(aStatus, aDescription, *title, *delConf);
Related APIs
  • ExecTextEditorL

Error handling

Normal Symbian platform error handling practises should be used, including e.g. using cleanup stack and trap harness. Leaves and system wide error codes as function return values are used if the error is recoverable. A client application can handle these errors similarly as a normal Symbian platform application.