appinstaller/AppMngr2/Widget/src/appmngr2widgetruntime.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     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:   Widget runtime type for AppMngr2
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "appmngr2widgetruntime.h"      // CAppMngr2WidgetRuntime
       
    20 #include "appmngr2widgetappinfo.h"      // CAppMngr2WidgetAppInfo
       
    21 #include "appmngr2widgetpackageinfo.h"  // CAppMngr2WidgetPackageInfo
       
    22 #include "appmngr2recognizedfile.h"     // CAppMngr2RecognizedFile
       
    23 #include <appmngr2cleanuputils.h>       // CleanupResetAndDestroyPushL
       
    24 #include <data_caging_path_literals.hrh> // KDC_APP_BITMAP_DIR
       
    25 #include <apmrec.h>                     // CDataTypeArray
       
    26 #include <AknIconArray.h>               // CAknIconArray
       
    27 #include <AknsUtils.h>                  // AknsUtils
       
    28 #include <gulicon.h>                    // CGulIcon
       
    29 #include <eikenv.h>                     // CEikonEnv
       
    30 #include <appmngr2widget.mbg>           // icon IDs
       
    31 
       
    32 _LIT( KAppMngr2WidgetIconFileNameMif, "AppMngr2Widget.mif" );
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CAppMngr2WidgetRuntime::NewL()
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CAppMngr2WidgetRuntime* CAppMngr2WidgetRuntime::NewL( MAppMngr2RuntimeObserver& aObserver )
       
    42     {
       
    43     CAppMngr2WidgetRuntime* self = new (ELeave) CAppMngr2WidgetRuntime( aObserver );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CAppMngr2WidgetRuntime::~CAppMngr2WidgetRuntime()
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CAppMngr2WidgetRuntime::~CAppMngr2WidgetRuntime()
       
    55     {
       
    56     iWidgetRegistry.Disconnect();
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CAppMngr2WidgetRuntime::LoadIconsL()
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CAppMngr2WidgetRuntime::LoadIconsL( CAknIconArray& aIconArray )
       
    64     {
       
    65     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
    66     HBufC* iconFilePath = NULL;
       
    67     
       
    68     iconFilePath = FullBitmapFileNameLC( KAppMngr2WidgetIconFileNameMif );
       
    69 
       
    70     // Icon 0: Widget application icon, qgn_menu_am_widget
       
    71     CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance,
       
    72             KAknsIIDQgnMenuAmWidget, *iconFilePath,
       
    73             EMbmAppmngr2widgetQgn_menu_am_widget,
       
    74             EMbmAppmngr2widgetQgn_menu_am_widget_mask );
       
    75     CleanupStack::PushL( icon );
       
    76     aIconArray.AppendL( icon );
       
    77     CleanupStack::Pop( icon );
       
    78 
       
    79     CleanupStack::PopAndDestroy( iconFilePath );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CAppMngr2WidgetRuntime::GetSupportedDataTypesL()
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CAppMngr2WidgetRuntime::GetSupportedDataTypesL(
       
    87         CDataTypeArray& aDataTypeArray )
       
    88     {
       
    89     TDataType zipFile( KDataTypeWidget );
       
    90     aDataTypeArray.AppendL( zipFile );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CAppMngr2WidgetRuntime::GetInstallationFilesL()
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CAppMngr2WidgetRuntime::GetInstallationFilesL(
       
    98         RPointerArray<CAppMngr2PackageInfo>& aPackageInfos,
       
    99         const RPointerArray<CAppMngr2RecognizedFile>& aFileList,
       
   100         RFs& aFsSession, TRequestStatus& aStatus )
       
   101     {
       
   102     TInt fileCount = aFileList.Count();
       
   103     for( TInt index = 0; index < fileCount; index++ )
       
   104         {
       
   105         CAppMngr2RecognizedFile* file = aFileList[ index ];
       
   106         CAppMngr2WidgetPackageInfo* packageInfo = NULL;
       
   107         TRAPD( err, packageInfo = CAppMngr2WidgetPackageInfo::NewL( *this,
       
   108                 file->FileName(), aFsSession ) );
       
   109         if( err == KErrNone )
       
   110             {
       
   111             CleanupStack::PushL( packageInfo );
       
   112             aPackageInfos.AppendL( packageInfo );
       
   113             CleanupStack::Pop( packageInfo );
       
   114             }
       
   115         }
       
   116 
       
   117     TRequestStatus* status = &aStatus;
       
   118     User::RequestComplete( status, KErrNone );
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CAppMngr2WidgetRuntime::CancelGetInstallationFiles()
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CAppMngr2WidgetRuntime::CancelGetInstallationFiles()
       
   126     {
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CAppMngr2WidgetRuntime::GetInstalledAppsL()
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 void CAppMngr2WidgetRuntime::GetInstalledAppsL(
       
   134         RPointerArray<CAppMngr2AppInfo>& aApps,
       
   135         RFs& aFsSession, TRequestStatus& aStatus )
       
   136     {
       
   137     RWidgetInfoArray widgetInfoArray;
       
   138     CleanupResetAndDestroyPushL( widgetInfoArray );
       
   139     iWidgetRegistry.InstalledWidgetsL( widgetInfoArray );
       
   140 
       
   141     for( TInt index = 0; index < widgetInfoArray.Count(); index++ )
       
   142         {
       
   143         CAppMngr2WidgetAppInfo* appObj = NULL;
       
   144         TRAPD( err, appObj = CAppMngr2WidgetAppInfo::NewL( *this,
       
   145                 *( widgetInfoArray[ index ] ), aFsSession ) );
       
   146         if( err == KErrNone )
       
   147             {
       
   148             CleanupStack::PushL( appObj ); 
       
   149             aApps.Append( appObj );
       
   150             CleanupStack::Pop( appObj );
       
   151             }
       
   152         }
       
   153     
       
   154     CleanupStack::PopAndDestroy( &widgetInfoArray );
       
   155     
       
   156     TRequestStatus* status = &aStatus;
       
   157     User::RequestComplete( status, KErrNone );
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CAppMngr2WidgetRuntime::CancelGetInstalledApps()
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CAppMngr2WidgetRuntime::CancelGetInstalledApps()
       
   165     {
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // CAppMngr2WidgetRuntime::CAppMngr2WidgetRuntime()
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 CAppMngr2WidgetRuntime::CAppMngr2WidgetRuntime( MAppMngr2RuntimeObserver& aObserver )
       
   173         : CAppMngr2Runtime( aObserver ) 
       
   174     {
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // CAppMngr2WidgetRuntime::ConstructL()
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CAppMngr2WidgetRuntime::ConstructL()
       
   182     {
       
   183     User::LeaveIfError( iWidgetRegistry.Connect() );
       
   184     }
       
   185