upnpmediaserver/mediaserverengine/inc/upnpmediaserverdescriptionprovider.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /** @file
       
     2 * Copyright (c) 2009 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:  CUpnpMediaServerDescriptionProvider declaration
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CUPNPMEDIASERVERDESCRIPTIONPROVIDER_H
       
    19 #define CUPNPMEDIASERVERDESCRIPTIONPROVIDER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <e32hashtab.h> 
       
    25 #include "upnpdevicedescriptionprovider.h"
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 
       
    29 class CUpnpSecurityManager;
       
    30 class TInetAddr;
       
    31 
       
    32 const TInt KMaxUriLength = 256;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  * CUpnpMediaServerDescriptionProvider
       
    38  * Provides description of device and its services, and icons. 
       
    39  *
       
    40  * @lib avmediaserver.exe
       
    41  * @since S60 MCL 
       
    42  */
       
    43 class CUpnpMediaServerDescriptionProvider : public CBase,
       
    44         public MUpnpDeviceDescriptionProvider
       
    45     {
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Destructor.
       
    50      */
       
    51     ~CUpnpMediaServerDescriptionProvider();
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      */
       
    56     static CUpnpMediaServerDescriptionProvider* NewL();
       
    57 
       
    58     /**
       
    59      * Two-phased constructor.
       
    60      */
       
    61     static CUpnpMediaServerDescriptionProvider* NewLC();
       
    62     
       
    63     /**
       
    64      * Adds new map uri to file.
       
    65      * 
       
    66      * @since S60 MCL
       
    67      * @param aUri uri
       
    68      * @param aFile file for aUri
       
    69      */    
       
    70     void AddUriToFileMapL( const TDesC8& aUri, const TDesC16& aFile );
       
    71     
       
    72     /**
       
    73      * Removes map uri to file.
       
    74      * 
       
    75      * @since S60 MCL
       
    76      * @param aUri uri
       
    77      */    
       
    78     void RemoveUriToFileMapL( const TDesC8& aUri );
       
    79     
       
    80 private:    // from MUpnpDeviceDescriptionProvider
       
    81     
       
    82     virtual TInt OnDeviceDescription( CUpnpDeviceDescriptionRequest& aRequest );
       
    83     
       
    84     virtual TInt OnServiceDescription( CUpnpDeviceDescriptionRequest& aRequest );    
       
    85     
       
    86     virtual TInt OnIcon( CUpnpDeviceDescriptionRequest& aRequest );            
       
    87     
       
    88     virtual TInt GetFile( const TDesC8& aUri, RFile& aFile ); 
       
    89 
       
    90 private:
       
    91 
       
    92     /**
       
    93      * Constructor for performing 1st stage construction
       
    94      */
       
    95     CUpnpMediaServerDescriptionProvider();
       
    96 
       
    97     /**
       
    98      * EPOC default constructor for performing 2nd stage construction
       
    99      */
       
   100     void ConstructL();
       
   101 
       
   102     /**
       
   103      * Main function to service requests.
       
   104      * 
       
   105      * @since S60 MCL
       
   106      * @param aRequest request to service
       
   107      * @return error code
       
   108      */
       
   109     TInt OnRequest( CUpnpDeviceDescriptionRequest& aRequest );
       
   110 
       
   111     /**
       
   112      * Check if resource is accessible.
       
   113      * Leaves with -EHttpNotFound when filename 
       
   114      * is not authorized for specific IP.
       
   115      * May leave with other system error code. 
       
   116      * 
       
   117      * @since S60 MCL
       
   118      * @param aFileName data source file name
       
   119      * @param aSender sender IP address
       
   120      */
       
   121     void AuthorizeRequestL( const TDesC& aFileName, const TInetAddr& aSender );
       
   122    
       
   123     /**
       
   124      * Gets a folder with device description.
       
   125      * Leave with KErrNotFound when aUri is not found.
       
   126      * 
       
   127      * @since S60 MCL
       
   128      * @param aUri uri to get file for
       
   129      * @param aPath on return contains path of file related to aUri
       
   130      */
       
   131     void GetFileFromUriL( const TDesC8& aUri, TDes& aPath );
       
   132 
       
   133     /**
       
   134      * Gets a path from uri. Removed IP and port.
       
   135      *  
       
   136      * @since S60 MCL
       
   137      * @param aUri uri to extract
       
   138      * @return allocated buffer with extracted uri lower case
       
   139      */
       
   140     HBufC8* ExtractPathAndFileFromUriL( const TDesC8& aUri );
       
   141 
       
   142 private:
       
   143     
       
   144     // Security manager
       
   145     // Own
       
   146     CUpnpSecurityManager* iSecurityManager;
       
   147     
       
   148     // File server session used to open file
       
   149     RFs iFs;
       
   150 
       
   151     // Hash map uri to file
       
   152     RHashMap< TBufC8<KMaxUriLength>, TFileName > iUriMap;
       
   153     
       
   154     // Used for file name to aviod use this type on stack
       
   155     TFileName iFileName;
       
   156     };
       
   157 
       
   158 #endif // CUPNPMEDIASERVERDESCRIPTIONPROVIDER_H