upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectory.h
changeset 0 7f85d04be362
child 9 0b99b84ce2a1
child 25 52826dcbed74
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /** @file
       
     2 * Copyright (c) 2005-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:  Declares ContentDirectory class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CUPNPCONTENTDIRECTORY_H
       
    20 #define C_CUPNPCONTENTDIRECTORY_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include "upnpserviceimplementation.h"
       
    25 #include "upnpelementfactory.h"
       
    26 
       
    27 // new xml
       
    28 #include <xmlengdom.h>
       
    29 
       
    30 #include "upnpfiletransfer.h"
       
    31 #include "upnpcontentdirectorydatafinder.h"
       
    32 #include "upnpthumbnailcreator.h"
       
    33 #include "upnpcdsettings.h"
       
    34 #include "upnptransferobserver.h"
       
    35 #include "upnphttpservertransactioncreator.h"
       
    36 #include "upnphttpserverobserver.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 class CUpnpElementFactory;
       
    41 class TUpnpContainerUpdateId;
       
    42 class CUpnpFileTransferTimerObserver;
       
    43 class CUpnpObject;
       
    44 class CUpnpItem;
       
    45 class CUpnpContentDirectoryDb;
       
    46 class CProtocolInfo;
       
    47 class CUpnpMetadataStorage;
       
    48 class CUpnpAutoDestroyObjectList;
       
    49 class MUpnpContentDirectoryEventObserver;
       
    50 class CUpnpFileTransferEvent;
       
    51 class MUpnpCdsSender;
       
    52 class CUpnpStateHandler;
       
    53 class CUpnpTransferUploader;
       
    54 class CUpnpMimeMapper;
       
    55 class CUpnpTransferController;
       
    56 class MUpnpTransferInterface;
       
    57 class CUpnpDlnaFilter;
       
    58 class CUpnpHttpServerSession;
       
    59 class CUpnpSecurityManager;
       
    60 
       
    61 // CONSTANTS
       
    62 static const TInt KMaxImportExportTransfers = 3;
       
    63 _LIT8( KContentDirectoryType, "ContentDirectory:1" );
       
    64 
       
    65 // CLASS DECLARATION
       
    66 
       
    67 /**
       
    68 *  @brief Main Content Directory Service Class
       
    69 *
       
    70 *  @lib ServiceFramework.lib
       
    71 *  @since Series60 2.6
       
    72 */
       
    73 class CUpnpContentDirectory :             
       
    74                 public CUpnpServiceImplementation, 
       
    75                 public MUpnpContentDirectoryDataFinder,
       
    76                 public MUpnpThumbnailCreatorObserver,
       
    77                 public MUpnpTransferObserver,
       
    78                 public MUpnpHttpServerTransactionCreator,
       
    79                 public MUpnpHttpServerObserver
       
    80 {
       
    81 public: // Constructors and destructors
       
    82     
       
    83     /**
       
    84     * Two-phased constructor for creating Content Directory Service (CDS).
       
    85     * @since Series60 2.6
       
    86     * @param aService Parent service 
       
    87     */
       
    88     static CUpnpContentDirectory* NewL( TUpnpCdSettings aSettings, 
       
    89                                         CUpnpMetadataStorage* aMetadataStorage,
       
    90                                         MUpnpTransferInterface* aTransfer );
       
    91 
       
    92     /**
       
    93     * Destructor function; called automatically from the destructor of a 
       
    94     * derived class
       
    95     **/
       
    96     virtual ~CUpnpContentDirectory();
       
    97     IMPORT_C void SetSender(MUpnpCdsSender* aSender);
       
    98             
       
    99 
       
   100 public: //from CUpnpServiceImplementation
       
   101     
       
   102     CUpnpStateHandler* CUpnpContentDirectory::StateHandler();
       
   103     /**
       
   104     * Handles auto destroy events.
       
   105     * @since Series 60 2.6
       
   106     * @param aObjIdn id of evented upnp object
       
   107     */
       
   108     void AutoDestroyEventL(TInt aObjId, TBool aDeleteObj);
       
   109 
       
   110     /**
       
   111     * This functions is a entry point for actions. See coments in base class
       
   112     * @since Series 60 2.6
       
   113     * @param aAction Action received by CDS.
       
   114     */
       
   115     void ActionReceivedLD( CUpnpAction* aAction );
       
   116     
       
   117     /**
       
   118     * Hnadle unknown http event
       
   119     * Export for interneal use only    
       
   120     */
       
   121     IMPORT_C void UnknownHttpEventReceivedL( CUpnpHttpMessage& aHttpMsg );
       
   122     
       
   123     /**
       
   124     * Handles address change event    
       
   125     */
       
   126     void AddressChangeL();
       
   127     
       
   128     /**
       
   129     * This function is for informing service from evented statevariables.
       
   130     * @since Series 60 2.6
       
   131     * @param aVariableName Name of the evented statevariable.
       
   132     */
       
   133     void StateVariableEvented(const TDesC8& aVariableName);
       
   134       
       
   135     /**
       
   136     * Checks if specified importUri is in database still active.
       
   137     * @param aImportUri uri to be searched in databse. 
       
   138     * @return objId if successful
       
   139     */
       
   140     TInt CheckImportUriL(const TDesC8& aImportUri);
       
   141 
       
   142     /**
       
   143     * Inserts Ip and Port
       
   144     * @since Series S60 3.1
       
   145     * @param aString
       
   146     */
       
   147     void InsertRealIpAndPortL(TDes8& aString);
       
   148     
       
   149     /**
       
   150     *
       
   151     * @since Series S60 3.1
       
   152     * @param aString
       
   153     * @return descriptor pointer
       
   154     */  
       
   155     HBufC8* InsertIpAndPortPlaceholderL(const TDesC8& aString);
       
   156     
       
   157     /**
       
   158     * Find protocolInfo by importUri (Not by importUri).
       
   159     * @param aImportUri uri to be searched in database (Value of resource).
       
   160     * @return aProtocolInfo related to resorce which has been founded 
       
   161     */  
       
   162     CUpnpDlnaProtocolInfo* GetProtocolInfoByImportUriL(const TDesC8& aImportUri);
       
   163     
       
   164     /**
       
   165     * Gets infomation about protocol
       
   166     * @since Series S60 3.1
       
   167     * @param aContentUri
       
   168     * @parma aProtocolInfo
       
   169     * @return
       
   170     */
       
   171     TInt GetProtocolInfoL(const TDesC8& aContentUri, CUpnpDlnaProtocolInfo*& aProtocolInfo);
       
   172         
       
   173     /**
       
   174     * Gets title of the object with given id from ContentDirectory service. 
       
   175     * @since Series60 2.6
       
   176     * @param aObjectId id of the object.
       
   177     * @param aValue pointer to buffer in which the tilte of the object will be returned.
       
   178     *       Buffer for aValue has to allocated first.
       
   179     **/
       
   180     void GetTitleForUriL( TInt aObjectId, TPtr& aValue );
       
   181         
       
   182     /**
       
   183     *
       
   184     * @since Series S60 3.1
       
   185     * @param aUrlPath
       
   186     * @param aFileName
       
   187     * @param aSystemPath
       
   188     */
       
   189     TInt FindSharedFolderL( const TDesC& aUrlPath, const TDesC& aFileName, HBufC*& aSystemPath);
       
   190         
       
   191     /**
       
   192     *
       
   193     * @since Series S60 3.1
       
   194     * @return TPtrC
       
   195     */
       
   196     const TPtrC MediaRealDir();
       
   197         
       
   198         
       
   199     /**
       
   200     * Sets download directory
       
   201     * @since Series S60 3.1
       
   202     * @param aDownloadDir this directory is going to be set as download directory
       
   203     * @return TInt
       
   204     */
       
   205     void SetDownloadDirectoryL(const TDesC& aDownloadDir);
       
   206         
       
   207     /**
       
   208     * Sets thumbnail directory
       
   209     * @since Series S60 3.1
       
   210     * @param aDownloadDir this directory is going to be set as thumbnail directory
       
   211     * @return TInt
       
   212     */
       
   213     void SetThumbnailDirectoryL(const TDesC& aDownloadDir);    
       
   214     
       
   215     TInetAddr GetAddress();
       
   216     IMPORT_C void SendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
       
   217     IMPORT_C void SendMessageL( CUpnpHttpMessage* aMessage );
       
   218     CUpnpAutoDestroyObjectList* GetAutoDestroyObjectList();
       
   219     
       
   220     // For internal use only
       
   221     IMPORT_C void HttpTransferEventReceivedL(CUpnpHttpMessage& aHttpMsg);
       
   222     
       
   223     /**
       
   224     * Sends transfer failed event to Media Server       
       
   225     * @param aSessionId transaction identifier
       
   226     * @param aStatusCode HTTP Status code
       
   227     */
       
   228     void NotifyTransferFailL(TInt aSessionId, TInt aStatusCode);
       
   229     
       
   230     /**
       
   231     * Sends transfer stopped event to Media Server       
       
   232     * @param aSessionId transaction identifier
       
   233     * @param aType import/export
       
   234     */
       
   235     void NotifyTransferStoppedL( TInt aSessionId, CUpnpFileTransfer::TTransferType aType);
       
   236 
       
   237      // new functions for httptransfer.dll intergration
       
   238     void HttpGetStartedSoapNotifyL(TInt aSessionId);    
       
   239     void HttpPostStartedL(TInt aSessionId);   
       
   240               
       
   241 
       
   242     // helper functions
       
   243     TCurrentAction ExecutedAction();
       
   244     void SetExecutedAction(TCurrentAction aAction);
       
   245     
       
   246     
       
   247     /**
       
   248     * This function is a entry point for http messages.
       
   249     * received from Symbian HTTP Stack
       
   250     * @since Series 60 3.2
       
   251     * @param aSessionId identifier of the HTTP request.
       
   252     * @param aHttpStatusCode HTTP error code.
       
   253     */
       
   254     void HttpResponseReceivedL( TInt aSessionId,
       
   255                                 TInt aStatusCode);   
       
   256     
       
   257     /**
       
   258     * Getter
       
   259     * @since Series 60 3.2
       
   260     * @return Event Observer
       
   261     */
       
   262     MUpnpContentDirectoryEventObserver* EventObserver();
       
   263     
       
   264 public://temporary public methods
       
   265 
       
   266     void TransferCompleteL(TInt aResId, TInt aObjId);
       
   267     
       
   268     void TransferProgress( TInt aId, TInt aBytes, TInt aTotalBytes );
       
   269     
       
   270     void TransferStartL(const TDesC8& aImpUri);
       
   271 
       
   272     /** 
       
   273     * This fuction removes a TransferID from the TransferIDs Statevariable
       
   274     * @since Series 60 2.6
       
   275     * @param aTransferID a id of file transfer
       
   276     **/
       
   277     void RemoveFileTransferFromTransferIDsStateVariableL(TInt aTransferID);
       
   278     
       
   279     /** 
       
   280     * This fuction adds a TransferID to the TransferIDs Statevariable
       
   281     * @since Series 60 2.6
       
   282     * @param aTransferID a id of file transfer
       
   283     **/
       
   284     void AddFileTransferToTransferIDsStateVariableL( TInt aTransferID );
       
   285     
       
   286     /**
       
   287     *
       
   288     * @since Series S60 3.1
       
   289     * @param aFileName
       
   290     * @return boolean whether given file is drmfile
       
   291     */
       
   292     TBool IsDrmFileL(const TDesC& aFileName);
       
   293     
       
   294     /**
       
   295     *
       
   296     * @since Series S60 3.1
       
   297     * @param aFileName
       
   298     * @return boolean whether given file is drmfile
       
   299     */
       
   300     TBool IsDrmFileL(const TDesC8& aFileName);
       
   301     
       
   302 
       
   303      /** 
       
   304     * This functions is used for generating correct res tags for finished downloads.
       
   305     * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
       
   306     *                           In CreateObject case res can be created by passed argument so we only thumbail has to be created
       
   307     * @since Series 60 2.6
       
   308     * @return error code. KErrNone if no errors.
       
   309     **/
       
   310     TInt CreateResTagL( TInt aSessionId, 
       
   311                        TDesC8& aFilePath, 
       
   312                         TInt aImportNumber,
       
   313                         TBool aOnlyThumbnail = EFalse  );
       
   314 
       
   315 
       
   316     /**
       
   317     * Notify transfer          
       
   318     * @param aSessionId HTTP transaction identifier 
       
   319     */    
       
   320     void NotifyOutgoingTransferL (TInt aSessionId); 
       
   321     
       
   322     
       
   323     CUpnpContentDirectoryDb*  ContentDirectoryDb();
       
   324     
       
   325     MUpnpTransferInterface* TransferHandler();
       
   326     
       
   327 public: //from MUpnpTransferObserver
       
   328     
       
   329     virtual void TransferCompletedL( TInt akey, TInt aResultCode );
       
   330 
       
   331 public: //from MUpnpHttpServerTransactionCreator
       
   332 
       
   333         IMPORT_C virtual void NewTransactionL(
       
   334         const TDesC8& aMethod, const TDesC8& aUri, 
       
   335         const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans );
       
   336 
       
   337 private: //form MUpnpHttpServerObserver
       
   338     virtual void HttpEventLD( CUpnpHttpMessage* aMessage );
       
   339     
       
   340 private://private methods
       
   341 
       
   342 
       
   343     void PrepareAutoDestroyObjectL(TXmlEngElement aObject, TInt aObjId);
       
   344 
       
   345     /**
       
   346     * Gets ip and port number
       
   347     * @since Series S60 3.1
       
   348     * @return descriptor pointer
       
   349     */
       
   350     HBufC8* GetIpAndPortDes8L();
       
   351 
       
   352     /**
       
   353     * Sets size
       
   354     * @since Series S60 3.1
       
   355     * @parma aSize
       
   356     * @parma aFilePath
       
   357     */
       
   358     void SetResSizeL(TXmlEngAttr aSize, const TDesC& aFilePath);
       
   359         
       
   360     /**
       
   361     * Adds Import URI to Element
       
   362     * @since Series S60 3.1
       
   363     * @param aElement
       
   364     */
       
   365     void AddImportUriToElL(TXmlEngElement aElement);
       
   366         
       
   367     /**
       
   368     *
       
   369     * @since Series S60 3.1
       
   370     * @return descriptor pointer
       
   371     */
       
   372     HBufC8* BuildImportUriLC();
       
   373     HBufC8* BuildImportUriShorterLC();
       
   374         
       
   375     /**
       
   376     * Checking whether thumbnail is available
       
   377     * @since Series S60 3.1
       
   378     * @param aFile
       
   379     * @return 
       
   380     **/
       
   381     TBool IsThumbnailAvailableL(const TDesC& aFile);
       
   382     
       
   383     /**
       
   384     * Checking whether thumbnail is available
       
   385     * @since Series S60 3.1
       
   386     * @param aFile 
       
   387     * @return
       
   388     */
       
   389     TBool IsThumbnailAvailableL(const TDesC8& aFile);
       
   390     
       
   391     /**
       
   392     * Creates thumbnail
       
   393     * @since Series S60 3.1
       
   394     * @param a SrcFile
       
   395     * @param aObjId
       
   396     */
       
   397     void CreateThumbnailL(const TDesC& aSrcFile, TInt aObjId);
       
   398     
       
   399     /**
       
   400     * Adds new res tag
       
   401     * @since Series S60 3.1
       
   402     * @param aObjEl 
       
   403     */
       
   404     void AddNewResTagL(TXmlEngElement aObjEl);
       
   405     
       
   406     /**
       
   407     * Creates a name for thumbnail
       
   408     * @since Series S60 3.1
       
   409     * @param aFileName
       
   410     * @return descriptor pointer
       
   411     */
       
   412     HBufC* CreateNameForThumbnailL(const TDesC& aFileName);
       
   413     
       
   414     /**
       
   415     *
       
   416     * @since Series S60 3.1
       
   417     * @param aRes
       
   418     */      
       
   419     void HandleLocalResourcesL(TXmlEngElement aRes, TInt aObjectId);
       
   420     
       
   421     /**
       
   422     *
       
   423     * @since Series S60 3.1
       
   424     * @parma aFileName
       
   425     * @return descriptor pointer
       
   426     */
       
   427     HBufC8* BuildContentUriL(const TDesC& aFileExt, TInt aObjectId);  
       
   428     
       
   429     /**
       
   430     *
       
   431     * @since Series S60 3.1
       
   432     * @param aAction  
       
   433     * @param aSenAndDestroy
       
   434     * @return
       
   435     */
       
   436     TInt DoActionReceivedL( CUpnpAction* aAction );
       
   437     
       
   438     /**
       
   439     * 
       
   440     * since Series S60 3.1
       
   441     * @param aObjs
       
   442     * return descriptor pointer
       
   443     */
       
   444     HBufC8* SerializeObjectsListL(const RArray<RXmlEngDocument>& aObjs);
       
   445               
       
   446     /**
       
   447     *
       
   448     * @since Series S60 3.1
       
   449     * @param aObj
       
   450     * @param aImportUri
       
   451     * @param ANewFile
       
   452     */
       
   453     void DeleteOldResourcesL( RXmlEngDocument& aObj, const TDesC8& aImportUri,
       
   454                               const TDesC& aNewFile );
       
   455     
       
   456     /**
       
   457     *
       
   458     * @since Series S60 3.1
       
   459     * @parma aMessage
       
   460     * return descriptor pointer
       
   461     */
       
   462     HBufC8* GetImportUriLC(CUpnpHttpMessage* aMessage);     
       
   463        
       
   464     /**
       
   465     *
       
   466     * @since Series S60 3.1
       
   467     * @param aFileName
       
   468     * @param aNextKey
       
   469     * @return descriptor pointer
       
   470     */
       
   471     HBufC* BuildThumbnailUrlPathL(const TDesC& aFilename, const TDesC& aNextKey);
       
   472 
       
   473     /**
       
   474     * This function gets mime type for specified file. 
       
   475     * @since Series 60 3.1
       
   476     * @param aFilename -  filename, for which mimeType will be taken.
       
   477     * @return pointer to variable storing mimeType. 
       
   478     */
       
   479     HBufC8* GetMimeTypeLC(const TDesC8& aFilename);    
       
   480 
       
   481     /**
       
   482     * Removes thumbnail creator and corresponding objectId from lists. 
       
   483     * @since Series 60 3.1
       
   484     * @param aThCreator - thumbnail creator for which the information will be deleted.
       
   485     */
       
   486     void RemoveThCreatorAndObjectIdLD( CUpnpThumbnailCreator* aThCreator);
       
   487 
       
   488     /**
       
   489     * Gives object id for specified thumbnail creator. 
       
   490     * @since Series 60 3.1
       
   491     * @param aThCreator - thumbnail creator for which object id will be searched for. 
       
   492     * @return object id for specified thumbnail creator. 
       
   493     */
       
   494     TInt GetObjectIdFromThCreator( CUpnpThumbnailCreator* aThCreator);
       
   495 
       
   496     /**
       
   497     * Gives this server address in predefined format. 
       
   498     * @since Series 60 3.1
       
   499     * @return pointer to address. 
       
   500     */
       
   501     HBufC8* CreateAddressValueLC();
       
   502 
       
   503     /**
       
   504     * This function creates ProtocolInfo object for further use. 
       
   505     * @since Series 60 3.1
       
   506     * @param aMimeType - mime type, for which ProtocolInfo will be created.
       
   507     * @param aAddInfo - additional information which can be choosen according to mime type and image size. 
       
   508     * @return pointer to CProtocolInfo object, which describes all protocolInfo values for this element.
       
   509     */
       
   510     CUpnpDlnaProtocolInfo* CreateProtocolInfoFromMimeL(const TDesC8& aMimeType, TInt aAddInfo );
       
   511 
       
   512     /**
       
   513     * This function retrieves title from object description. 
       
   514     * @since Series 60 3.1
       
   515     * @param aObjId - objecty id for which title will be retrieved. 
       
   516     * @return pointer to HBufC, with specified value. 
       
   517     */
       
   518     HBufC* GetFileNameL( TInt aObjId );    
       
   519     HBufC* GetFileNameWithoutPathL( TInt aObjId );
       
   520     
       
   521     /**
       
   522     * This function add underscore and number to existing filename. 
       
   523     * @since Series 60 3.2
       
   524     * @param aFileName - file that probably exist. 
       
   525     * @return pointer to HBufC, with specified value. 
       
   526     */
       
   527     HBufC* CreateFileNameL( const TDesC16& aFileName );
       
   528    
       
   529     /**
       
   530     * This function puts on stack upnp:class value for specific mime type.  
       
   531     * @since Series 60 3.1
       
   532     * @param aMimeType - mime type from which additional information will be retrieved. 
       
   533     * @return pointer to HBufC8 object with new value, if the type is unknown there is null returned.
       
   534     * Mapping: 
       
   535     * image/* - object.item.imageItem
       
   536     * video/* - object.item.videoItem 
       
   537     * audio/* - object.item.audioItem 
       
   538     * text/* - object.item.textItem 
       
   539     */ 
       
   540     HBufC8* GetItemTypeFromMimeTypeLC(const TDesC8& aMimeType);
       
   541         
       
   542     /**
       
   543     * This function compares upnp:class tag value, with value denoted by aMimeType. 
       
   544     * @since Series 60 3.1
       
   545     * @param obj - object for which needed changes will be applied.
       
   546     * @param aMimeType - mime type from which additional information will be retrieved. 
       
   547     */ 
       
   548     void CheckItemTypeForObjectL( RXmlEngDocument& obj, const TDesC8&  aMimeType );
       
   549         
       
   550   
       
   551     /**
       
   552     * This function returns a XML fragment containing the XML in the parameter
       
   553     * @since Series 60 2.6
       
   554     * @param aBuffer the XML is in this buffer
       
   555     * @return A new CSenDomFragment that is on the cleanup stack
       
   556     */
       
   557     RXmlEngDocument XmlFragmentL(const TDesC8& aBuffer);
       
   558         
       
   559     /**
       
   560     * This fuctions converts one XML element to a string 
       
   561     * @since Series 60 2.6
       
   562     * @param aResp XML string
       
   563     * @param aSen an Sen element to be converted to string
       
   564     */
       
   565     void BrowseElementL( HBufC8*& aResp, TXmlEngElement& aSen );
       
   566 
       
   567     /**
       
   568     * This fuctions is a getter for container updateID. 
       
   569     * @since Series 60 2.6
       
   570     * @param aID ID of the container which updateID is returned
       
   571     * @return a updateId of container
       
   572     */
       
   573     TInt ContainerUpdateId( const TDesC8& aContainerID );
       
   574 
       
   575 
       
   576     /**
       
   577     * Function to add data to metadb
       
   578     * @param aFragment fragment to add to db
       
   579     * @param aContainer container where to add data
       
   580     * @param aId parameter returned by AddToMetaDbL method, stands for item id
       
   581     * @return upnperrorcode descriping situation
       
   582     */
       
   583     TUpnpErrorCode AddToMetaDbL( RXmlEngDocument& aFragment, TInt aContainer, TInt* aId,
       
   584                                  TBool aIsLocal );
       
   585 
       
   586     /*
       
   587     *
       
   588     * @since Series S60 3.1
       
   589     * @param aFragment
       
   590     * @param aImportUris
       
   591     * @param aRess
       
   592     * @param aLocal
       
   593     * @param aCreateThumbnailRes
       
   594     * @param aNextKey
       
   595     * @return upnperrorcode descriping situation
       
   596     */
       
   597     TUpnpErrorCode PrepareCreateOperationL( RXmlEngDocument& aFragment, 
       
   598         RArray<TXmlEngAttr>& aImportUris, RArray<TXmlEngElement>& aRess, TBool& aLocal,
       
   599         TBool& aCreateThumbnailRes, TInt& aNextKey );
       
   600 
       
   601     /**
       
   602     * Related to CreateObject, resultset of create is created here
       
   603     * @since Series 60 2.6
       
   604     * @param aAction action data structure is needed here
       
   605     * @param aElement element added to db
       
   606     * @param aId element's id
       
   607     **/
       
   608     void ConstructCreateResultsetL( CUpnpAction*& aAction, 
       
   609                                     RXmlEngDocument aElement, 
       
   610                                     TInt aId );
       
   611 
       
   612  
       
   613     /** 
       
   614     * Function for creating a new object
       
   615     * @since Series 60 2.6
       
   616     * @param aAction received action
       
   617     * @return upnperrorcode descriping situation
       
   618     **/
       
   619     TUpnpErrorCode CreateObjectL( CUpnpAction*& aAction );
       
   620     /** 
       
   621     * Function for browsing values of objects
       
   622     * @since Series 60 2.6
       
   623     * @param aAction received action
       
   624     * @return upnperrorcode descriping situation
       
   625     **/
       
   626     TUpnpErrorCode BrowseL( CUpnpAction*& aAction );
       
   627 
       
   628     /** 
       
   629     * Function for destroying objects
       
   630     * @since Series 60 2.6
       
   631     * @param aAction received action
       
   632     * @return upnperrorcode descriping situation
       
   633     **/
       
   634     TUpnpErrorCode DestroyObjectL( CUpnpAction*& aAction );
       
   635 
       
   636     /** 
       
   637     * Function for creating refense items
       
   638     * @since Series 60 2.6
       
   639     * @param aAction received action
       
   640     * @return upnperrorcode descriping situation
       
   641     **/
       
   642     TUpnpErrorCode CreateReferenceL( CUpnpAction*& aAction );
       
   643 
       
   644     /** 
       
   645     * Function to solve CDS's search capabilities
       
   646     * @since Series 60 2.6
       
   647     * @param aAction received action
       
   648     * @retrun upnperrorcode descriping situation
       
   649     **/
       
   650     TUpnpErrorCode GetSearchCapabilitiesL( CUpnpAction*& aAction );
       
   651 
       
   652     /** 
       
   653     * Function to solve CDS's sort capabilities
       
   654     * @since Series 60 2.6
       
   655     * @param aAction received action
       
   656     * @return upnperrorcode descriping situation
       
   657     **/
       
   658     TUpnpErrorCode GetSortCapabilitiesL( CUpnpAction*& aAction );
       
   659 
       
   660     /** 
       
   661     * Getter for CDS's SystemUpdateID
       
   662     * @since Series 60 2.6
       
   663     * @param aAction received action
       
   664     * @return upnperrorcode descriping situation
       
   665     **/
       
   666     TUpnpErrorCode GetSystemUpdateIdL( CUpnpAction*& aAction );
       
   667 
       
   668     /** 
       
   669     * Function for importing resources
       
   670     * @since Series 60 2.6
       
   671     * @param aAction received action
       
   672     * @return upnperrorcode descriping situation
       
   673     **/
       
   674     TUpnpErrorCode ImportResourceL( CUpnpAction*& aAction );
       
   675 
       
   676     /** 
       
   677     * Function for exporting resources
       
   678     * @since Series 60 2.6
       
   679     * @param aAction received action
       
   680     * @return upnperrorcode descriping situation
       
   681     */
       
   682     TUpnpErrorCode ExportResourceL( CUpnpAction*& aAction );
       
   683 
       
   684     /** 
       
   685     * Function for stopping ongoing file transfer (import / export)
       
   686     * @since Series 60 2.6
       
   687     * @param aAction received action
       
   688     * @retrun upnperrorcode descriping situation
       
   689     **/
       
   690     TUpnpErrorCode StopTransferResourceL( CUpnpAction*& aAction );
       
   691 
       
   692     /** 
       
   693     * Function for getting information about ongoing file transfer
       
   694     * @since Series 60 2.6
       
   695     * @param aAction received action
       
   696     * @return upnperrorcode descriping situation
       
   697     **/
       
   698     TUpnpErrorCode GetTransferProgressL( CUpnpAction*& aAction );
       
   699 
       
   700     /** 
       
   701     * This functions removes a "res" tag from a object
       
   702     * @since Series 60 2.6
       
   703     * @param aAction received action
       
   704     * @return upnperrorcode descriping situation
       
   705     **/
       
   706     TUpnpErrorCode DeleteResourceL( CUpnpAction*& aAction );
       
   707 
       
   708     /**
       
   709     * This function changes file name and its extension. 
       
   710     * @since Series 60 3.1
       
   711     * @param aFilePath - the target file. 
       
   712     * @param aMimeType - mime type, for which file extension will be choosen. 
       
   713     */
       
   714     HBufC8* ChangeFileNameWithExtensionL(TDesC8& aFilePath, const TDesC8& aMimeType );
       
   715  
       
   716  
       
   717    
       
   718     /**
       
   719     * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
       
   720     *           In CreateObject case res can be created by passed argument so we only thumbail has to be created
       
   721     */
       
   722     TInt CreateResTagInternalL( TInt aSessionId, 
       
   723                                 TDesC8& aFilePath,
       
   724                                 HBufC8* aImportUri, 
       
   725                                 TBool aOnlyThumbnail );
       
   726 
       
   727     /**
       
   728     * calls CreateResTagInternalL but KErrCorrupted is TRAPed in order to invoke recovery on DB
       
   729     */
       
   730     TInt CreateResTagInternalWithDBRecoveryL( TInt aSessionId,
       
   731                                               TDesC8& aFilePath, 
       
   732                                               HBufC8* aImportUri, 
       
   733                                               TBool aOnlyThumbnail = EFalse );
       
   734     
       
   735 private:    // New functions    
       
   736 
       
   737    
       
   738     void DoSendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
       
   739     void DoSendMessageL(CUpnpHttpMessage* aMessage);
       
   740     TBool IsValidUrlPath(const TDesC& aUrlPath);
       
   741     
       
   742     /**
       
   743     * Gets protocolInfo from mimeType.
       
   744     * @param aMimeType mime type for which protocolInfo will be created.
       
   745     * @return string with protocolInfo
       
   746     */
       
   747     HBufC8* ProtocolInfoFromMimeL( const TDesC8& aMimeType, TInt aAddInfo, TBool aOpRangeParam,
       
   748                                    TBool aCiParam = EFalse );
       
   749 
       
   750     HBufC8* ProtocolInfoFromMimeL(const TDesC8& aMimeType, TXmlEngElement& aResEl);
       
   751     
       
   752     /**
       
   753     * Notify message when the thumbnail creation has been finished. 
       
   754     * From MUpnpThumbnailCreatorObserver interface.
       
   755     * @param aThCreator this is a thumbnail creator.
       
   756     * @param aResult result from thumbnail creation.
       
   757     */
       
   758     void NotifyThumbnailResultL( CUpnpThumbnailCreator* aThCreator, TInt aResult );
       
   759 
       
   760     /**
       
   761     * Notify message when the thumbnail creation has been finished. 
       
   762     * From MUpnpThumbnailCreatorObserver interface.
       
   763     * @param aThCreator this is a thumbnail creator.
       
   764     * @param aResult result from thumbnail creation.
       
   765     */
       
   766     CUpnpThumbnailCreator* CreateThumbnailCreatorL(TInt aObjectId);
       
   767     
       
   768     /**
       
   769     * Cheks if object exists.
       
   770     * @param aObjectId
       
   771     */
       
   772     TBool IsObjectExistL( TInt aObjectId );
       
   773     
       
   774     /**
       
   775     * Cheks if object is valid.
       
   776     * if object doesn't exist or has no parent 
       
   777     * object is removed from autodestoy table and EFalse is returned
       
   778     * @param aObjectId
       
   779     */
       
   780     TBool ValidateObjectL( TInt aObjectId );
       
   781          
       
   782     /**
       
   783     * Handles DB error
       
   784     * Tries to recover, if fails tries to recreate
       
   785     * @since Series S60 3.2
       
   786     * @return TInt - KErrNone if succeed
       
   787     */
       
   788     TInt HandleDbError( TInt aError );
       
   789     
       
   790     /**
       
   791     * Checks DB and disk Space
       
   792     * Tries to recover DB, if fails tries to recreate
       
   793     * @since Series S60 3.2
       
   794     * @param aAction received action
       
   795     * @return EFalse if succeed
       
   796     */
       
   797     TBool IsDbOrDiskProblemL( CUpnpAction* aAction );
       
   798     
       
   799     /**
       
   800     * Determines if DB has benn recovered successfully
       
   801     * returns ETrue if yes
       
   802     * @param a Error - DB is revovered only if aError equal KErrCorrupted
       
   803     * @since Series S60 3.2
       
   804     * @returns ETrue if succeed 
       
   805     */
       
   806     TBool DataBaseHasBeenRecoveredL( TInt aError );
       
   807     
       
   808     /**
       
   809     * Returns DB creation status
       
   810     * @since Series S60 3.2
       
   811     * @return TBool
       
   812     */
       
   813     TBool IsDbCreated(); 
       
   814 
       
   815     /**
       
   816     * Updates import URI
       
   817     * @since Series S60 3.2
       
   818     * @return TPtrC8
       
   819     */
       
   820     TPtrC8 UpdateImportUriL( const TDesC8& aImportUri );
       
   821     
       
   822 private: // Constructors
       
   823     
       
   824     /**
       
   825     * C++ default constructor.
       
   826     */
       
   827     CUpnpContentDirectory( CUpnpDevice& aDevice, 
       
   828                            MUpnpThumbnailCreatorObserver* aThmbObs,
       
   829                            MUpnpTransferInterface* aTransfer
       
   830                          );
       
   831 
       
   832     /**
       
   833     * Second phase of the constructor.
       
   834     * Initialises a DOM tree.
       
   835     * By default Symbian 2nd phase constructor is private.
       
   836     * @param service Parent service
       
   837     */
       
   838     void ConstructL( TUpnpCdSettings aSettings, 
       
   839                      CUpnpMetadataStorage* aMetadataStorage 
       
   840                    );
       
   841     
       
   842     void ConstructHttpL();
       
   843     
       
   844 private:
       
   845     
       
   846     //Array containing objects ids, which will be updated after Thumbnail creation.
       
   847     RArray<TInt> iThObjectIds;
       
   848     
       
   849     // Array of thumbnail creators in which creators can be searched for.
       
   850     RPointerArray<CUpnpThumbnailCreator> iThumbnailCreators;
       
   851 
       
   852     // Next free object ID, owned
       
   853     TInt iNextFreeID;
       
   854 
       
   855     // Pointerarray for pending actions (used in Import and Export), owned
       
   856     //RPointerArray<CUpnpAction> iPendingActions;
       
   857 
       
   858     // Elementfactory, owned
       
   859     CUpnpElementFactory* iElementdb;
       
   860     
       
   861        
       
   862     // Database
       
   863     CUpnpContentDirectoryDb* iContentDirectoryDb;
       
   864         
       
   865     // file session
       
   866     RFs iFs;
       
   867     
       
   868     // Download directory
       
   869     HBufC* iDownloadDir;
       
   870     
       
   871    // Thumbnail directory
       
   872     HBufC* iThumbDir;
       
   873     // connection try to bitmap and font server. 
       
   874     // if there is no such connection there will be no thumbcreated. 
       
   875     TInt iBitmapServerConnection;
       
   876         
       
   877     TBool iEcomUsed;
       
   878         
       
   879     // Thumbnail creator observer
       
   880     MUpnpThumbnailCreatorObserver* iThmbObs;
       
   881 
       
   882     // auto-destroy object list    
       
   883     CUpnpAutoDestroyObjectList* iAutoDestroyObjects;
       
   884 
       
   885     
       
   886     // Event observer
       
   887     MUpnpContentDirectoryEventObserver* iEventObserver;
       
   888     
       
   889     // Thumbnail creation flag
       
   890     TBool iCreateThumbnails; 
       
   891     
       
   892     // Max number of browsed object
       
   893     TInt iMaxRequestCount;
       
   894 
       
   895     TCurrentAction iCurrentAction;
       
   896     
       
   897     RXmlEngDOMImplementation iDOMImpl;
       
   898     
       
   899     MUpnpCdsSender* iSender; // not owned
       
   900         
       
   901     CUpnpMimeMapper* iMimeToExtMap;
       
   902         
       
   903     HBufC* iObjectsXmlPath;
       
   904     
       
   905     CUpnpStateHandler* iStateHandler;
       
   906          
       
   907 
       
   908     CUpnpTransferController* iTransferController;
       
   909     
       
   910     MUpnpTransferInterface* iTransferHandler;
       
   911     
       
   912     CUpnpDlnaFilter* iDlnaFilter;
       
   913     
       
   914     CUpnpHttpServerSession* iHttpServerSession;
       
   915     
       
   916     CUpnpSecurityManager* iSecurityManager;
       
   917     
       
   918     };
       
   919 
       
   920 #endif  // C_CUPNPCONTENTDIRECTORY_H
       
   921 
       
   922 // End Of File