ncdengine/provider/server/inc/ncdnodelink.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 CNcdNodeLink class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_LINK_H
       
    20 #define NCD_NODE_LINK_H
       
    21 
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <e32cmn.h>
       
    25 #include <s32mem.h>
       
    26 
       
    27 #include "catalogscommunicable.h"
       
    28 #include "ncdnodemanager.h"
       
    29 #include "ncdstorable.h"
       
    30 #include "ncdnodeclassids.h"
       
    31 #include "ncd_pp_entityref.h"
       
    32 
       
    33 class CNcdNodeIdentifier;
       
    34 class CNcdNode;
       
    35 
       
    36 
       
    37 /**
       
    38  *  CNcdNodeLink ...
       
    39  *  @lib ?library
       
    40  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    41  */
       
    42 class CNcdNodeLink : public CCatalogsCommunicable,
       
    43                      public MNcdStorable
       
    44     {
       
    45 
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Destructor
       
    50      */
       
    51     virtual ~CNcdNodeLink();
       
    52 
       
    53 
       
    54     /**
       
    55      * Retrieves the data type that informs what class the data is for.
       
    56      * By checking the data type information, an InternalizeL function
       
    57      * of a right class can be called when the object data is set
       
    58      * from the storage.
       
    59      * The data type may be decided and set in a factory that creates object.
       
    60      * The factory should know which integer is reserved for which class.
       
    61      *
       
    62      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
    63      */
       
    64     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
    65 
       
    66     
       
    67     /**
       
    68      * @see MNcdPreminetProtocolEntityRef::Timestamp
       
    69      */
       
    70     const TDesC& Timestamp() const;
       
    71 
       
    72     /**
       
    73      * @see MNcdPreminetProtocolEntityRef::ServerUri
       
    74      */
       
    75     const TDesC& ServerUri() const;
       
    76     
       
    77     /**
       
    78      * Setter for server uri.
       
    79      *
       
    80      * @param aServerUri Uri to set.
       
    81      */
       
    82     void SetServerUriL( const TDesC& aServerUri );
       
    83 
       
    84     /**
       
    85      * @see MNcdPreminetProtocolEntityRef::RemoteUri
       
    86      */
       
    87     const TDesC& RemoteUri() const;
       
    88 
       
    89     /**
       
    90      * @see MNcdPreminetProtocolEntityRef::Description
       
    91      */
       
    92     MNcdPreminetProtocolEntityRef::TDescription Description() const;
       
    93 
       
    94     /**
       
    95      * @see MNcdPreminetProtocolEntityRef::ValidUntilDelta
       
    96      */
       
    97     TInt ValidUntilDelta() const;
       
    98     
       
    99     /**
       
   100      * Setter for validity time, needed for setting root nodes
       
   101      * validity time. Also sets iLinkDownloadTime to current time.
       
   102      *
       
   103      * @param aValidUntilDelta Validity time.
       
   104      */
       
   105     void SetValidUntilDelta( TInt aValidUntilDelta );
       
   106 
       
   107     /**
       
   108      * @see MNcdPreminetProtocolEntityRef::ValidUntilAutoUpdate
       
   109      */
       
   110     TBool ValidUntilAutoUpdate() const;
       
   111 
       
   112     /**
       
   113      * @return CNcdNodeIdentifier contains parent identifier infromation.
       
   114      */
       
   115     const CNcdNodeIdentifier& ParentIdentifier() const;
       
   116     
       
   117     /**
       
   118      * Set the parent identifier.
       
   119      *
       
   120      * @note This setter function also sets the given identifier to the
       
   121      * request parent identifier variable. So, if the request parent identifier
       
   122      * should differ from the actual parent identifier, 
       
   123      * then the SetRequestParentIdentifierL function has to be called after
       
   124      * this function.
       
   125      *
       
   126      * @param aParentIdentifier The new parent identifier.
       
   127      */
       
   128     void SetParentIdentifierL( const CNcdNodeIdentifier& aParentIdentifier );
       
   129 
       
   130 
       
   131     /**
       
   132      * @note The parent identifier differs from the request parent identifier
       
   133      * if the parent is transparent. Then the proxy side should get the
       
   134      * grandparent info instead of the actual parent identifier.
       
   135      *
       
   136      * @return CNcdNodeIdentifier Parent identifier that is used when the
       
   137      * parent information is sent to the proxy side.
       
   138      */
       
   139     const CNcdNodeIdentifier& RequestParentIdentifier() const;
       
   140     
       
   141     /**
       
   142      * Set the request parent identifier.
       
   143      *
       
   144      * @param aRequestParentIdentifier The new parent identifier.
       
   145      */
       
   146     void SetRequestParentIdentifierL( 
       
   147         const CNcdNodeIdentifier& aRequestParentIdentifier );
       
   148 
       
   149 
       
   150     /**
       
   151      * @return TTIme Time when this link was downloaded.
       
   152      */
       
   153     TTime LinkDownloadTime() const;
       
   154 
       
   155     /**
       
   156      * @return TTime Expiration time. Sum of link download time and
       
   157      * valid until delta. Notice that valid until delta should give
       
   158      * the time value in minutes.
       
   159      */
       
   160     TTime ExpiredTime() const;
       
   161     
       
   162     /**
       
   163      * Checks whether this link is expired. 
       
   164      * @return ETrue if expired, EFalse if not.
       
   165      */
       
   166     TBool IsExpired() const;
       
   167 
       
   168     /**
       
   169      * Sets the catalogs source name for this nodelink.
       
   170      * The source name is set only for the root node childs.
       
   171      * @param aSourceName is the provider name that is gotten from the
       
   172      * cp response.
       
   173      */
       
   174     void SetCatalogsSourceNameL( const TDesC& aSourceName );
       
   175 
       
   176     /**
       
   177      * @return const TDesC& provider name that has been gotten from the 
       
   178      * cp response. This is only set for the root node childs. KNullDesC
       
   179      * if the value has not been set.
       
   180      */
       
   181     const TDesC& CatalogsSourceName() const;
       
   182 
       
   183     
       
   184     /**
       
   185      * @note The node may be a remote node if the parent gets remote uri information
       
   186      * for the strcuture data of its child. This child then has to be loaded from
       
   187      * the given remote uri. An example is a catalog. This function can be used
       
   188      * to set the flag that tells the original purpose of the node. For example, after
       
   189      * downloading a catalog it will act as a normal folder but the flag can be used
       
   190      * to inform its original purpose. 
       
   191      *
       
   192      * @param aRemote ETrue if the node is originally a remote node.
       
   193      * If the node is directly part of the structure then EFalse.
       
   194      */
       
   195     void SetRemoteFlag( TBool aRemoteFlag );
       
   196 
       
   197     /**
       
   198      * @return TBool ETrue if the node is originally a remote node.
       
   199      * If the node is directly part of the structure then EFalse.
       
   200      */
       
   201     TBool RemoteFlag() const;
       
   202 
       
   203 
       
   204     /**
       
   205      * Returns the identifier of the metadata that this link points to.
       
   206      * This should always be used when accessing metadata via a link.
       
   207      * 
       
   208      * @return const CNcdNodeIdentifier&
       
   209      */
       
   210     const CNcdNodeIdentifier& MetaDataIdentifier() const;
       
   211     
       
   212     /**
       
   213      * Sets the metadata identifier.
       
   214      *
       
   215      * @param aIdentifier The identifier of the metadata. Old one will be
       
   216      * replaced with this one.
       
   217      */
       
   218     void SetMetaDataIdentifierL( const CNcdNodeIdentifier& aIdentifier );
       
   219     
       
   220     
       
   221     /**
       
   222      * This function is called when the owner of this object
       
   223      * wants to internalize the content according to the data
       
   224      * that has been received from the parser.
       
   225      * 
       
   226      * @param aData The data is set in the protocol parser and can
       
   227      * be used to initialize this class object.
       
   228      * @param aParentIdentifier contains the parent information.
       
   229      * @param aRequestParentIdentifier Parent identifier that is used 
       
   230      * when the parent information is sent to the proxy side. Usually this
       
   231      * is most likely same as aParentIdentifier. But in case of transparent
       
   232      * nodes, aRequestParentIdentifier value should be the grandparent identifier
       
   233      * instead of the actual parent.
       
   234      */
       
   235     virtual void InternalizeL( const MNcdPreminetProtocolEntityRef& aData,
       
   236                                const CNcdNodeIdentifier& aParentIdentifier,
       
   237                                const CNcdNodeIdentifier& aRequestParentIdentifier,
       
   238                                const TUid& aClientUid );
       
   239 
       
   240 
       
   241     /**
       
   242      * Sets metadata's timestamp to link
       
   243      */
       
   244     void SetMetadataTimeStampL( const TDesC& aTimeStamp );
       
   245 
       
   246 public: // MNcdStorable
       
   247 
       
   248     /**
       
   249      * @see MNcdStorageDataItem::ExternalizeL
       
   250      */
       
   251     virtual void ExternalizeL( RWriteStream& aStream );
       
   252 
       
   253 
       
   254     /**
       
   255      * @see MNcdStorageDataItem::InternalizeL
       
   256      */
       
   257     virtual void InternalizeL( RReadStream& aStream );
       
   258 
       
   259 
       
   260 public: // CCatalogsCommunicable
       
   261 
       
   262     /**
       
   263      * @see CCatalogsCommunicable::ReceiveMessage
       
   264      */
       
   265     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   266                                  TInt aFunctionNumber );
       
   267 
       
   268     /**
       
   269      * @see CCatalogsCommunicable::CounterPartLost
       
   270      */
       
   271     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   272 
       
   273 
       
   274 protected:
       
   275 
       
   276     /**
       
   277      * Constructor
       
   278      *
       
   279      * @param aNode The node that owns this link.
       
   280      * @param aClassId This identifier can be asked to identify
       
   281      * the class for example when it is read from db.
       
   282      */
       
   283     CNcdNodeLink( CNcdNode& aNode,
       
   284                   NcdNodeClassIds::TNcdNodeClassId aClassId );
       
   285 
       
   286     /**
       
   287      * ConstructL
       
   288      */
       
   289     virtual void ConstructL();
       
   290     
       
   291 
       
   292     // These functions are called from the ReceiveMessage when
       
   293     // the given function id has matched to the function.
       
   294 
       
   295     /**
       
   296      * This function is called when the proxy wants to get the
       
   297      * data from the serverside. This function calls the
       
   298      * InternalizeDataForRequestL which may be overloaded in the
       
   299      * child classes
       
   300      * @param aMessage Contains data from the proxy and can be used
       
   301      * to send data back to proxy
       
   302      */
       
   303     void InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   304 
       
   305     /**
       
   306      * This function writes the object data to the stream. 
       
   307      * The stream content will be sent to the proxy that requested the data.
       
   308      * Child classes should add their own data after this parent data.
       
   309      *
       
   310      * @param aStream The data content of this class object will be written
       
   311      * into this stream.
       
   312      */
       
   313     virtual void ExternalizeDataForRequestL( RWriteStream& aStream ) const;    
       
   314 
       
   315 
       
   316     /**
       
   317      * This function is called from the proxy side. When the proxy
       
   318      * is deleted.
       
   319      * @param aMessage Contains data from the proxy and can be used
       
   320      * to send data back to proxy
       
   321      */
       
   322     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   323 
       
   324 
       
   325     /**
       
   326      * @param CNcdNode& Node that owns this link.
       
   327      */
       
   328     CNcdNode& Node() const;    
       
   329 
       
   330     
       
   331 private:
       
   332 
       
   333     // Prevent these two if they are not implemented
       
   334     CNcdNodeLink( const CNcdNodeLink& aObject );
       
   335     CNcdNodeLink& operator =( const CNcdNodeLink& aObject );
       
   336 
       
   337 
       
   338     /**
       
   339      * This function is used to insert the right parent identifier 
       
   340      * into the stream for the proxy.
       
   341      * In the case of the transparent parent, the proxy  
       
   342      * gets the grandparent as a parent instead of the real parent.     
       
   343      *
       
   344      * @param aStream The data content of this class object will be written
       
   345      * into this stream.
       
   346      */
       
   347     void ParentIdentifierForRequestL( RWriteStream& aStream ) const;
       
   348 
       
   349 
       
   350 private: // data
       
   351 
       
   352     // The class id is the id for this class that a factory uses
       
   353     // when it creates an object of this class.
       
   354     NcdNodeClassIds::TNcdNodeClassId iClassId;
       
   355     
       
   356     // Node that owns this link
       
   357     CNcdNode& iNode;
       
   358 
       
   359     HBufC* iTimeStamp;
       
   360     HBufC* iCatalogsSourceName;
       
   361     HBufC* iRemoteUri;
       
   362     HBufC* iServerUri;
       
   363 
       
   364     MNcdPreminetProtocolEntityRef::TDescription iDescription;
       
   365     TInt iValidUntilDelta;
       
   366     TBool iValidUntilAutoUpdate;
       
   367 
       
   368     // The actual parent of the node
       
   369     CNcdNodeIdentifier* iParentIdentifier;
       
   370     
       
   371     // The parent identifier that is given to the proxy side
       
   372     // when the parent is asked. This may differ from the actual parent
       
   373     // identifier for example if parent is transparent. Then the grandparent
       
   374     // should be returned to the proxy side instead the actual parent.
       
   375     CNcdNodeIdentifier* iRequestParentIdentifier;
       
   376 
       
   377     RArray<TInt> iQueries;
       
   378 
       
   379     TTime iLinkDownloadTime;
       
   380 
       
   381     // The message is set when ReceiveMessage is called. The message
       
   382     // is used in the CounterPartLost-function that informs the message
       
   383     // if the session has been lost.
       
   384     MCatalogsBaseMessage* iMessage;
       
   385     
       
   386     // This identifies the metadata that this link points to
       
   387     CNcdNodeIdentifier* iMetaDataIdentifier;
       
   388 
       
   389     // The node may be a remote node if the parent gets remote uri information
       
   390     // for the strcuture data of its child. This child then has to be loaded from
       
   391     // the given remote uri. An example is a catalog. For example, after
       
   392     // downloading a catalog it will act as a normal folder but the flag can be used
       
   393     // to inform its original purpose. EFalse means that the node was normal node,
       
   394     // ETrue means that the remote uri was originally given.
       
   395     TBool iRemoteFlag;
       
   396 
       
   397     // Metadata's timestamp is used for expiration checking    
       
   398     HBufC* iMetadataTimeStamp;
       
   399     };
       
   400 
       
   401 
       
   402 #endif // NCD_NODE_LINK_H