widgets/widgetinstaller/src/WidgetInstallerUi.cpp
changeset 0 dd21522fd290
child 41 4bd5176e1bc8
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 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 CWidgetInstallerUI class.
       
    15 *
       
    16 *                This class implements the ECom SWInstUIPluginAPI interface
       
    17 *                for widget installation.
       
    18 *
       
    19 */
       
    20 
       
    21 #include <WidgetUI.rsg>
       
    22 #include <eikenv.h>
       
    23 #include <data_caging_path_literals.hrh>
       
    24 
       
    25 #include "CUIUtils.h"
       
    26 
       
    27 #include "WidgetInstallerUI.h"
       
    28 #include "WidgetUIOperationsWatcher.h"
       
    29 #include "BAUTILS.H"
       
    30 
       
    31 using namespace SwiUI;
       
    32 
       
    33 _LIT( KResourceFileName, "\\resource\\WidgetInstallerUI.rsc" );
       
    34 _LIT( KResourceDir, "Z:WidgetInstallerUI.rsc" );
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // ============================================================================
       
    39 // CWidgetInstallerUI::CWidgetInstallerUI
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 //
       
    43 // @since 3.1
       
    44 // ============================================================================
       
    45 //
       
    46 CWidgetInstallerUI::CWidgetInstallerUI()
       
    47     {
       
    48     }
       
    49 
       
    50 // ============================================================================
       
    51 // CWidgetInstallerUI::ConstructL
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 //
       
    54 // @since 3.1
       
    55 // ============================================================================
       
    56 //
       
    57 void CWidgetInstallerUI::ConstructL()
       
    58     {
       
    59  	CCoeEnv::Static()->DisableExitChecks( ETrue );
       
    60     TFileName resourceFileName;  
       
    61     TParse parse;    
       
    62     Dll::FileName (resourceFileName);           
       
    63     parse.Set(KResourceFileName, &resourceFileName, NULL); 
       
    64     resourceFileName = parse.FullName(); 
       
    65       
       
    66     CCoeEnv* coeEnv=CCoeEnv::Static(); 
       
    67     BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceFileName); 
       
    68    
       
    69     if ( !BaflUtils::FileExists( coeEnv->FsSession(), resourceFileName ) )           
       
    70         { 
       
    71         // Use resource file on the Z drive instead  
       
    72         parse.Set( KResourceDir, &KDC_RESOURCE_FILES_DIR, NULL ); 
       
    73         resourceFileName = parse.FullName();  
       
    74         BaflUtils::NearestLanguageFile( coeEnv->FsSession(),resourceFileName );            
       
    75         } 
       
    76     iResourceFileOffset = coeEnv->AddResourceFileL(resourceFileName);         
       
    77     }
       
    78 
       
    79 // ============================================================================
       
    80 // CWidgetInstallerUI::NewL
       
    81 // Two-phased constructor.
       
    82 //
       
    83 // @since 3.1
       
    84 // ============================================================================
       
    85 //
       
    86 CWidgetInstallerUI* CWidgetInstallerUI::NewL()
       
    87     {
       
    88     CWidgetInstallerUI* self = new( ELeave ) CWidgetInstallerUI();
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL();
       
    91     CleanupStack::Pop( self );
       
    92     return self;
       
    93     }
       
    94 
       
    95 // ============================================================================
       
    96 // CWidgetInstallerUI::~CWidgetInstallerUI
       
    97 // Destructor.
       
    98 //
       
    99 // @since 3.1
       
   100 // ============================================================================
       
   101 //
       
   102 CWidgetInstallerUI::~CWidgetInstallerUI()
       
   103     {
       
   104     delete iWatcher;
       
   105 
       
   106     if( iResourceFileOffset )
       
   107         {
       
   108         CEikonEnv::Static()->DeleteResourceFile( iResourceFileOffset );
       
   109         }
       
   110     }
       
   111 
       
   112 // ============================================================================
       
   113 // CWidgetInstallerUI::InstallL
       
   114 // Perform installation.
       
   115 // (other items were commented in a header).
       
   116 //
       
   117 // @since 3.1
       
   118 // ============================================================================
       
   119 //
       
   120 void CWidgetInstallerUI::InstallL( RFile& aFile,
       
   121                                    TInstallReq& aInstallParams,
       
   122                                    TBool /*aIsDRM*/,
       
   123                                    TRequestStatus& aStatus )
       
   124     {
       
   125     __ASSERT_ALWAYS( !iWatcher, User::Leave( KErrInUse ) );
       
   126     TRAPD( err ,
       
   127            iWatcher = CWidgetUIOperationsWatcher::NewL();
       
   128            iWatcher->InstallL( aFile, aInstallParams.iMIME, aStatus );
       
   129         );
       
   130     if ( KErrNone != err )
       
   131       {
       
   132         delete iWatcher;
       
   133         iWatcher = NULL;
       
   134         User::Leave( KErrGeneral );
       
   135       }
       
   136     }
       
   137 
       
   138 // ============================================================================
       
   139 // CWidgetInstallerUI::SilentInstallL
       
   140 // Perform silent installation.
       
   141 // (other items were commented in a header).
       
   142 //
       
   143 // @since 3.1
       
   144 // ============================================================================
       
   145 //
       
   146 void CWidgetInstallerUI::SilentInstallL( RFile& aFile,
       
   147                                          TInstallReq& aInstallParams,
       
   148                                          TBool /*aIsDRM*/,
       
   149                                          TInstallOptions& /*aOptions*/,
       
   150                                          TRequestStatus& aStatus )
       
   151     {
       
   152     __ASSERT_ALWAYS( !iWatcher, User::Leave( KErrInUse ) );
       
   153     TRAPD( err ,
       
   154            iWatcher = CWidgetUIOperationsWatcher::NewL();
       
   155            iWatcher->SilentInstallL( aFile, aInstallParams.iMIME, aStatus );
       
   156         );
       
   157     if ( KErrNone != err )
       
   158       {
       
   159         delete iWatcher;
       
   160         iWatcher = NULL;
       
   161         User::Leave( KErrGeneral );
       
   162       }
       
   163     }
       
   164 
       
   165 // ============================================================================
       
   166 // CWidgetInstallerUI::UninstallL
       
   167 // Perform uninstallation.
       
   168 // (other items were commented in a header).
       
   169 //
       
   170 // @since 3.1
       
   171 // ============================================================================
       
   172 //
       
   173 //
       
   174 void CWidgetInstallerUI::UninstallL( const TUid& aUid,
       
   175                                      const TDesC8& /*aMIME*/,
       
   176                                      TRequestStatus& aStatus )
       
   177     {
       
   178     __ASSERT_ALWAYS( !iWatcher, User::Leave( KErrInUse ) );
       
   179     TRAPD(err,
       
   180           iWatcher = CWidgetUIOperationsWatcher::NewL();
       
   181           iWatcher->UninstallL( aUid, aStatus );
       
   182         );
       
   183     if ( KErrNone != err )
       
   184       {
       
   185         delete iWatcher;
       
   186         iWatcher = NULL;
       
   187         User::Leave( KErrGeneral );
       
   188       }
       
   189     }
       
   190 
       
   191 // ============================================================================
       
   192 // CWidgetInstallerUI::SilentUninstallL
       
   193 // Perform silent uninstallation.
       
   194 // (other items were commented in a header).
       
   195 //
       
   196 // @since 3.1
       
   197 // ============================================================================
       
   198 //
       
   199 void CWidgetInstallerUI::SilentUninstallL( const TUid& aUid,
       
   200                                            const TDesC8& /*aMIME*/,
       
   201                                            TUninstallOptions& /*aOptions*/,
       
   202                                            TRequestStatus& aStatus )
       
   203     {
       
   204     __ASSERT_ALWAYS( !iWatcher, User::Leave( KErrInUse ) );
       
   205     TRAPD( err ,
       
   206            iWatcher = CWidgetUIOperationsWatcher::NewL();
       
   207            iWatcher->SilentUninstallL( aUid, aStatus );
       
   208         );
       
   209     if ( KErrNone != err )
       
   210       {
       
   211         delete iWatcher;
       
   212         iWatcher = NULL;
       
   213         User::Leave( KErrGeneral );
       
   214       }
       
   215     }
       
   216 
       
   217 // ============================================================================
       
   218 // CWidgetInstallerUI::IsAppShellUpdate
       
   219 // Indicates if the application shell must be updated.
       
   220 // (other items were commented in a header).
       
   221 //
       
   222 // @since 3.1
       
   223 // ============================================================================
       
   224 //
       
   225 TBool CWidgetInstallerUI::IsAppShellUpdate()
       
   226     {
       
   227     return ETrue;
       
   228     }
       
   229 
       
   230 // ============================================================================
       
   231 // CWidgetInstallerUI::Cancel()
       
   232 // Cancel the current operation.
       
   233 //
       
   234 // @since 3.1
       
   235 // ============================================================================
       
   236 //
       
   237 void CWidgetInstallerUI::Cancel()
       
   238     {
       
   239     delete iWatcher;
       
   240     iWatcher = NULL;
       
   241     }
       
   242 
       
   243 // ============================================================================
       
   244 // CWidgetInstallerUI::CompleteL
       
   245 // Informs the plugin about completed operation. Called when all tasks are
       
   246 // completed.
       
   247 //
       
   248 // @since 3.1
       
   249 // ============================================================================
       
   250 //
       
   251 void CWidgetInstallerUI::CompleteL()
       
   252     {
       
   253     delete iWatcher;
       
   254     iWatcher = NULL;
       
   255     }
       
   256 
       
   257 // ============================================================================
       
   258 // CWidgetInstallerUI::GetErrorDetails
       
   259 //
       
   260 // @since 3.1
       
   261 // ============================================================================
       
   262 //
       
   263 CErrDetails* CWidgetInstallerUI::GetErrorDetails()
       
   264     {
       
   265     return NULL;
       
   266     }
       
   267 
       
   268 // ============================================================================
       
   269 // CWidgetInstallerUI::CustomUninstallL
       
   270 // Perform a custom uninstallation.
       
   271 // @since 3.1
       
   272 // ============================================================================
       
   273 //
       
   274 void CWidgetInstallerUI::CustomUninstallL( TOperation /*aOperation*/,
       
   275                                   const TDesC8& /*aParams*/,
       
   276                                   TRequestStatus& /*aStatus*/ )
       
   277     {
       
   278     User::Leave( KErrNotSupported );
       
   279     }
       
   280 
       
   281 // ============================================================================
       
   282 // CWidgetInstallerUI::SilentCustomUninstallL
       
   283 // Perform a custom uninstallation.
       
   284 //
       
   285 // @since 3.1
       
   286 // ============================================================================
       
   287 //
       
   288 void CWidgetInstallerUI::SilentCustomUninstallL( TOperation /*aOperation*/,
       
   289                                         TUninstallOptions& /*aOptions*/,
       
   290                                         const TDesC8& /*aParams*/,
       
   291                                         TRequestStatus& /*aStatus*/ )
       
   292     {
       
   293     User::Leave( KErrNotSupported );
       
   294     }
       
   295 
       
   296 
       
   297 //  End of File