webengine/widgetinstaller/Inc/WidgetInstaller.h
changeset 0 dd21522fd290
child 16 a359256acfc6
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2007 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 the License "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:  This file contains the header file of the WidgetInstaller class.
       
    15 *
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef WIDGETINSTALLER_H
       
    22 #define WIDGETINSTALLER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <WidgetRegistryClient.h>
       
    27 #ifdef _DEBUG
       
    28 #include <flogger.h>
       
    29 #endif
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CWidgetConfigHandler;
       
    33 class CWidgetRegistrationManager;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 /**
       
    37 * This class is provided for callback to notify icon conversion completion.
       
    38 * @lib WidgetInstallerUI.lib
       
    39 * @since 3.1
       
    40 */
       
    41 class MConverterController
       
    42     {
       
    43 public:
       
    44     /**
       
    45      * notify icon conversion completion
       
    46      */
       
    47     virtual void NotifyCompletionL( TInt aErr ) = 0;
       
    48     };
       
    49 
       
    50 /**
       
    51 * This class handles the install.
       
    52 *
       
    53 * @lib WidgetBackupRestore.exe
       
    54 * @since 3.1
       
    55 */
       
    56 NONSHARABLE_CLASS(CWidgetInstaller) : public CBase, MConverterController
       
    57     {
       
    58 public:  // Constructors and destructor
       
    59     /**
       
    60      * Two-phased constructor.
       
    61      */
       
    62     IMPORT_C static CWidgetInstaller* NewL();
       
    63 
       
    64     /**
       
    65      * Destructor.
       
    66      */
       
    67     virtual ~CWidgetInstaller();
       
    68 
       
    69 public: // New functions
       
    70     /**
       
    71      * Handle install request.
       
    72      * @since 3.1
       
    73      */
       
    74     IMPORT_C void InstallL( TDesC16& aRestoreDir );
       
    75 
       
    76     /**
       
    77      * Called when installation or update is finished,
       
    78      * do the final steps of registration, file clean up (remove
       
    79      * temporary files, display complete message.
       
    80      * Or handle error.
       
    81      */
       
    82     IMPORT_C void FinishInstallL( TInt aErr );
       
    83 
       
    84     /**
       
    85      * @since 3.2
       
    86      */
       
    87     IMPORT_C TInt RunError( TInt aError );
       
    88 
       
    89     /**
       
    90      * Rebuild registry properties (except UID) from installed widget dir.
       
    91      *
       
    92      * @param aFs: file session to use
       
    93      * @param aWidgetPath: path to main widget dir (icon path)
       
    94      * @param aLproj: language project name for localization (from registry)
       
    95      * @param aUid: the UID to assign to the widget
       
    96      * @since 5.0
       
    97      */
       
    98     IMPORT_C RPointerArray<CWidgetPropertyValue>* WidgetPropertiesFromInstalledWidgetL(
       
    99         RFs &aFs,
       
   100         const TDesC& aWidgetPath, /* should end with backslash */
       
   101         const TDesC& aLproj,
       
   102         TUid aUid );
       
   103 
       
   104     /**
       
   105      * If widget registry entry is assigned a new UID, then the
       
   106      * processed icon file (mbm file), if any, needs to be renamed
       
   107      * with the new UID.
       
   108      *
       
   109      * @param aFs: file session to use
       
   110      * @param aEntry: widget entry as stored in the registry
       
   111      * @since 5.0
       
   112      */
       
   113     IMPORT_C TInt RenameIconFile( RFs &aFs,
       
   114                                   RPointerArray<CWidgetPropertyValue>* aEntry );
       
   115 
       
   116     /**
       
   117      * @since 5.0
       
   118      */
       
   119     IMPORT_C void RegisterWidgetL( const TDesC& aMainHTML,
       
   120                                    const TDesC& aBundleDisplayName,
       
   121                                    const TDesC& aIconPath,
       
   122                                    const TDesC& aDriveName,
       
   123                                    const TUid& aUid );
       
   124 
       
   125     /**
       
   126      * @since 5.0
       
   127      */
       
   128     IMPORT_C void DeregisterWidgetL( const TUid& aUid );
       
   129 
       
   130 
       
   131 private:
       
   132     /**
       
   133      * C++ default constructor.
       
   134      * @param aRequestStatus - Status of the request.
       
   135      */
       
   136     CWidgetInstaller();
       
   137 
       
   138     /**
       
   139      * 2nd phase constructor.
       
   140      */
       
   141     void ConstructL();
       
   142 
       
   143     /**
       
   144      * Create widget entry by parsing the info.plist, insert the entry into the entry list
       
   145      * if the entry is not already existing.
       
   146      * @return the existed widget's index if already present
       
   147      * @since 3.1
       
   148      */
       
   149     TInt PreprocessWidgetBundleL( TDesC& aRestoreDir );
       
   150 
       
   151     void ProcessRestoreDirL( TDesC& aRestoreDir );
       
   152 
       
   153     /**
       
   154      * Set drive to C: to install/update the widget
       
   155      * @return true if no error, Leaves if drive space is not sufficient
       
   156      * @since 3.2
       
   157      */
       
   158     TBool SetDriveAndCheckSpaceL();
       
   159 
       
   160     /**
       
   161      * update basepath of widget
       
   162      * @since 3.2
       
   163      */
       
   164     void UpdateWidgetBasePathL( TDriveUnit& aDrive );
       
   165 
       
   166     /**
       
   167      * When overwriting an installed widget, backup so can restore on error
       
   168      * @since 3.2
       
   169      */
       
   170     void BackupL();
       
   171 
       
   172     /**
       
   173      * When overwriting an installed widget, restore on error
       
   174      * @since 3.2
       
   175      */
       
   176     void RestoreL();
       
   177 
       
   178     TInt DriveInfo( TInt aDrive, TInt64& aDiskSpace );
       
   179 
       
   180     /**
       
   181      * Return the name of file/dir found given path of dir to search in and search critiria.
       
   182      * @Since 3.2
       
   183 
       
   184      * @param aDir: in param, bundle ID, e.g. com.yahoo.local.widget.traffic
       
   185      * @param aFoundName: out param,
       
   186      */
       
   187     TInt SearchByExtL( const TDesC& aDir, TUint aSortKey, const TDesC& aExt, TFileName& aFoundName );
       
   188 
       
   189     TInt GetDirSizeL( const TDesC& aDir );
       
   190     
       
   191     /**
       
   192      * Return the name of dir which contains info.plist file.
       
   193      * 
       
   194 
       
   195      * @param aDir: in param, bundle ID, e.g. com.yahoo.local.widget.traffic
       
   196      * @param aFoundName: out param,
       
   197      */
       
   198     TInt SearchWidgetRootL( const TDesC& aDir, TFileName& aFoundName );
       
   199 
       
   200     /**
       
   201     * ConvertIconL
       
   202     * Specific to WidgetPreInstaller
       
   203     * converts Icon.png to mbm
       
   204     * @Since 5.0
       
   205     */
       
   206     void ConvertIconL( TUid& aUid, const TDesC& aIconPath );
       
   207 
       
   208 
       
   209 public: // From MConverterController
       
   210     /**
       
   211      * Used for notify icon convertion complete
       
   212      * @since 5.0
       
   213      */
       
   214     void NotifyCompletionL( TInt aErr ) ;
       
   215 
       
   216 private: // Data
       
   217 
       
   218     TBool iOverwriting;
       
   219 
       
   220     CFileMan* iFileMgr; // owned
       
   221     RFs iRfs; // owned
       
   222 
       
   223     RWidgetRegistryClientSession iRegistry;
       
   224     TBool iServerConnected; // to Widget Registry server
       
   225 
       
   226     CWidgetConfigHandler* iWidgetConfigHandler; // owned
       
   227     CWidgetRegistrationManager* iAppManager; // owned
       
   228 
       
   229     TFileName iOriginalDir; // for overwrite backup/restore
       
   230     TFileName iBackupDir; // for overwrite backup/restore
       
   231 
       
   232     TFileName iBundleRootName; // e.g. yahooTraffic.wdgt
       
   233 
       
   234     // these values mainly come from parsing bundle metadata file
       
   235     // (info.plist) and are passed to WidgetRegistry for registration.
       
   236     RPointerArray<CWidgetPropertyValue> iPropertyValues;
       
   237 
       
   238 #ifdef _DEBUG
       
   239     RFileLogger             iFileLogger;
       
   240     TBool                   iCanLog;
       
   241 #endif
       
   242     };
       
   243 
       
   244 #endif      // WIDGETINSTALLER_H
       
   245 
       
   246 // End of File