browserutilities/feedsengine/FeedsServer/Server/inc/ImportFeedsTask.h
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 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 the License "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 task to import Feeds from an OPML file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IMPORT_FEEDS_TASK_H
       
    20 #define IMPORT_FEEDS_TASK_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 #include "Task.h"
       
    28 #include "PackedFolder.h"
       
    29 #include "PackedAttributes.h"
       
    30 #include "FeedsDatabase.h"
       
    31 #include "FolderAttributes.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // DATA TYPES
       
    38 
       
    39 // FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CIdle;
       
    43 class RFile;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 
       
    48 /**
       
    49 *  The ImportFeedsTask's observer.
       
    50 *
       
    51 *  \b Library: FeedsEngine.lib
       
    52 *
       
    53 *  @since 3.2
       
    54 */
       
    55 class MImportFeedsTaskObserver
       
    56     {
       
    57     public: 
       
    58         /**
       
    59         * Notifies the observer that the task is about to start a lengthy 
       
    60         * operation.  In response the observer could display somekind of 
       
    61         * status indicator.
       
    62         *
       
    63         * @since 3.2
       
    64         * @return void.
       
    65         */
       
    66         virtual void StartImportWait() = 0;
       
    67 
       
    68         /**
       
    69         * Called upon completion of the task.
       
    70         *
       
    71         * @since 3.2
       
    72         * @param aStatusCode The completion status of the request.
       
    73         * @return Void
       
    74         */
       
    75         virtual void ImportCompleted(TInt aStatusCode) = 0;
       
    76     };
       
    77 
       
    78 
       
    79 enum TImportFeedsTaskStates
       
    80     {
       
    81     EImportOpenOPMLFile,
       
    82     EImportPreparePackedFolder,
       
    83     EImportIntoDB,
       
    84     EImportDone
       
    85     };
       
    86     
       
    87 
       
    88 /**
       
    89 *  A task to import Feeds.
       
    90 *
       
    91 *  \b Library: FeedsEngine.lib
       
    92 *
       
    93 *  @since 3.2
       
    94 */
       
    95 class CImportFeedsTask: public CTask
       
    96     {
       
    97     public:  // Constructors and destructor
       
    98         /**
       
    99         * Two-phased constructor.
       
   100         */
       
   101         static CImportFeedsTask* NewL(CFeedsServer& aFeedsServer, MImportFeedsTaskObserver& aObserver, const RMessage2& aMessage);
       
   102 
       
   103         /**
       
   104         * Destructor.
       
   105         */        
       
   106         virtual ~CImportFeedsTask();
       
   107         
       
   108     public:  // From CTask
       
   109         /**
       
   110         * Starts the task.
       
   111         *
       
   112         * @since 3.2
       
   113         * @return Void
       
   114         */
       
   115         virtual void StartTaskL();
       
   116         
       
   117 
       
   118     private:
       
   119         /**
       
   120         * C++ default constructor.
       
   121         */
       
   122         CImportFeedsTask(CFeedsServer& aFeedsServer, MImportFeedsTaskObserver& aObserver, const RMessage2& aMessage);
       
   123         
       
   124         /**
       
   125         * By default Symbian 2nd phase constructor is private.
       
   126         */
       
   127         void ConstructL();
       
   128 
       
   129 	private:
       
   130 	
       
   131         /**
       
   132         * Callback function for CIdle task
       
   133         *
       
   134         * @since 3.2
       
   135         * @param aPtr The this pointer.
       
   136         * @return TBool - ETrue if callback has to be called again, EFalse if nomore calls has to be made
       
   137         */        
       
   138         static TBool StartImportStateMachine(TAny *aPtr);
       
   139 	
       
   140         /**
       
   141         * Opens the OPML file name
       
   142         *
       
   143         * @since 3.2
       
   144         * @return Void.
       
   145         */	
       
   146         void OpenOPMLFileL();
       
   147 
       
   148         /**
       
   149         * Creates the packed folder by parsing the OPML file
       
   150         *
       
   151         * @since 3.2
       
   152         * @return Void.
       
   153         */	
       
   154 		void PreparePackedFolderL();
       
   155 		
       
   156         /**
       
   157         * Starts importing the packed folder into DB
       
   158         *
       
   159         * @since 3.2
       
   160         * @return Void.
       
   161         */	
       
   162 		void ImportIntoDBL();
       
   163 		
       
   164         /**
       
   165         * Import the packed folder into DB
       
   166         *
       
   167         * @since 3.2
       
   168         * @return Void.
       
   169         */	
       
   170 		void ImportFoldersL();
       
   171 
       
   172         /**
       
   173         * Cancel the ongoing OPML import task
       
   174         *
       
   175         * @since 3.2
       
   176         * @return Void.
       
   177         */	
       
   178 		void CleanupImportTaskL();
       
   179 
       
   180         /**
       
   181         * Callback function for import task completion
       
   182         *
       
   183         * @since 3.2
       
   184         * @param aPtr The this pointer.
       
   185         * @return Void.
       
   186         */	
       
   187 		static void ReleaseImportTablesCallback(TAny *ptr);
       
   188 		
       
   189         /**
       
   190         * Closes all the OPML import related tables
       
   191         *
       
   192         * @since 3.2
       
   193         * @return Void.
       
   194         */	
       
   195 		void ReleaseImportTables();
       
   196 
       
   197     private:
       
   198 
       
   199    		TInt						iImportState;
       
   200    		MImportFeedsTaskObserver&	iObserver;
       
   201 		const RMessage2& 			iMessage;
       
   202         CIdle*						iIdle;
       
   203         TBool						iMoreToAdd;
       
   204 
       
   205 		TInt						iFolderListId;
       
   206 		TBool						iClearFolderList;
       
   207 
       
   208 		RFs 						iRFs;
       
   209 		RFile						iImportFile;
       
   210 
       
   211 		HBufC*						iFullImportFileName;
       
   212 		TFileName					iDispImportFileName;
       
   213 
       
   214 		CPackedFolder*				iPackedFolder;
       
   215 		CFeedsDatabase*				iFeedsDatabase;
       
   216 		
       
   217 		TBool						iDBTransactInited;
       
   218 		
       
   219 	    RArray<TInt>        		iParentStack;
       
   220 	    RArray<TInt>        		iSiblingIndexStack;
       
   221 		
       
   222 		TBool						iFoundRootFolder;
       
   223 		
       
   224 		RArray<TInt>				iFolderItemIds;
       
   225 		RArray<TInt>				iFeedIds;
       
   226 		
       
   227 		
       
   228 	private:
       
   229 	
       
   230 		friend class CFeedsServerSession;		
       
   231         
       
   232     };
       
   233     
       
   234 #endif      // IMPORT_FEEDS_TASK_H
       
   235             
       
   236 // End of File