ncdengine/provider/server/inc/ncdnodedownloadimpl.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:   Contains CNcdNodeDownload class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_DOWNLOAD_H
       
    20 #define NCD_NODE_DOWNLOAD_H
       
    21 
       
    22 
       
    23 // For streams
       
    24 #include <s32mem.h>
       
    25 #include <badesca.h>
       
    26 
       
    27 #include "catalogscommunicable.h"
       
    28 #include "ncdnodeclassids.h"
       
    29 
       
    30 
       
    31 class MNcdPreminetProtocolDataEntity;
       
    32 class MNcdPurchaseDetails;
       
    33 class MNcdPurchaseDownloadInfo;
       
    34 
       
    35 
       
    36 /**
       
    37  *  CNcdNodeDownload does not handle db information directly. The information
       
    38  *  is Internalized from the purchase history data and also the data is saved
       
    39  *  to the purchase history when the purchase operation progresses.
       
    40  *
       
    41  *  This server side class contains the data and the functionality
       
    42  *  that the proxy objects will use to internalize itself.
       
    43  *
       
    44  *  This object should be added to the session. So, it will be usable
       
    45  *  in the proxy side by using the handle gotten during addition. 
       
    46  *  The handle is used to identify to what object the proxy directs 
       
    47  *  the function call.  When objects are added to sessions, 
       
    48  *  multiple handles may be gotten for the same object if addition is 
       
    49  *  done multiple times.
       
    50  *
       
    51  *  @lib ?library
       
    52  *  @since S60 v3.2
       
    53  */
       
    54 class CNcdNodeDownload : public CCatalogsCommunicable
       
    55     {
       
    56 
       
    57 public:
       
    58     /**
       
    59      * NewL
       
    60      *
       
    61      * @return CNcdNodeDownload* Pointer to the created object 
       
    62      * of this class.
       
    63      */
       
    64     static CNcdNodeDownload* NewL();
       
    65 
       
    66     /**
       
    67      * NewLC
       
    68      *
       
    69      * @return CNcdNodeDownload* Pointer to the created object 
       
    70      * of this class.
       
    71      */
       
    72     static CNcdNodeDownload* NewLC();
       
    73 
       
    74 
       
    75     /**
       
    76      * Destructor
       
    77      *
       
    78      * @note Because this is CCatalogsCommunicable function the
       
    79      * session that owns this object should delete this class object.
       
    80      * So, instead of directly deleting this object from some other
       
    81      * class. Close-method should be used instead.
       
    82      */
       
    83     virtual ~CNcdNodeDownload();
       
    84 
       
    85 
       
    86     /**
       
    87      * Retrieves the data type that informs what class the data is for.
       
    88      * By checking the data type information, an InternalizeL function
       
    89      * of a right class can be called when the object data is set
       
    90      * from the storage.
       
    91      * The data type may be decided and set in a object that creates this 
       
    92      * class object.
       
    93      *
       
    94      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
    95      */
       
    96     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
    97 
       
    98 
       
    99     /**
       
   100      * This function is called when the owner of this object
       
   101      * wants to internalize the content according to the data
       
   102      * that has been received from the purchase history.
       
   103      * 
       
   104      * @param aDetails Purchase details from purchase history.
       
   105      * @return ETrue if purchase details contained download
       
   106      * data to internalize.
       
   107      */
       
   108     TBool InternalizeL( const MNcdPurchaseDetails& aDetails );
       
   109     
       
   110     /**
       
   111      * Get download information.
       
   112      *
       
   113      * @return Download information.
       
   114      */
       
   115     const RPointerArray< MNcdPurchaseDownloadInfo >& DownloadInfo() const;
       
   116           
       
   117     
       
   118 public: // CCatalogsCommunicable
       
   119 
       
   120     /**
       
   121      * @see CCatalogsCommunicable::ReceiveMessage
       
   122      */
       
   123     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   124                                  TInt aFunctionNumber );
       
   125 
       
   126     /**
       
   127      * @see CCatalogsCommunicable::CounterPartLost
       
   128      */
       
   129     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   130 
       
   131 
       
   132 protected:
       
   133 
       
   134     /**
       
   135      * Constructor
       
   136      * @param aClassId Identifies this class. 
       
   137      * Is set in the NewLC function 
       
   138      */
       
   139     CNcdNodeDownload( NcdNodeClassIds::TNcdNodeClassId aClassId );
       
   140 
       
   141     /**
       
   142      * ConstructL
       
   143      */
       
   144     virtual void ConstructL();
       
   145     
       
   146 
       
   147     // These functions are called from the ReceiveMessage when
       
   148     // the given function id has matched to the function.
       
   149 
       
   150     /**
       
   151      * This function is called when the proxy wants to get the
       
   152      * data from the serverside. This function calls the
       
   153      * InternalizeDataForRequestL which may be overloaded in the
       
   154      * child classes
       
   155      * @param aMessage Contains data from the proxy and can be used
       
   156      * to send data back to proxy
       
   157      */
       
   158     void InternalizeRequestL( MCatalogsBaseMessage& aMessage );
       
   159         
       
   160     /**
       
   161      * This function writes the object data to the stream. 
       
   162      * The stream content will be sent to the proxy that requested the data.
       
   163      * Child classes should add their own data after this parent data.
       
   164      * @param aStream The data content of this class object will be written
       
   165      * into this stream.
       
   166      */
       
   167     virtual void ExternalizeDataForRequestL( RWriteStream& aStream );
       
   168 
       
   169     /**
       
   170      * This function is called from the proxy side. When the proxy
       
   171      * is deleted.
       
   172      * @param aMessage Contains data from the proxy and can be used
       
   173      * to send data back to proxy
       
   174      */
       
   175     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   176 
       
   177 
       
   178     void FilesExistRequestL( MCatalogsBaseMessage& aMessage );
       
   179     
       
   180     /**
       
   181      * Checks that all downloaded files actually exist in the file system
       
   182      */
       
   183     TBool FilesExist();
       
   184 
       
   185 private:
       
   186 
       
   187     // Prevent these two if they are not implemented
       
   188     CNcdNodeDownload( const CNcdNodeDownload& aObject );
       
   189     CNcdNodeDownload& operator =( const CNcdNodeDownload& aObject );
       
   190 
       
   191 
       
   192 private: // data
       
   193     
       
   194     // The class id identifies this class. The id may be used to identify
       
   195     // what kind of class object is created when data is gotten from the db.
       
   196     NcdNodeClassIds::TNcdNodeClassId iClassId;
       
   197     
       
   198     // Download info array.
       
   199     RPointerArray< MNcdPurchaseDownloadInfo > iDownloadInfo;
       
   200     
       
   201     CDesCArrayFlat* iFiles;
       
   202     
       
   203     // Indicates download status.
       
   204     TBool iIsDownloaded;
       
   205 
       
   206     // The message is set when ReceiveMessage is called. The message
       
   207     // is used in the CounterPartLost-function that informs the message
       
   208     // if the session has been lost.
       
   209     MCatalogsBaseMessage* iMessage;
       
   210     };
       
   211     
       
   212 #endif // NCD_NODE_DOWNLOAD_H