ncdengine/provider/server/inc/ncdloadbundlenodeoperationimpl.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDLOADBUNDLENODEOPERATIONIMPL_H
       
    20 #define C_NCDLOADBUNDLENODEOPERATIONIMPL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <badesca.h>
       
    24 #include "ncdbaseoperation.h"
       
    25 #include "ncdconfigurationobserver.h"
       
    26 
       
    27 class MCatalogsAccessPointManager;
       
    28 class MNcdProtocol;
       
    29 class MNcdConfigurationManager;
       
    30 class CNcdContentSource;
       
    31 class CNcdNodeIdentifier;
       
    32 class CNcdLoadNodeOperationImpl;
       
    33 class CNcdContentSourceMap;
       
    34 class CNcdChildEntityMap;
       
    35 class MNcdOperationQueue;
       
    36 class CNcdNodeMetaData;
       
    37 
       
    38 /**
       
    39  *  Load node operation implementation.
       
    40  *
       
    41  *  Handles the "loading of root node" i.e. creates
       
    42  *  a root node from a conf protocol response.
       
    43  *
       
    44  *  @lib ?library
       
    45  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    46  */
       
    47 class CNcdLoadBundleNodeOperation : public CNcdBaseOperation,
       
    48                                     public MNcdParserObserver,
       
    49                                     public MCatalogsHttpObserver,
       
    50                                     public MNcdParserConfigurationProtocolObserver,
       
    51                                     public MNcdConfigurationObserver
       
    52     {
       
    53     
       
    54 public:
       
    55 
       
    56     /** Sub states of bundle node operation */
       
    57     enum TBundleNodeState
       
    58         {
       
    59         EConfRequest,      // create and send a conf request
       
    60         EReceiveConf,      // receive and parse conf data
       
    61         EConfQuery,        // respond to conf query
       
    62         EBrowseRequest,    // create sub-operations 
       
    63         EReceiveBrowse,    // wait for sub-operations to complete
       
    64         EComplete,         // everything done
       
    65         EFailed            // operation failed
       
    66         };
       
    67     
       
    68     
       
    69     static CNcdLoadBundleNodeOperation* NewL(
       
    70         const CNcdNodeIdentifier& aNodeIdentifier,
       
    71         CNcdGeneralManager& aGeneralManager,
       
    72         MCatalogsHttpSession& aHttpSession,
       
    73         MNcdOperationRemoveHandler* aRemoveHandler,
       
    74         MNcdOperationQueue& aOperationQueue,
       
    75         MCatalogsSession& aSession );
       
    76 
       
    77     static CNcdLoadBundleNodeOperation* NewLC(
       
    78         const CNcdNodeIdentifier& aNodeIdentifier,
       
    79         CNcdGeneralManager& aGeneralManager,
       
    80         MCatalogsHttpSession& aHttpSession,
       
    81         MNcdOperationRemoveHandler* aRemoveHandler,
       
    82         MNcdOperationQueue& aOperationQueue,
       
    83         MCatalogsSession& aSession );
       
    84 
       
    85     virtual ~CNcdLoadBundleNodeOperation();
       
    86     
       
    87     /**
       
    88      * Returns the identifier of the parent node this operation is loading.
       
    89      *
       
    90      * @return Identifier of the parent node.
       
    91      */
       
    92     const CNcdNodeIdentifier& NodeIdentifier() const;
       
    93 
       
    94     
       
    95 public: //from CNcdBaseOperation
       
    96 
       
    97     /**
       
    98      * Starts the operation.
       
    99      */
       
   100     virtual TInt Start();
       
   101 
       
   102     /**
       
   103      * @see CNcdBaseOperation::Cancel
       
   104      */
       
   105     virtual void Cancel();
       
   106     
       
   107     /**
       
   108      * @see CNcdBaseOperation::HandleCancelMessage
       
   109      */
       
   110     virtual void HandleCancelMessage( MCatalogsBaseMessage* aMessage );
       
   111 
       
   112     /**
       
   113      * @see CNcdBaseOperation::CompleteMessage         
       
   114      */
       
   115     virtual TInt CompleteMessage( MCatalogsBaseMessage* & aMessage,
       
   116         TNcdOperationMessageCompletionId aId,
       
   117         const MNcdSendable& aSendableObject,
       
   118         TInt aStatus );
       
   119         
       
   120     /**
       
   121      * @see CNcdBaseOperation::CompleteMessage         
       
   122      */
       
   123     virtual TInt CompleteMessage( MCatalogsBaseMessage* & aMessage,
       
   124         TNcdOperationMessageCompletionId aId,
       
   125         TInt aStatus );
       
   126         
       
   127     /**
       
   128      * @see CNcdBaseOperation::CompleteMessage         
       
   129      */
       
   130     virtual TInt CompleteMessage( MCatalogsBaseMessage*& aMessage,
       
   131         TNcdOperationMessageCompletionId aId,
       
   132         const MNcdSendable& aSendableObject,
       
   133         RPointerArray<CNcdNodeIdentifier>& aNodes,
       
   134         TInt aStatus );
       
   135         
       
   136     /**
       
   137      * @see CNcdBaseOperation::CompleteMessage         
       
   138      */
       
   139     virtual TInt CompleteMessage( MCatalogsBaseMessage*& aMessage,
       
   140         TNcdOperationMessageCompletionId aId,
       
   141         RPointerArray<CNcdExpiredNode>& aExpiredNodes,
       
   142         TInt aStatus );
       
   143     
       
   144     
       
   145 public: // from MCatalogsHttpObserver
       
   146 
       
   147     /**     
       
   148      * @see MCatalogsHttpObserver::HandleHttpEventL
       
   149      */
       
   150     virtual void HandleHttpEventL( 
       
   151         MCatalogsHttpOperation& aOperation, 
       
   152         TCatalogsHttpEvent aEvent );
       
   153         
       
   154     /**
       
   155      * @see MCatalogsHttpObserver::HandleHttpError()
       
   156      */
       
   157     TBool HandleHttpError(
       
   158         MCatalogsHttpOperation& aOperation,
       
   159         TCatalogsHttpError aError );
       
   160         
       
   161 public: //from MNcdParserObserver
       
   162 
       
   163     /**
       
   164      * @see MNcdParserObserver
       
   165      */
       
   166     virtual void ParseError( TInt aErrorCode );
       
   167 
       
   168     /**
       
   169      * @see MNcdParserObserver
       
   170      */
       
   171     virtual void ParseCompleteL( TInt aError );
       
   172     
       
   173 public: // from MNcdParserConfigurationProtocolObserver
       
   174 
       
   175     virtual void ConfigurationBeginL( const TDesC& aVersion, 
       
   176                                       TInt aExpirationDelta );
       
   177     virtual void ConfigurationQueryL( MNcdConfigurationProtocolQuery* aQuery );
       
   178 
       
   179     virtual void ClientConfigurationL(
       
   180         MNcdConfigurationProtocolClientConfiguration* aConfiguration );
       
   181     virtual void ConfigurationDetailsL( 
       
   182         CArrayPtr<MNcdConfigurationProtocolDetail>* aDetails );
       
   183     virtual void ConfigurationActionRequestL(
       
   184         MNcdConfigurationProtocolActionRequest* aActionRequest );
       
   185     virtual void ConfigurationErrorL( MNcdConfigurationProtocolError* aError );
       
   186     virtual void ConfigurationServerDetailsL( MNcdConfigurationProtocolServerDetails* aServerDetails );
       
   187     virtual void ConfigurationEndL();
       
   188 
       
   189 public: // from MNcdOperationObserver
       
   190     
       
   191     /**
       
   192      * @see MNcdOperationObserver
       
   193      */
       
   194     virtual void Progress( CNcdBaseOperation& aOperation );
       
   195     
       
   196     /**
       
   197      * @see MNcdOperationObserver
       
   198      */
       
   199     virtual void QueryReceived( CNcdBaseOperation& aOperation,
       
   200                                  CNcdQuery* aQuery );
       
   201 
       
   202     /**
       
   203      * @see MNcdOperationObserver
       
   204      */
       
   205     virtual void OperationComplete( CNcdBaseOperation* aOperation,
       
   206                                     TInt aError );
       
   207                                     
       
   208 public: // from MNcdConfigurationObserver
       
   209 
       
   210     virtual void ConfigurationChangedL();                                   
       
   211                                     
       
   212 public: // from CCatalogsCommunicable
       
   213     
       
   214     /**
       
   215      * @see CCatalogsCommunicable
       
   216      */
       
   217     virtual void ReceiveMessage( 
       
   218         MCatalogsBaseMessage* aMessage,
       
   219         TInt aFunctionNumber );
       
   220         
       
   221 public: // from MNcdParserErrorObserver
       
   222 
       
   223     virtual void ErrorL( MNcdPreminetProtocolError* aData );
       
   224                                     
       
   225 
       
   226 protected:
       
   227 
       
   228     CNcdLoadBundleNodeOperation(
       
   229         CNcdGeneralManager& aGeneralManager,
       
   230         MCatalogsHttpSession& aHttpSession,
       
   231         MNcdOperationRemoveHandler* aRemoveHandler,
       
   232         MNcdOperationQueue& aOperationQueue,
       
   233         MCatalogsSession& aSession );
       
   234     
       
   235     void ConstructL( const CNcdNodeIdentifier& aNodeIdentifier );
       
   236     
       
   237     HBufC8* CreateConfRequestLC( CNcdQuery* aQuery = NULL );
       
   238 
       
   239     /**
       
   240      * Reverts the nodes which could not be retrieved due to broken content
       
   241      * source from NodeManager's temp cache to main RAM cache.
       
   242      */
       
   243     void RevertNodesOfBrokenSourcesToCacheL();
       
   244     
       
   245     /**
       
   246      * Reverts the given node belonging to given content source from
       
   247      * NodeManager's temp cache to the main cache.
       
   248      */
       
   249     void RevertNodeL(
       
   250         const CNcdNodeIdentifier& aNodeIdentifier,
       
   251         const CNcdContentSource& aContentSource );
       
   252     /**
       
   253      * Removes the nodes that were removed from content sources.
       
   254      */
       
   255     void RemoveOldNodesL();
       
   256     
       
   257     /**
       
   258      * Adds the bundle node identifier to iLoadedNodes.
       
   259      */
       
   260     void AddBundleToLoadedNodesL();
       
   261     
       
   262     /**
       
   263      * Updates the root node's content source map according to the new
       
   264      * content sources of the loaded bundle.
       
   265      */
       
   266     void UpdateCsMapToRootNodeL();
       
   267     
       
   268     /**
       
   269      * Sets always visible flags to the metadata of the nodes that belong to
       
   270      * content sources defined as always visible in client configuration.
       
   271      */
       
   272     void SetAlwaysVisibleFlagsL();
       
   273     
       
   274     void ParseCatalogBundleL( const MNcdConfigurationProtocolDetail& aDetail );
       
   275     
       
   276     /**
       
   277      * Notifies the operation manager about completion of a queued operation,
       
   278      * if the given completion id indicates that the operation is really completed.
       
   279      *
       
   280      * @param aId The completion id.
       
   281      */
       
   282     void NotifyCompletionOfQueuedOperation( TNcdOperationMessageCompletionId aId );    
       
   283     
       
   284     static TBool ContainsNode(
       
   285         const RPointerArray<CNcdNodeIdentifier>& aNodes,
       
   286         const CNcdNodeIdentifier& aNode);
       
   287     
       
   288     void HandleBundleDisclaimerL(
       
   289         CNcdNodeMetaData& aMetadata, 
       
   290         const TDesC& aDisclaimer );
       
   291     
       
   292 
       
   293 protected:
       
   294 
       
   295     void HandleConfigurationDataRequestMessage( MCatalogsBaseMessage& aMessage );
       
   296     
       
   297     
       
   298 protected: // from CNcdBaseOperation
       
   299 
       
   300     /**
       
   301      * @see CNcdBaseOperation::RunOperation
       
   302      */
       
   303     virtual TInt RunOperation();
       
   304     
       
   305     void DoRunOperationL();
       
   306     
       
   307     /**
       
   308      * @see CNcdBaseOperation::RunOperation
       
   309      */
       
   310     virtual void ChangeToPreviousStateL();
       
   311     
       
   312     virtual TBool QueryCompletedL( CNcdQuery* aQuery );
       
   313     
       
   314 private: // type declarations
       
   315     
       
   316     /** Sub states of master server redirection process */
       
   317     enum TMasterServerRedirectionState 
       
   318         {
       
   319         EBegin, // Start state.
       
   320         ERedirecting, // Redirecting.
       
   321         EReverted // Returned to use previous master server address.
       
   322         };
       
   323 
       
   324 private: // data
       
   325     /**
       
   326      * A sub-state of this operation's execution.
       
   327      */
       
   328     TBundleNodeState iBundleNodeState;
       
   329     
       
   330     /**
       
   331      * A sub-state of master server redirection.
       
   332      */
       
   333     TMasterServerRedirectionState iMasterServerRedirectionState;
       
   334     
       
   335     /**
       
   336      * Nodes that have been loaded. This is used to store loaded
       
   337      * nodes identifiers before they can be sent to the proxy in a message.
       
   338      */
       
   339     RPointerArray<CNcdNodeIdentifier> iLoadedNodes;
       
   340         
       
   341     /**
       
   342      * This flag is set to indicate that progress info should be sent
       
   343      * when the next message is received.
       
   344      */
       
   345     TBool iSendProgress;    
       
   346         
       
   347     /**
       
   348      * Access point manager for creating access points.
       
   349      */
       
   350     MCatalogsAccessPointManager& iAccessPointManager;
       
   351     
       
   352 
       
   353     /**
       
   354      * Http session for sending requests and receiving responses.
       
   355      * Not own.
       
   356      */
       
   357     MCatalogsHttpSession& iHttpSession;
       
   358 
       
   359     MNcdProtocol& iProtocol;
       
   360     
       
   361     /**
       
   362      * Configuration manager for getting the Master Server Address
       
   363      */
       
   364     MNcdConfigurationManager& iConfigManager;
       
   365         
       
   366     /**
       
   367      * Http operation for current transaction.
       
   368      * Not own.
       
   369      */
       
   370     MCatalogsHttpOperation* iTransaction;
       
   371         
       
   372     /**
       
   373      * Sub-operations for browse requests.
       
   374      */
       
   375     RPointerArray<CNcdLoadNodeOperationImpl> iSubOps;
       
   376     RPointerArray<CNcdLoadNodeOperationImpl> iFailedSubOps;
       
   377     RPointerArray<CNcdLoadNodeOperationImpl> iCompletedSubOps;
       
   378         
       
   379     /**
       
   380      * Content sources are stored here.
       
   381      */
       
   382     CNcdContentSourceMap* iContentSourceMap;
       
   383     
       
   384     /**
       
   385      * Identifier of the bundle node.
       
   386      */
       
   387     CNcdNodeIdentifier* iNodeIdentifier;
       
   388     
       
   389     CNcdQuery* iConfQuery;
       
   390     RPointerArray<CNcdQuery> iSubOpQuerys;
       
   391        
       
   392     MNcdParserConfigurationProtocolObserver*	iDefaultConfigurationProtocolObserver;
       
   393     
       
   394     HBufC* iServerUri;
       
   395     
       
   396     CBufFlat* iConfigResponseBuf;
       
   397         
       
   398     TBool iNodeDbLocked;
       
   399         
       
   400     /**
       
   401      * Maps of current children and their children for new checking.
       
   402      */
       
   403     RPointerArray<CNcdChildEntityMap> iChildEntityMaps;
       
   404     
       
   405     MNcdOperationQueue& iOperationQueue;
       
   406     
       
   407     TBool iFirstConfRequest;
       
   408 
       
   409     };
       
   410 
       
   411 #endif // C_NCDLOADBUNDLENODEOPERATIONIMPL_H