skins/AknSkins/srvinc/AknsSrvUtils.h
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Utility methods for skin server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef AKNSSRVUTILS_H
       
    20 #define AKNSSRVUTILS_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <f32file.h>
       
    26 #include <badesca.h>
       
    27 
       
    28 #include <AknsPkgID.h>
       
    29 #include <AknsSrvSkinInformationPkg.h>
       
    30 #include "AknsSrvFileBuffer.h"
       
    31 #include "AknsDriveMaster.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 struct TAknsSrvDef;
       
    36 
       
    37 class CDRMHelper;
       
    38 class CDRMRights;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * Internal utility classfor skin server containing various utility functions.
       
    44 *
       
    45 * @since 2.0
       
    46 */
       
    47 class AknsSrvUtils
       
    48     {
       
    49 
       
    50     public: // New methods
       
    51         /**
       
    52         * Checks if supplied skin file is a A&H override variant.
       
    53         *
       
    54         * @since 2.0
       
    55         *
       
    56         * @param aFile File buffer to read.
       
    57         *
       
    58         * @return ETrue if the skin is A&H override variant, EFalse otherwise
       
    59         *
       
    60         * @par Exceptions:
       
    61         *   If check failed, function leaves with an error code.
       
    62         */
       
    63         static TBool CheckAHOverrideFlagL( CAknsSrvFileBuffer& aFile );
       
    64 
       
    65         /**
       
    66         * Looks for .skn files from specified directory.
       
    67         *
       
    68         * @since 2.0
       
    69         *
       
    70         * @param aBasePath The base path of the skin directory
       
    71         *
       
    72         * @param aDirName The directory name of the skin directory.
       
    73         *
       
    74         * @param aSkinFiles Array containing the actual skin filenames
       
    75         *   after a succesfull call.
       
    76         *
       
    77         * @par Exceptions:
       
    78         *     If function fails, leaves with an error code.
       
    79         */
       
    80         static void SearchSkinsL(
       
    81             RFs& aRfs, const TDesC& aBasePath, const TDesC& aDirName,
       
    82             CDesCArray* aSkinFiles );
       
    83 
       
    84         /**
       
    85         * Looks after skin directories under specified path
       
    86         *
       
    87         * @since 2.0
       
    88         *
       
    89         * @param aSkinfiles An array containing skin file directory names
       
    90         *   after a succesfull call.
       
    91         *
       
    92         * @par Exceptions:
       
    93         *   If the function fails, leaves with an error code.
       
    94         */
       
    95         static void SearchDirectoriesL( RFs& aRfs, const TDesC& aPath,
       
    96             CDesCArray* aSkinFiles );
       
    97 
       
    98         /**
       
    99         * Build skin information array containing skin information.
       
   100         *
       
   101         * @since 2.0
       
   102         *
       
   103         * @param aSkinInfo The array where skin information is stored.
       
   104         *
       
   105         * @param aSkinArray Array containing skin file names.
       
   106         *
       
   107         * @par Exceptions:
       
   108         *    if function fails, leaves with an error code.
       
   109         */
       
   110         static void BuildSkinInfoPackagesL(
       
   111             CArrayPtr<TAknsSrvSkinInfoPkg>* aSkinInfo,
       
   112             CDesCArray* aSkinArray, RFs& aFileSession,
       
   113             CDRMHelper& aDrmHelper );
       
   114 
       
   115         /**
       
   116         * Builds a single skin information package.
       
   117         */
       
   118         static TAknsSrvSkinInfoPkg* BuildSkinInfoPackageL(
       
   119             const TDesC& aFilename, CDRMHelper& aDrmHelper, RFs& aFileSession );
       
   120 
       
   121         /**
       
   122         * Gets the package ID of the skin.
       
   123         *
       
   124         * @since 2.0
       
   125         *
       
   126         * @param aFile Opened skin file.
       
   127         *
       
   128         * @return The package ID of the skin.
       
   129         *
       
   130         * @par Exceptions:
       
   131         *   If function failed, function leaves with an error code.
       
   132         */
       
   133         static TAknsPkgID GetSkinPIDL( CAknsSrvFileBuffer& aFile );
       
   134 
       
   135         /**
       
   136         * Gets the filename of the skin file, or A&H variant skin file
       
   137         *
       
   138         * @since 2.0
       
   139         *
       
   140         * @param aPath Skin file directory.
       
   141         *
       
   142         * @param aPID Packge ID of the skin
       
   143         *
       
   144         * @param aAHFlag ETrue if A&H skin filename is wanted, EFalse otherwise.
       
   145         *
       
   146         * @return The skin file name or NULL of no skin file was found
       
   147         *   in the specified directory
       
   148         *
       
   149         * @par Exceptions:
       
   150         *   If skin filename could not be fetched, leaves with an error code.
       
   151         */
       
   152         static HBufC* GetSkinFileNameL( const TDesC& aPath,
       
   153             const TAknsPkgID aPID, RFs& aFileSession );
       
   154 
       
   155         /**
       
   156         * Reads skin data to a buffer
       
   157         *
       
   158         * @since 2.0
       
   159         *
       
   160         * @param aFile File buffer to read.
       
   161         *
       
   162         * @param aOffset The file offset to read from.
       
   163         *
       
   164         * @param aCount The number of bytes to read.
       
   165         *
       
   166         * @return A buffer containing skin data which was read.
       
   167         *
       
   168         * @par Exceptions:
       
   169         *    If reading fails, leaves with an error code.
       
   170         */
       
   171         static TUint8* ReadSkinDescL(CAknsSrvFileBuffer& aFile,
       
   172             const TUint aOffset, const TUint aCount );
       
   173 
       
   174         /**
       
   175         * Gets a 32-bit integer value from a skin file.
       
   176         *
       
   177         * @since 2.0
       
   178         *
       
   179         * @param aFile File buffer to read.
       
   180         *
       
   181         * @param aOffset The offset to read from.
       
   182         *
       
   183         * @return An integer value which was read from the file
       
   184         *
       
   185         * @par Exceptions:
       
   186         *    If value couldn't be read, leaves with an error code.
       
   187         */
       
   188         static TInt32 GetInt32L(CAknsSrvFileBuffer& aFile, const TUint aOffset);
       
   189 
       
   190         /**
       
   191         * Gets a 16-bit unsigned integer value from a skin file.
       
   192         *
       
   193         * @since 2.0
       
   194         *
       
   195         * @param aFile File buffer to read.
       
   196         *
       
   197         * @param aOffset The offset to read from.
       
   198         *
       
   199         * @return An integer value which was read from the file.
       
   200         *
       
   201         * @par Exceptions:
       
   202         *    If value couldn't be read, leaves with an error code
       
   203         */
       
   204         static TUint16 GetUInt16L(CAknsSrvFileBuffer& aFile, const TUint aOffset);
       
   205 
       
   206         /**
       
   207         * Gets a 16-bit integer value from a skin file.
       
   208         *
       
   209         * @since 2.0
       
   210         *
       
   211         * @param aFile File buffer to read.
       
   212         *
       
   213         * @param aOffset The offset to read from.
       
   214         *
       
   215         * @return An integer value which was read from the file.
       
   216         *
       
   217         * @par Exceptions:
       
   218         *    If value couldn't be read, leaves with an error code
       
   219         */
       
   220         static TInt16 GetInt16L(CAknsSrvFileBuffer& aFile, const TUint aOffset);
       
   221 
       
   222         /**
       
   223         * Gets a 8-bit unsigned integer value from a skin file.
       
   224         *
       
   225         * @since 2.0
       
   226         *
       
   227         * @param aFile File buffer to read.
       
   228         *
       
   229         * @param aOffset The offset to read from.
       
   230         *
       
   231         * @return An integer value which was read from the file.
       
   232         *
       
   233         * @par Exceptions:
       
   234         *    If value couldn't be read, leaves with an error code
       
   235         */
       
   236         static TUint8 GetUInt8L(CAknsSrvFileBuffer& aFile, const TUint aOffset);
       
   237 
       
   238         /**
       
   239         * Get the skin name.
       
   240         *
       
   241         * @since 2.0
       
   242         *
       
   243         * @param aFile File buffer to read from.
       
   244         *
       
   245         * @return The name of the skin.
       
   246         *
       
   247         * @par Exceptions:
       
   248         *    If name couldn't be read leaves with an error code.
       
   249         */
       
   250         static HBufC* GetSkinNameL(CAknsSrvFileBuffer& aFile);
       
   251 
       
   252 
       
   253         /**
       
   254         * Checks whether the given file exists. Same as above, but
       
   255         * takes RFs as a parameter.
       
   256         *
       
   257         * @since 3.1
       
   258         *
       
   259         * @param aFileSession RFs reference.
       
   260         * @param aFilename Filename with full path.
       
   261         *
       
   262         * @return ETrue if the file exists, EFalse otherwise.
       
   263         */
       
   264         static TBool IsFile( RFs& aFileSession, const TDesC& aFilename );
       
   265 
       
   266         /**
       
   267         * Checks whether the given file is Drm-protected or not
       
   268         *
       
   269         * @since 2.6
       
   270         *
       
   271         * @param aFilename Filename with full path.
       
   272         *
       
   273         * @return ETrue if the file is protected, EFalse otherwise.
       
   274         */
       
   275         static TBool IsDrmProtectedL(const TDesC& aFilename);
       
   276         static TBool IsDrmProtectedL(RFile& aFileHandle);
       
   277 
       
   278         /**
       
   279         * Like above (@see SearchSkinsL), but searches for given extension.
       
   280         *
       
   281         * @since 3.1
       
   282         *
       
   283         * @param aBasePath The base path of the skin directory
       
   284         *
       
   285         * @param aDirName The directory name of the skin directory.
       
   286         *
       
   287         * @param sExtension The extension to look for.
       
   288         *
       
   289         * @param aSkinFiles Array containing the actual skin filenames
       
   290         *   after a succesfull call.
       
   291         *
       
   292         * @par Exceptions:
       
   293         *     If function fails, leaves with an error code.
       
   294         */
       
   295         static void SearchSkinsL(
       
   296             RFs& aRfs, const TDesC& aBasePath, const TDesC& aDirName,
       
   297             const TDesC& aExtension, CDesCArray* aSkinFiles );
       
   298 
       
   299         /**
       
   300         * Looks after skin directories under specified path
       
   301         *
       
   302         * @since 2.0
       
   303         *
       
   304         * @param aSkinfiles An array containing skin file directory names
       
   305         *   after a succesfull call.
       
   306         *
       
   307         * @param aExtension extension to look for.
       
   308         * @par Exceptions:
       
   309         *   If the function fails, leaves with an error code.
       
   310         */
       
   311         static void SearchDirectoriesL( RFs& aRfs, const TDesC& aPath,
       
   312             const TDesC& aExtension, CDesCArray* aSkinFiles );
       
   313 
       
   314         /**
       
   315         * Returns skin file name from a given drive.
       
   316         *
       
   317         * @since 5.0
       
   318         *
       
   319         * @param aDriveMaster reference to drive master.
       
   320         * @param aPID PID of a skin to look for.
       
   321         * @param aFileSession file server session.
       
   322         * @param aDriveType what type of drives to look from.
       
   323         *
       
   324         * @return filename of requested skin.
       
   325         */
       
   326         static HBufC* GetSkinFileNameL(
       
   327             CAknsSrvDriveMaster& aDriveMaster,
       
   328             const TAknsPkgID aPID,
       
   329             RFs& aFileSession,
       
   330             CAknsSrvDriveMaster::TAknsSrvSkinDriveList aDriveType );
       
   331 
       
   332         /**
       
   333         * Gets content URI from a given file.
       
   334         *
       
   335         * @since S60 v3.2
       
   336         *
       
   337         * @param aFilename Filename with full path.
       
   338         *
       
   339         * @return file's content URI.
       
   340         */
       
   341         static HBufC8* GetContentUriFromFileL( const TDesC& aFilename );
       
   342 
       
   343         /**
       
   344         * Gets protection type of the URI.
       
   345         *
       
   346         * @since S60 v3.2
       
   347         *
       
   348         * @param aManager DRM Rights manager.
       
   349         * @param aProtectionType protection type of the URI.
       
   350         */
       
   351         static void GetProtectionTypeL(
       
   352             const TDesC& aFilename,
       
   353             TAknsSkinSrvSkinProtectionType& aProtectionType );
       
   354 
       
   355         /**
       
   356         * Checks if a skin has mif file.
       
   357         *
       
   358         * @since S60 3.2
       
   359         *
       
   360         * @param aHasMifFile ETrue if mif file exists, otherwise EFalse.
       
   361         * @param aFileSession file server session.
       
   362         * @param aFilename Filename with full path.
       
   363         */
       
   364         static void SkinHasMifFileL( TBool& aHasMifFile,
       
   365             RFs& aFileSession, const TDesC& aFilename );
       
   366         
       
   367         /**
       
   368         * Get the skin anim background support.
       
   369         *
       
   370         * @since 9.2
       
   371         *
       
   372         * @param aFile File buffer to read from.
       
   373         *
       
   374         * @return ETrue:Support  EFalse: Not support.
       
   375         *
       
   376         * @par Exceptions:
       
   377         *    If name couldn't be read leaves with an error code.
       
   378         */        
       
   379         static TBool AnimBackgroundSupportL(CAknsSrvFileBuffer& aFile);
       
   380     };
       
   381 
       
   382 #endif
       
   383 
       
   384 // End of File