javamanager/javainstaller/installer/src.s60/iconconverter/iconconverter.h
changeset 21 2a9601315dfc
child 50 023eef975703
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 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:  Java Installer component iconconverter.
       
    15 *                Reads icon and .jar file and stores it a temp file in a
       
    16 *                format that can be shown by the S60 UI shell.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef ICONCONVERTER_H
       
    22 #define ICONCONVERTER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <fbs.h>
       
    26 #include <imageconversion.h>
       
    27 
       
    28 
       
    29 namespace java
       
    30 {
       
    31 
       
    32 NONSHARABLE_CLASS(CActiveListener) : public CActive
       
    33 {
       
    34 public:
       
    35     CActiveListener() : CActive(CActive::EPriorityIdle)
       
    36     {
       
    37         CActiveScheduler::Add(this);
       
    38     }
       
    39     void InitialiseActiveListener()
       
    40     {
       
    41         SetActive();
       
    42     }
       
    43     // From CActive
       
    44     virtual void RunL()
       
    45     {
       
    46         CActiveScheduler::Stop();
       
    47     }
       
    48     virtual void DoCancel() {};
       
    49 };
       
    50 
       
    51 
       
    52 /**
       
    53 * Reads the icon from specified .jar file, converts it to format
       
    54 * supported by S60 UI shell and returns it in a temporary file.
       
    55 *
       
    56 */
       
    57 NONSHARABLE_CLASS(CIconConverter) : public CBase
       
    58 {
       
    59 public:
       
    60 
       
    61     /**
       
    62      * NewL constructor
       
    63      * Constructs a new CIconConverter object
       
    64      *
       
    65      * @param[in] aFs file session
       
    66      * @return pointer to new IconConverter
       
    67      */
       
    68     static CIconConverter* NewL(RFs& aRFs);
       
    69 
       
    70     /**
       
    71      * Read iconFile in aJarFile, if it is SVG icon
       
    72      * use CMifConverter to convert it to MIF,
       
    73      * otherwise convert it to MBM,
       
    74      * store it to output file
       
    75      *
       
    76      * @param[in] aJarFile jar file that contains the icon
       
    77      * @param[in] aIconFile the path name of icon inside jar
       
    78      * @param[in] aOutputFile the name of the file where the converted icon
       
    79      *   must be stored to
       
    80      * @param[out] apWasMbm The value pointed by this parameter will be set to
       
    81      *   ETrue if the icon was converted to MBM, otherwise it is set to EFalse
       
    82      * @return Symbian error code in case of an error,
       
    83      *   KErrNone is conversion succeeds
       
    84      */
       
    85     int Convert(
       
    86         const TDesC &aJarFile,
       
    87         const TDesC &aIconFile,
       
    88         const TDesC &aOutputFile,
       
    89         TBool *apWasMbm);
       
    90 
       
    91     /**
       
    92      * Destroy the object and release all internal memory objects.
       
    93      * Does not close file session.
       
    94      */
       
    95     ~CIconConverter();
       
    96 
       
    97     /**
       
    98      * Logs the names of all MIME types that IconConverter supports
       
    99      * in the current device. Also the corresponding file extensions
       
   100      * are logged.
       
   101      */
       
   102     static void LogAllSupportedMimeTypes();
       
   103 
       
   104 private:
       
   105     /**
       
   106      * Constructor
       
   107      * Constructs a new CIconConverter object
       
   108      *
       
   109      * @param[in] aFs file session
       
   110      * @return pointer to new IconConverter
       
   111      */
       
   112     CIconConverter(RFs &aRFs);
       
   113 
       
   114     /**
       
   115      * Reads icon from .jar file and then based on the type of
       
   116      * icon calls either ConvertNormalIconL or
       
   117      * ConvertScalableIconL
       
   118      *
       
   119      * @param[in] aJarFile jar file that contains the icon
       
   120      * @param[in] aIconFile the path name of icon inside jar
       
   121      * @param[in] aOutputFile the name of the file where the converted icon
       
   122      *   must be stored to
       
   123      * @param[out] apWasMbm The value pointed by this parameter will be set to
       
   124      *   ETrue if the icon was converted to MBM, otherwise it is set to EFalse
       
   125      * @return Symbian error code in case of an error,
       
   126      *   KErrNone is conversion succeeds
       
   127      */
       
   128     int ConvertL(
       
   129         const TDesC &aJarFile,
       
   130         const TDesC &aIconFile,
       
   131         const TDesC &aOutputFile,
       
   132         TBool *apWasMbm);
       
   133 
       
   134     /**
       
   135      * Real implementation of Convert for normal icons.
       
   136      * Uses iImageDecoder to convert icon to mbm.
       
   137      *
       
   138      * @param[in] apIconBuf
       
   139      * @param[in] aptrIconBuf
       
   140      * @param[in] aOutputFile the name of the file where the converted icon
       
   141      *   must be stored to
       
   142      * @return Symbian error code in case of an error,
       
   143      *   KErrNone is conversion succeeds
       
   144      */
       
   145     int ConvertNormalIconL(
       
   146         HBufC8*      apIconBuf,
       
   147         TPtr8       &aptrIconBuf,
       
   148         const TDesC &aOutputFile);
       
   149 
       
   150     /**
       
   151      * Real implementation of Convert for scalable icons.
       
   152      * Uses CMifConverter to convert svg to mif
       
   153      *
       
   154      * @param[in] apIconBuf
       
   155      * @param[in] aOutputFile the name of the file where the converted icon
       
   156      *   must be stored to
       
   157      * @return Symbian error code in case of an error,
       
   158      *   KErrNone is conversion succeeds
       
   159      */
       
   160     int ConvertScalableIconL(
       
   161         HBufC8*      apIconBuf,
       
   162         const TDesC &aOutputFile);
       
   163 
       
   164 
       
   165 private:
       
   166     /**
       
   167      * File server session. Shared with the caller.
       
   168      * Do not close.
       
   169      */
       
   170     RFs iRFs;
       
   171 
       
   172     /**
       
   173      * Converts from any format supported by the conversion
       
   174      * plugins in the S60 system to bitmap.
       
   175      */
       
   176     CBufferedImageDecoder* iImageDecoder;
       
   177 
       
   178     /**
       
   179      * Pointer to bitmap generated from the icon
       
   180      */
       
   181     CFbsBitmap* iBitmap;
       
   182 
       
   183     /**
       
   184      * Pointer to the bitmap mask generated from the icon.
       
   185      * May be NULL if the original icon not not have mask.
       
   186      */
       
   187     CFbsBitmap* iBitmapMask;
       
   188 
       
   189     CActiveListener *iActiveListener;
       
   190 
       
   191 };
       
   192 
       
   193 } // namespace java
       
   194 
       
   195 #endif // ICONCONVERTER_H