landmarksui/engine/inc/CLmkParser.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2005 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:    LandmarksUi Content File -    This class provides methods to interact with Landmark Framework parser
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CLMKPARSER_H
       
    25 #define CLMKPARSER_H
       
    26 
       
    27 //  INCLUDES
       
    28 
       
    29 #include <e32base.h>
       
    30 #include "MLmkAOOperationObserver.h"
       
    31 #include <EPos_CPosLandmarkCategory.h>
       
    32 #include "CLmkLandmark.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CPosLandmarkParser;
       
    36 class CPosLandmarkDatabase;
       
    37 class CLmkAOOperation;
       
    38 class CPosLandmark;
       
    39 class CLmkDbUtils;
       
    40 class CLmkParseAllWrapper;
       
    41 class RFile;
       
    42 class CLmkLandMarkCategoriesName;
       
    43 class TDataType;
       
    44 
       
    45 #if 0
       
    46 // FORWARD DECLARATIONS
       
    47 class RFile;
       
    48 class CLmkDbUtils;
       
    49 class CPosLandmarkParser;
       
    50 class CPosLandmarkDatabase;
       
    51 class CLmkAOOperation;
       
    52 class CPosLandmark;
       
    53 class CLmkParseAllWrapper;
       
    54 
       
    55 class CLmkLandMarkCategoriesName;
       
    56 #endif
       
    57 
       
    58 // CLASS DECLARATION
       
    59 /**
       
    60 * CLmkParser class
       
    61 * This class provides methods to interact with Landmarks Framework parser for parsing
       
    62 * the landmarks received in the landmarks package via messaging
       
    63 *
       
    64 * It returns the parsed landmark data (object) to the client of this class
       
    65 *
       
    66 * This class is mainly used by the Landmarks Message viewer application classes for
       
    67 * displaying landmarks received in landmarks package
       
    68 */
       
    69 class CLmkParser : public CBase, public MLmkAOOperationObserver
       
    70     {
       
    71 	public:  // Constructors and destructor
       
    72 
       
    73 		/**
       
    74 		* Create CLmkParser object
       
    75         * @param aFile File to be parsed
       
    76         * @param aDb handle to landmark database
       
    77         * @param aObserver Caller can set itself as observer of parser class
       
    78         * @param aProgressNote Note for showing the progress of the parsing operation
       
    79 		* @return newly instantiated object
       
    80 		*/
       
    81 		IMPORT_C static CLmkParser* NewL( const TDesC& aFile,
       
    82                                           CPosLandmarkDatabase& aDb,
       
    83                                           MLmkAOOperationObserver& aObserver,
       
    84                                           TBool aProgressNote );
       
    85 
       
    86 		/**
       
    87 		* This method creates a new parser object
       
    88 		* @param aFile File to be parsed
       
    89         * @param aDb handle to landmark database
       
    90         * @param aObserver Caller can set itself as observer of parser class
       
    91         * @param aProgressNote Note for showing the progress of the parsing operation
       
    92 		* @return newly instantiated object
       
    93 		*/
       
    94 
       
    95 		IMPORT_C static CLmkParser* NewL(RFile& aFile,
       
    96                                           CPosLandmarkDatabase& aDb,
       
    97                                           MLmkAOOperationObserver& aObserver,
       
    98                                           TBool aProgressNote );
       
    99 
       
   100 		/**
       
   101 		* Destructor.
       
   102 		*/
       
   103 		~CLmkParser();
       
   104 
       
   105     protected: //from MLmkAOOperationObserver
       
   106         void HandleOperationL( TOperationTypes aType,
       
   107                                TReal32 aProgress,
       
   108                                TInt aStatus );
       
   109 
       
   110     public: // New functions
       
   111         /**
       
   112         * Gets the name of the file to be parsed.
       
   113         * @return descriptor containing filename
       
   114         */
       
   115         IMPORT_C TPtrC FileName();
       
   116 
       
   117         /**
       
   118         * Gets the handle to file which needs to be parsed.
       
   119         * @return reference to file handle
       
   120         */
       
   121         IMPORT_C RFile& FileHandle();
       
   122 
       
   123 		/**
       
   124         * Check if the handle to file which needs parsing exists or not
       
   125         * @return reference to file handle
       
   126         */
       
   127         IMPORT_C TBool IsFileHandle();
       
   128 
       
   129         /**
       
   130         * Initializes the landmark database which is already open.
       
   131         * This is an Asynchronous method
       
   132         * The client of this class should call this method before calling other methods.
       
   133         */
       
   134         IMPORT_C void InitializeDbL();
       
   135 
       
   136         /**
       
   137         * This method initiates the landmark parsing operation
       
   138         * This is an Asynchronous method.
       
   139         */
       
   140         IMPORT_C void StartParsingL();
       
   141 
       
   142         /**
       
   143         * This method provides the number of latest parsed landmarks from
       
   144         * the landmark package.
       
   145         * @return number of parsed landmarks
       
   146         */
       
   147         IMPORT_C TInt NumOfParsedLandmarks();
       
   148 
       
   149         /**
       
   150         * Returns the name of the package using collection data information.
       
   151         * Contains empty descriptor if name does not exist.
       
   152         * @return Package name
       
   153         */
       
   154         IMPORT_C TPtrC PackageName();
       
   155 
       
   156         /**
       
   157         * Get Landmark at the specified position
       
   158         * @param aIndex Position of Landmark in the package
       
   159         * @return CPosLandmark
       
   160         */
       
   161         IMPORT_C CPosLandmark* LandmarkLC( TInt aIndex );
       
   162 
       
   163         /**
       
   164         * Get Landmark packaged in CLmkLandmark at the specified position
       
   165         * @param aIndex Position of Landmark in the package
       
   166         * @return CLmkLandmark
       
   167         */
       
   168         IMPORT_C CLmkLandmark* LmkLandmarkLC( TInt aIndex );
       
   169 
       
   170         /**
       
   171         * Get CategoriesNames at the specified position
       
   172         * @param aIndex
       
   173         * @return CLmkLandMarkCategoriesName
       
   174         */
       
   175 		IMPORT_C CLmkLandMarkCategoriesName* CategoryNameLC( TInt aIndex );
       
   176         /* Change observer of asynchronous operations
       
   177         * @param aNewObserver Observer which need to be changed
       
   178         */
       
   179         IMPORT_C void ChangeObserver( MLmkAOOperationObserver& aNewObserver );
       
   180 
       
   181 	/**
       
   182         * Start importing all landmarks in the package to database
       
   183         */
       
   184         IMPORT_C void StartImportingL(TBool aIncludeNewCategories);
       
   185 
       
   186         /**
       
   187         * Start importing selected landmarks to database
       
   188         * This is an asynchronous operation
       
   189         * @param aSelected Array containing the landmarks in the landmarks package
       
   190         */
       
   191         IMPORT_C void StartImportingL( const RArray<TUint>& aSelected, TBool aIncludeNewCategories );
       
   192 
       
   193         /**
       
   194         * Cancel importing of landmarks to database
       
   195         */
       
   196         IMPORT_C void CancelImporting();
       
   197 
       
   198     private:  // New functions
       
   199         /**
       
   200         * This method checks if Active Object operation is already ongoing or not
       
   201         * This is useful when a new Active Object operation is started
       
   202         */
       
   203         void LeaveIfInUseL();
       
   204 
       
   205         /*
       
   206         * This function resolves the MIME Type from the list present in the
       
   207         * resource file
       
   208         */
       
   209         TInt ResolveMimeTypeL( RFile& aFile, TDataType& aDataType ) const;
       
   210 
       
   211     private:  // Constructors and destructor
       
   212         /**
       
   213         * C++ default constructor.
       
   214         */
       
   215         CLmkParser( CPosLandmarkDatabase& aDb,
       
   216                     MLmkAOOperationObserver& aObserver,
       
   217                     TBool aProgressNote );
       
   218 
       
   219         /**
       
   220 		* By default Symbian 2nd phase constructor is private.
       
   221 		* @param aFile Full file path
       
   222 		*/
       
   223         void ConstructL( const TDesC& aFile );
       
   224 
       
   225         /**
       
   226 		* By default Symbian 2nd phase constructor is private.
       
   227 		* @param aFile File handle
       
   228 		*/
       
   229         void ConstructL(RFile& aFile  );
       
   230 
       
   231     private:    // Data
       
   232         ///Ref:
       
   233         CPosLandmarkDatabase& iDb;
       
   234 
       
   235         ///Ref:
       
   236         MLmkAOOperationObserver* iObserver;
       
   237 
       
   238         TBool iProgressNote;
       
   239 
       
   240         ///Own: EPos parser
       
   241         CPosLandmarkParser* iParser;
       
   242 
       
   243         // remove the wrapper when CPosLandmarkParser supports indexing:
       
   244         CLmkParseAllWrapper* iParseWrapper;
       
   245 
       
   246         ///Own:
       
   247         CLmkAOOperation* iAOOperation;
       
   248 
       
   249         ///Own:
       
   250         CLmkDbUtils* iDbUtils;
       
   251 
       
   252         /// Own: full name of the parsed file
       
   253         HBufC* iFileName;
       
   254 
       
   255         // Added for passing FileHandle
       
   256 
       
   257         RFile* iFileHandle;
       
   258 
       
   259         TBool iFileHandleFlag;
       
   260     };
       
   261 
       
   262 #endif      // CLMKPARSER_H
       
   263 
       
   264 // End of File