notepad/notepad1/inc/NpdLoadFileAO.h
branchRCL_3
changeset 48 bf573002ff72
equal deleted inserted replaced
36:9c5b1510919f 48:bf573002ff72
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  A long task wrapper for load file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CNOTEPADLOADFILEAO_H
       
    21 #define CNOTEPADLOADFILEAO_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <txtetext.h>
       
    27 #include <f32file.h>
       
    28 #include "MNpdLoadFileObserver.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CCoeEnv;
       
    32 class RFile;
       
    33 class CPlainText;
       
    34 class RFileReadStream;
       
    35 
       
    36 // CONSTANTS
       
    37 // the completed code for load file in one step
       
    38 static const TInt KErrStep = 10000;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 *  The class implements a long task wrapper for load file
       
    43 *
       
    44 *  @lib NpdLib.lib
       
    45 *  @since 5.2
       
    46 */
       
    47 NONSHARABLE_CLASS(CNotepadLoadFileAO) : public CActive
       
    48     {
       
    49     public:
       
    50         static CNotepadLoadFileAO* NewL( MNotepadLoadFileObserver* aObserver,
       
    51                                          CCoeEnv& aCoeEnv,
       
    52                                          RFile& aFile, 
       
    53                                          TBool aGuessEncoding,
       
    54                                          TUint aEncoding, 
       
    55                                          CPlainText& aText );
       
    56 
       
    57         ~CNotepadLoadFileAO();
       
    58 
       
    59     public: // New functions
       
    60        
       
    61         /**
       
    62         * Starts load file .
       
    63         * @return start load file successful or not, KErrNone is sucessed, other failed
       
    64         * @since 5.2
       
    65         */
       
    66         TInt StartLoadFile( );
       
    67 
       
    68         /**
       
    69         * Cancels load file .
       
    70         * @since 5.2
       
    71         */
       
    72         void CancelLoadFile();
       
    73 
       
    74    
       
    75 
       
    76     private: // From CActive
       
    77         void RunL();
       
    78         
       
    79         void DoCancel();
       
    80         
       
    81     private:
       
    82         CNotepadLoadFileAO( MNotepadLoadFileObserver* aObserver,
       
    83                             CCoeEnv& aCoeEnv,
       
    84                             RFile& aFile, 
       
    85                             TBool aGuessEncoding,
       
    86                             TUint aEncoding, 
       
    87                             CPlainText& aText );
       
    88 
       
    89         void ConstructL();
       
    90         
       
    91         /**
       
    92         * Initialize import export param for CPlianText.
       
    93         * @since 5.2
       
    94         */
       
    95         void InitImportExportParamL();
       
    96         
       
    97         
       
    98         /**
       
    99         * Run step for load file.
       
   100         * @since 5.2
       
   101         */
       
   102         void DoStepL();
       
   103         
       
   104 
       
   105     private: // Data
       
   106         
       
   107         // Ref: Pointer to thread function observer
       
   108         MNotepadLoadFileObserver* iObserver;
       
   109           
       
   110         // Ref: refrence to Control environment
       
   111         CCoeEnv& iCoeEnv;
       
   112         
       
   113         // Own: the file object to load
       
   114         RFile iFile;
       
   115         
       
   116         // indicate guess encoding or not
       
   117         TBool iGuessEncoding;
       
   118         
       
   119         // aEncoding encoding of the File
       
   120         TUint iEncoding;
       
   121         
       
   122         // Ref: refrence to CPlainText object
       
   123         CPlainText& iText;
       
   124         
       
   125         // the size of the file to load
       
   126         TInt iFileSize;
       
   127         
       
   128         // the current pos of the file 
       
   129         TInt iReadPos;
       
   130         
       
   131         // indicate cancel load file or not
       
   132         TBool iCancel;
       
   133         
       
   134         // Own: the import export param for CPlianText
       
   135         CPlainText::TImportExportParam iParam;
       
   136               
       
   137     };
       
   138 
       
   139 #endif // CNOTEPADLOADFILEAO_H
       
   140 
       
   141 // End of File