upnpmediaserver/mediaserverengine/inc/upnpiconmanager.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /** @file
       
     2 * Copyright (c) 2008-2008 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 CUpnpIconManager class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CUPNPICONMANAGER_H
       
    21 #define C_CUPNPICONMANAGER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <f32file.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CUpnpIcon;
       
    28 class CUpnpDeviceImplementation;
       
    29 class CUpnpDevice;
       
    30 class CUpnpMediaServerDescriptionProvider;
       
    31 class CUpnpDeviceDescriptionStore;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36  *  Class is responsible for MS icon managing
       
    37  *  Handles all request releated to icons
       
    38  *  Such as: Adding, Updating and Removing icons to/from MS description
       
    39  *  @since S60 v3.2
       
    40  */
       
    41 class CUpnpIconManager: public CBase
       
    42     {
       
    43 public:
       
    44     /**
       
    45      * Two-phased constructor.
       
    46      * @param aDescriptionFile file with device description xml
       
    47      * @param aDescriptionProvider description provider
       
    48      */
       
    49     static CUpnpIconManager* NewL( CUpnpDeviceDescriptionStore& iDescriptionStore,
       
    50                                    CUpnpMediaServerDescriptionProvider& aDescriptionProvider );
       
    51 
       
    52     /**
       
    53      * Two-phased constructor.
       
    54      * @param aDescriptionFile file with device description xml
       
    55      * @param aDescriptionProvider description provider
       
    56      */
       
    57     static CUpnpIconManager* NewLC( CUpnpDeviceDescriptionStore& iDescriptionStore,
       
    58                                     CUpnpMediaServerDescriptionProvider& aDescriptionProvider );
       
    59 
       
    60     /**
       
    61      * Destructor
       
    62      */
       
    63     ~CUpnpIconManager();
       
    64     
       
    65     /**
       
    66     * Adds icon
       
    67     * @param aIconDes icon description( serialized icon )
       
    68     */
       
    69     void AddIconL( const TDesC8& aIconDes );
       
    70 
       
    71     /**
       
    72     * Updates icon
       
    73     * @param aNewIconDes new icon description( serialized icon )
       
    74     * @param aUrl url of icon which will be updated
       
    75     */
       
    76     void UpdateIconL( const TDesC8& aNewIconDes, const TDesC8& aUrl );
       
    77 
       
    78     /**
       
    79     * Removes icon
       
    80     * @param url of icon which will be deleted
       
    81     */
       
    82     void RemoveIconL( const TDesC8& aUrl );
       
    83 
       
    84     /**
       
    85     * Removes all icons
       
    86     */
       
    87     void RemoveIconsL();
       
    88 
       
    89 private:
       
    90     /**
       
    91     * Creates icon path
       
    92     * @return icon path
       
    93     */
       
    94     HBufC* GetIconPathLC();
       
    95 
       
    96     /**
       
    97     * Returns icon name
       
    98     * @param aPath
       
    99     * @return icon name
       
   100     */
       
   101     HBufC* GetIconNameLC( const TDesC8& aPath );
       
   102 
       
   103     /**
       
   104     * Copy icon to MS private directory
       
   105     * @param aIcon icon which will be copied
       
   106     * @param aDestinationPath icon's destination directory
       
   107     */
       
   108     void CopyIconToPrivateL( const CUpnpIcon* icon , const TDesC& destinationPath );
       
   109 
       
   110     /**
       
   111     * Prepare beckup copy of icon which is going to be updated
       
   112     * @param aPath path to icon which going to be beckuped
       
   113     * return pointer to beckup filename, used in rollback operation
       
   114     */
       
   115     HBufC* PrepareIconToRollbackLC( const TDesC& aPath );
       
   116 
       
   117     /**
       
   118     * Updates icon
       
   119     * @param aIcon new icon
       
   120     * @param aDestinationPath old icon path
       
   121     */
       
   122     void DoUpdateIconL( CUpnpIcon* aIcon, const TDesC& aDestinationPath );
       
   123 
       
   124     /**
       
   125     * Deletes icon from FS
       
   126     * @param aPath path to icon which is delete
       
   127     * @returns KErrNone if succesfull or other error code of failed
       
   128     */
       
   129     TInt DeleteIconFile( const TDesC& aPath );
       
   130 
       
   131     /**
       
   132     * Makes an attempt to restore icon from it's original path
       
   133     * @param aUrl icons URL
       
   134     */
       
   135     void RestoreFromOrginalPathL( const TDesC8& aUrl );
       
   136 
       
   137     /**
       
   138     * Checks if icon already exist in device iconList
       
   139     * Leaves with KErrNotFound if icon doesn't exist
       
   140     * @param aUrl an icon's URL to be checked
       
   141     */
       
   142     TInt FindIcon( const TDesC8& aUrl );
       
   143 
       
   144     /**
       
   145      * Adds all icons to the description property map.
       
   146      * 
       
   147      * @since S60 5.1
       
   148      */
       
   149     void AddIconsToDescriptionPropertyMapL();
       
   150     
       
   151 private:
       
   152 
       
   153     /**
       
   154      * Two-phased constructor.
       
   155      * @param aDescriptionFile file with device description xml
       
   156      */
       
   157     void ConstructL();
       
   158 
       
   159     /**
       
   160      * Constructor.
       
   161      * @param aDescriptionProvider description provider
       
   162      */
       
   163     CUpnpIconManager( CUpnpDeviceDescriptionStore& iDescriptionStore,
       
   164                       CUpnpMediaServerDescriptionProvider& aDescriptionProvider );
       
   165 
       
   166 private:
       
   167     
       
   168     /** File session handler - owned */
       
   169     RFs iFileSession;
       
   170     
       
   171     /** Icon list used for icon operation when device is not started */
       
   172     RPointerArray< CUpnpIcon > iIconList;
       
   173     
       
   174     /** Description provider - not owned */
       
   175     CUpnpMediaServerDescriptionProvider& iDescriptionProvider;
       
   176     
       
   177     /** Description store */
       
   178     CUpnpDeviceDescriptionStore& iDescriptionStore; 
       
   179     };
       
   180 
       
   181 
       
   182 #endif//C_CUPNPICONMANAGER_H