ncdengine/provider/server/inc/ncdnodepreviewimpl.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 CNcdNodePreview class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_PREVIEW_H
       
    20 #define NCD_NODE_PREVIEW_H
       
    21 
       
    22 
       
    23 // For streams
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include "ncdcommunicable.h"
       
    27 #include "ncdstoragedataitem.h"
       
    28 #include "ncdnodeclassids.h"
       
    29 
       
    30 
       
    31 class MNcdPreminetProtocolDataEntity;
       
    32 class CNcdNodeManager;
       
    33 class CNcdNodeMetaData;
       
    34 
       
    35 
       
    36 /**
       
    37  *  This server side class contains the data and the functionality
       
    38  *  that the proxy objects will use to internalize itself.
       
    39  *
       
    40  *  This object should be added to the session. So, it will be usable
       
    41  *  in the proxy side by using the handle gotten during addition. 
       
    42  *  The handle is used to identify to what object the proxy directs 
       
    43  *  the function call.  When objects are added to sessions, 
       
    44  *  multiple handles may be gotten for the same object if addition is 
       
    45  *  done multiple times.
       
    46  *
       
    47  *  @lib ?library
       
    48  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    49  */
       
    50 class CNcdNodePreview : public CNcdCommunicable,
       
    51                         public MNcdStorageDataItem
       
    52     {
       
    53 
       
    54 public:
       
    55     /**
       
    56      * NewL
       
    57      *
       
    58      * @return CNcdNodePreview* Pointer to the created object 
       
    59      * of this class.
       
    60      */
       
    61     static CNcdNodePreview* NewL( CNcdNodeMetaData& aParentMetaData,
       
    62                                   CNcdNodeManager& aNodeManager );
       
    63 
       
    64     /**
       
    65      * NewLC
       
    66      *
       
    67      * @return CNcdNodePreview* Pointer to the created object 
       
    68      * of this class.
       
    69      */
       
    70     static CNcdNodePreview* NewLC( CNcdNodeMetaData& aParentMetaData,
       
    71                                    CNcdNodeManager& aNodeManager );
       
    72 
       
    73 
       
    74     /**
       
    75      * Destructor
       
    76      *
       
    77      * @note Because this is CCatalogsCommunicable function the
       
    78      * session that owns this object should delete this class object.
       
    79      * So, instead of directly deleting this object from some other
       
    80      * class. Close-method should be used instead.
       
    81      */
       
    82     virtual ~CNcdNodePreview();
       
    83 
       
    84 
       
    85     /**
       
    86      * Retrieves the data type that informs what class the data is for.
       
    87      * By checking the data type information, an InternalizeL function
       
    88      * of a right class can be called when the object data is set
       
    89      * from the storage.
       
    90      * The data type may be decided and set in a object that creates this 
       
    91      * class object.
       
    92      *
       
    93      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
    94      */
       
    95     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
    96 
       
    97 
       
    98     /**
       
    99      * This function is called when the owner of this object
       
   100      * wants to internalize the content according to the data
       
   101      * that has been received from the parser.
       
   102      * 
       
   103      * @param aData The data is set in the protocol parser and can
       
   104      * be used to initialize this class object.
       
   105      */
       
   106     void InternalizeL( MNcdPreminetProtocolDataEntity& aData );
       
   107    
       
   108     /**
       
   109      * URI count getter
       
   110      *
       
   111      * @return Number of available preview URIs
       
   112      */
       
   113     TInt UriCount() const;
       
   114     
       
   115     /**
       
   116      * URI getter
       
   117      *
       
   118      * @param aIndex URI index
       
   119      * @return URI
       
   120      */
       
   121     const TDesC& Uri( TInt aIndex ) const;
       
   122     
       
   123     /**
       
   124      * Updates preview MIME types from preview manager in case
       
   125      * they were not received in protocol responses
       
   126      */
       
   127     void UpdateMimesFromPreviewManagerL();
       
   128     
       
   129     
       
   130 public: // MNcdStorageDataItem 
       
   131 
       
   132     // These functions are used to get the data from and to insert the data
       
   133     // into the database using by the given stream.
       
   134 
       
   135     /**
       
   136      * @see MNcdStorageDataItem::ExternalizeL
       
   137      */
       
   138     virtual void ExternalizeL( RWriteStream& aStream );
       
   139 
       
   140 
       
   141     /**
       
   142      * @see MNcdStorageDataItem::InternalizeL
       
   143      */
       
   144     virtual void InternalizeL( RReadStream& aStream );
       
   145 
       
   146 
       
   147 public: // CCatalogsCommunicable
       
   148 
       
   149     /**
       
   150      * @see CCatalogsCommunicable::ReceiveMessage
       
   151      */
       
   152     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   153                                  TInt aFunctionNumber );
       
   154 
       
   155     /**
       
   156      * @see CCatalogsCommunicable::CounterPartLost
       
   157      */
       
   158     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   159 
       
   160 
       
   161 protected:
       
   162 
       
   163     /**
       
   164      * Constructor
       
   165      * @param aClassId Identifies this class. 
       
   166      * Is set in the NewLC function 
       
   167      */
       
   168     CNcdNodePreview( NcdNodeClassIds::TNcdNodeClassId aClassId, 
       
   169                      CNcdNodeMetaData& aParentMetaData,
       
   170                      CNcdNodeManager& aNodeManager );
       
   171 
       
   172     /**
       
   173      * ConstructL
       
   174      */
       
   175     virtual void ConstructL();
       
   176     
       
   177 
       
   178     // These functions are called from the ReceiveMessage when
       
   179     // the given function id has matched to the function.
       
   180 
       
   181     /**
       
   182      * This function is called when the proxy wants to get the
       
   183      * data from the serverside. This function calls the
       
   184      * InternalizeDataForRequestL which may be overloaded in the
       
   185      * child classes
       
   186      * @param aMessage Contains data from the proxy and can be used
       
   187      * to send data back to proxy
       
   188      */
       
   189     void InternalizeRequestL( MCatalogsBaseMessage& aMessage );
       
   190         
       
   191     /**
       
   192      * This function writes the object data to the stream. 
       
   193      * The stream content will be sent to the proxy that requested the data.
       
   194      * Child classes should add their own data after this parent data.
       
   195      * @param aStream The data content of this class object will be written
       
   196      * into this stream.
       
   197      */
       
   198     virtual void ExternalizeDataForRequestL( RWriteStream& aStream );
       
   199 
       
   200     /**
       
   201      * This function is called from the proxy side. When the proxy
       
   202      * is deleted.
       
   203      * @param aMessage Contains data from the proxy and can be used
       
   204      * to send data back to proxy
       
   205      */
       
   206     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   207 
       
   208     /**
       
   209      * Opens a preview file
       
   210      * @param aMessage
       
   211      */
       
   212     void OpenPreviewFileL( MCatalogsBaseMessage& aMessage );
       
   213 
       
   214     /**
       
   215      * Checks if a preview has been loaded
       
   216      * @param aMessage
       
   217      */
       
   218     void IsPreviewLoadedL( MCatalogsBaseMessage& aMessage );
       
   219 
       
   220 private:
       
   221 
       
   222     // Prevent these two if they are not implemented
       
   223     CNcdNodePreview( const CNcdNodePreview& aObject );
       
   224     CNcdNodePreview& operator =( const CNcdNodePreview& aObject );
       
   225 
       
   226 
       
   227 private: // data
       
   228     
       
   229     // The class id identifies this class. The id may be used to identify
       
   230     // what kind of class object is created when data is gotten from the db.
       
   231     NcdNodeClassIds::TNcdNodeClassId iClassId;
       
   232     CNcdNodeMetaData& iParentMetaData;
       
   233     CNcdNodeManager& iNodeManager;
       
   234     
       
   235     // The message is set when ReceiveMessage is called. The message
       
   236     // is used in the CounterPartLost-function that informs the message
       
   237     // if the session has been lost.
       
   238     MCatalogsBaseMessage* iMessage;
       
   239     HBufC* iNameSpace;
       
   240     TInt iFileCount;
       
   241     RPointerArray<HBufC> iPreviewMimeTypes;
       
   242     RPointerArray<HBufC> iUris;
       
   243     };
       
   244     
       
   245 #endif // NCD_NODE_PREVIEW_H