notepad/notepad1/inc/NpdDialogBase.h
changeset 0 f979ecb2b13e
child 27 55d60436f00b
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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         * Set iTitle text to title pane.
       
   192         * 
       
   193         */
       
   194         void RefreshTitleL();
       
   195 
       
   196 
       
   197         /**
       
   198         * Insert 'Send' menu item to aMenuPane just 
       
   199         * after aCommandId.
       
   200         * 
       
   201         * @param aSendUi CSendUi object.
       
   202         * @param aMenuPane menu pane to insert.
       
   203         * @param aCommandId new menu item is added after the position of this.
       
   204         */
       
   205         void InsertSendMenuItemAfterL(
       
   206             CSendUi& aSendUi,
       
   207             CEikMenuPane& aMenuPane, 
       
   208             TInt aCommandId );
       
   209 
       
   210         /**
       
   211         * For MCE, delayed exit.
       
   212         *
       
   213         * @return ETrue If delayed exit mode.
       
   214         */
       
   215         inline TBool IsExitDelayedBySendUi() const;
       
   216 
       
   217     protected:  // Functions from base classes
       
   218 
       
   219         /**
       
   220         * From CCoeControl.
       
   221         */
       
   222         void ActivateL();
       
   223 
       
   224         /**
       
   225         * From MEikCommandObserver
       
   226         * 
       
   227         * @param aCommandId command.
       
   228         */
       
   229         void ProcessCommandL(TInt aCommandId);
       
   230 
       
   231         /**
       
   232         * From MEikDialogPageObserver.
       
   233         * Create customized ListBox. 
       
   234         *
       
   235         * @param aControlType id of dialog line.
       
   236         * @return line control info.
       
   237         */
       
   238         SEikControlInfo CreateCustomControlL(TInt aControlType);
       
   239 
       
   240     private: // New functions
       
   241 
       
   242         /**
       
   243         * Send a file as an attachment.
       
   244         *
       
   245         * The MTM specified by aCommandId must have capability to send 
       
   246         * a file as attachment.
       
   247         *
       
   248         * @param aSendUi CSendUi object.
       
   249         * @param aCommandId a command id of send menu item.
       
   250         * @param aFileName a name of the file to be sent.
       
   251         */
       
   252         void SendFileAsAttachmentL( 
       
   253             CSendUi& aSendUi, 
       
   254             TInt aCommandId, 
       
   255             const TDesC& aFileName );
       
   256 
       
   257         /**
       
   258         * Send a file as an attachment.
       
   259         *
       
   260         * The MTM specified by aCommandId must have capability to send 
       
   261         * a file as attachment.
       
   262         *
       
   263         * @param aSendUi CSendUi object.
       
   264         * @param aCommandId a command id of send menu item.
       
   265         * @param aFileName a name of the file to be sent.
       
   266         */
       
   267         void SendFileAsAttachmentL( 
       
   268             CSendUi& aSendUi, 
       
   269             TInt aCommandId, 
       
   270             RFile& aFile );
       
   271 
       
   272         /**
       
   273         * For cleaning up the ENotepadSendUiRunning flag.
       
   274         */
       
   275         static void CleanupSendUiFlag(TAny *aSelf);
       
   276 
       
   277         /**
       
   278         * Reserved API entry.
       
   279         *
       
   280         * @internal
       
   281         */
       
   282         IMPORT_C void CNotepadDialogBase_Reserved();
       
   283 
       
   284     protected:  // Data
       
   285 
       
   286         TInt iResId; // dialog ResourceId
       
   287         CEikDialog** iSelfPtr;
       
   288         TBool iMskFlag;
       
   289 
       
   290     private:  // inner class
       
   291 
       
   292         /**
       
   293         * CTemporaryFiles is a class for temprary files.
       
   294         *
       
   295         * We must not only close but also 
       
   296         * 'Delete' the temorary files even when some function LEAVES while 
       
   297         * using it.
       
   298         */
       
   299         class CTemporaryFiles : public CDesC16ArrayFlat
       
   300             {
       
   301             public: //constructor, destructor
       
   302                 CTemporaryFiles(TInt aGranularity, CEikonEnv& aEikonEnv);
       
   303                 /**
       
   304 		        * Destructor.
       
   305 		        */
       
   306                 virtual ~CTemporaryFiles();
       
   307             public: // new function
       
   308             /*
       
   309 			* CNotepadDialogBase::CTemporaryFiles::AppendL
       
   310 			
       
   311 			* if you need some code conversion....
       
   312 			* CPlainText::TImportExportParam param;
       
   313 			* param.iForeignEncoding = KCharacterSetIdentifierUtf8; // target encoding
       
   314 			* CPlainText::TImportExportResult result;
       
   315 			* text->ExportTextL(0, stream, param, result);
       
   316 			*/
       
   317                 void AppendL(const CPlainText& aText);
       
   318             private: // data
       
   319                 CEikonEnv& iEnv; // not own
       
   320             public:
       
   321                 TBuf16<150> iSendFileName;
       
   322             };
       
   323     public:
       
   324 		/**
       
   325         * CCreateAndAppendFiles is an active object to create and append
       
   326         * attachments.
       
   327         */
       
   328         NONSHARABLE_CLASS(CCreateAndAppendFiles) : public CActive, public MProgressDialogCallback
       
   329             {
       
   330             public: // constructor, destructor
       
   331             
       
   332             	/**
       
   333 		        * CCreateAndAppendFiles* NewL
       
   334 		        * @param aReader resource reader already opened for 
       
   335 		        */
       
   336                 static CCreateAndAppendFiles* NewL(
       
   337 					CSendUi& aSendAppUi, 
       
   338 					TInt aCommandId, 
       
   339 					CNotepadModel& aModel,
       
   340 					RArray<TInt> aKeys,
       
   341 					CEikonEnv& aEikonEnv,
       
   342 					TInt& aBaseFlags,
       
   343 					CNotepadDialogBase* aNpdDlgBase,
       
   344 					TUid aServiceUId);
       
   345               /**
       
   346 		        * CCreateAndAppendFiles
       
   347 		        * @param aReader resource reader already opened for 
       
   348 		        */ 
       
   349               CCreateAndAppendFiles(
       
   350 					CSendUi& aSendAppUi, 
       
   351 					TInt aCommandId, 
       
   352 					CNotepadModel& aModel,
       
   353 					//RArray<TInt> aKeys,
       
   354 					CEikonEnv& aEikonEnv,
       
   355 					TInt& aBaseFlags,
       
   356 					CNotepadDialogBase* aNpdDlgBase,
       
   357 					TUid aServiceUId);
       
   358            		/**
       
   359 		        * Second phase constructor.
       
   360 		        * @param aReader resource reader already opened for 
       
   361 		        */
       
   362                 void ConstructL(RArray<TInt> aKeys);
       
   363                 
       
   364                 /**
       
   365 		        * Destructor.
       
   366 		        */
       
   367                  ~CCreateAndAppendFiles();
       
   368            		/**
       
   369 		        * Creates CAknProgressDialog object and creates a progress bar
       
   370 		        */
       
   371 				void ShowProgressBarL();
       
   372 				
       
   373 				/**
       
   374 		        * Deletes the CAknProgressDialog object if it is already created.
       
   375 		        */
       
   376 				void EndProgressDialog();
       
   377 				
       
   378 				/**
       
   379 		        * Attaches the selected notes to the message asynchronously.
       
   380 		        */
       
   381 				void StartAttachingL();
       
   382 				
       
   383 				/**
       
   384 		        * Call back function called when Dialog is dismissed.
       
   385 		        */
       
   386 				void DialogDismissedL( TInt aButtonId );
       
   387                 void RunL();
       
   388                 void DoCancel();
       
   389             private: // data
       
   390 				CSendUi& iSendAppUi;
       
   391 				TInt iCommandId;
       
   392 				CNotepadModel& iModel;
       
   393 				RArray<TInt> iKeys;
       
   394 				TInt iTotalCount;
       
   395 				CNotepadDialogBase::CTemporaryFiles* iFiles;
       
   396 				CPlainText* iText;
       
   397 				TInt iCount;
       
   398 				TBool iAttaching;
       
   399 				TBool iCanceled;
       
   400 				CEikonEnv& iEnv;
       
   401 				TInt& iBaseFlags;
       
   402 				CAknProgressDialog* iProgressBar;
       
   403 				CMessageData* imessageData ;
       
   404 				RFs iFs;
       
   405 				CArrayFixFlat<RFile> *array;
       
   406 				RFile ifile1;
       
   407 				TUid iServiceUId;
       
   408 				CNotepadListDialog *iListDialog; //Not owned 
       
   409 
       
   410             };
       
   411 
       
   412     private:  // Data
       
   413 
       
   414         enum TNotepadDialogBaseFlags
       
   415             {
       
   416             ENotepadSendUiRunning = 0x01,
       
   417             ENotepadSendUiDelayedExit = 0x02
       
   418             };
       
   419 
       
   420         TDesC* iTitle; // own
       
   421         HBufC* iSavedTitle; // own (copied)
       
   422         CAknTitlePane* iTitlePane; // not own (cached)
       
   423         RFile iFile;
       
   424 
       
   425         TInt iBaseFlags;
       
   426        public:
       
   427        
       
   428         CNotepadDialogBase::CCreateAndAppendFiles* iCreateFile;
       
   429     };
       
   430 
       
   431 #include "NpdDialogBase.inl"
       
   432 #endif // NPDDIALOGBASE_H
       
   433 
       
   434 // End of File