javamanager/javasettings/appmngrplugin/src/appmngr2midletappinfo.cpp
branchRCL_3
changeset 14 04becd199f91
child 23 e5618cc85d74
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008-2010 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:  MidletAppInfo implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <caf/caf.h>                    // ContentAccess::CContent
       
    20 #include <AknsUtils.h>                  // AknsUtils
       
    21 #include <eikenv.h>                     // CEikonEnv
       
    22 #include <eikappui.h>                   // CEikAppUi
       
    23 #include <aknViewAppUi.h>               // CAknViewAppUi
       
    24 #include <gulicon.h>                    // CGulIcon
       
    25 #include <browserlauncher.h>            // CBrowserLauncher
       
    26 #include <javaregistryincludes.h>       // JavaRegistry
       
    27 #include <x509certchain.h>              // CX509CertChain
       
    28 #include <imcvcodc.h>                   // TImCodecB64
       
    29 
       
    30 #include <appmngr2driveutils.h>         // TAppMngr2DriveUtils
       
    31 #include <appmngr2drmutils.h>           // TAppMngr2DRMUtils
       
    32 #include <appmngr2cleanuputils.h>       // CleanupResetAndDestroyPushL
       
    33 
       
    34 #include <javaapplicationsettings.rsg>           // Midlet resource IDs
       
    35 #include "appmngr2midletappinfo.h"      // CAppMngr2MidletAppInfo
       
    36 #include "appmngr2midletruntime.h"      // KAppMngr2MidletUid
       
    37 #include "javaapplicationsettings.hrh"           // Midlet command IDs
       
    38 #include "appmngr2midletinfoiterator.h" // CAppMngr2MidletInfoIterator
       
    39 #include "appmngr2midletsettingsview.h" // CAppMngr2MidletSettingsView
       
    40 #include "appmngr2midletsettingshandler.h" // CAppMngr2MidletSettingsHandler
       
    41 #include "appmngr2midletresourcehandler.h" // CAppMngr2MidletResourceHandler
       
    42 
       
    43 #include "appmngr2midletstorageutil.h"  // Storage util
       
    44 #include "exceptionbase.h"              // java::util::ExceptionBase exception.
       
    45 #include "logger.h"                     // LOG
       
    46 #include "securitystoragedatadefs.h"
       
    47 
       
    48 
       
    49 // Parameter that is passed to command line when launching Browser.
       
    50 // 4 - Start/Continue the browser specifying a URL
       
    51 _LIT(KBrowserStartContinueParam, "4 ");
       
    52 
       
    53 // MIDlet suite attributes
       
    54 _LIT(KMIDletDataSize, "MIDlet-Data-Size");
       
    55 _LIT(KMIDletDescription, "MIDlet-Description");
       
    56 _LIT(KMIDletInfoURL, "MIDlet-Info-URL");
       
    57 _LIT(KNokiaUpdateUrl, "Nokia-Update-URL");
       
    58 _LIT(KNokiaUpdate, "Nokia-Update");
       
    59 _LIT(KMIDletPermissions, "MIDlet-Permissions");
       
    60 _LIT(KNokiaMIDletName, "Nokia-MIDlet-Localized-Name");
       
    61 _LIT(KNokiaMIDletN, "Nokia-MIDlet-Localized-");
       
    62 
       
    63 _LIT(KListSeparatorAndSpace, ", ");
       
    64 
       
    65 // ======== MEMBER FUNCTIONS ========
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CAppMngr2MidletAppInfo::NewL()
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 CAppMngr2MidletAppInfo* CAppMngr2MidletAppInfo::NewL(
       
    72     CAppMngr2Runtime& aRuntime,
       
    73     Java::CJavaRegistryPackageEntry* aEntry,
       
    74     RFs& aFs,
       
    75     CAppMngr2MidletResourceHandler& aResourceHandler)
       
    76 {
       
    77     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::NewL");
       
    78     CAppMngr2MidletAppInfo* self
       
    79     = CAppMngr2MidletAppInfo::NewLC(aRuntime, aEntry, aFs, aResourceHandler);
       
    80     CleanupStack::Pop(self);
       
    81     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::NewL");
       
    82     return self;
       
    83 }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CAppMngr2MidletAppInfo::NewLC()
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CAppMngr2MidletAppInfo* CAppMngr2MidletAppInfo::NewLC(
       
    90     CAppMngr2Runtime& aRuntime,
       
    91     Java::CJavaRegistryPackageEntry* aEntry,
       
    92     RFs& aFs,
       
    93     CAppMngr2MidletResourceHandler& aResourceHandler)
       
    94 {
       
    95     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::NewLC");
       
    96     CAppMngr2MidletAppInfo* self
       
    97     = new(ELeave) CAppMngr2MidletAppInfo(aRuntime, aFs, aResourceHandler);
       
    98     CleanupStack::PushL(self);
       
    99     self->ConstructL(aEntry);
       
   100     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::NewLC");
       
   101     return self;
       
   102 }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CAppMngr2MidletAppInfo::~CAppMngr2MidletAppInfo()
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 CAppMngr2MidletAppInfo::~CAppMngr2MidletAppInfo()
       
   109 {
       
   110     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::~CAppMngr2MidletAppInfo");
       
   111 
       
   112     CAknViewAppUi* appUi
       
   113     = static_cast<CAknViewAppUi*>(CEikonEnv::Static()->EikAppUi());
       
   114     appUi->RemoveView(KMidletSuiteSettingsViewId);
       
   115 
       
   116     CancelCommand();
       
   117 
       
   118     delete iEntry;
       
   119     iEntry = NULL;
       
   120 
       
   121     delete iJarPath;
       
   122     iJarPath = NULL;
       
   123 
       
   124     delete iJadPath;
       
   125     iJadPath = NULL;
       
   126 
       
   127     delete iDetails;
       
   128     iDetails = NULL;
       
   129 
       
   130     delete iVersion;
       
   131     iVersion = NULL;
       
   132 
       
   133     delete iMimeType;
       
   134     iMimeType = NULL;
       
   135 
       
   136     delete iDataSize;
       
   137     iDataSize = NULL;
       
   138 
       
   139     delete iDescription;
       
   140     iDescription = NULL;
       
   141 
       
   142     delete iInfoUrl;
       
   143     iInfoUrl = NULL;
       
   144 
       
   145     delete iUpdateUrl;
       
   146     iUpdateUrl = NULL;
       
   147 
       
   148     delete iLocalizedMIDletName;
       
   149     iLocalizedMIDletName = NULL;
       
   150 
       
   151     delete iContent;
       
   152     iContent = NULL;
       
   153 
       
   154     delete iPermissions;
       
   155     iPermissions = NULL;
       
   156 
       
   157     delete iAppBitmap;
       
   158     iAppBitmap = NULL;
       
   159 
       
   160     delete iAppMask;
       
   161     iAppMask = NULL;
       
   162 
       
   163     delete iInfoIterator;
       
   164     iInfoIterator = NULL;
       
   165 
       
   166     iCertificates.ResetAndDestroy();
       
   167 
       
   168     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::~CAppMngr2MidletAppInfo");
       
   169 }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CAppMngr2MidletAppInfo::IconIndex()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 TInt CAppMngr2MidletAppInfo::IconIndex() const
       
   176 {
       
   177     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::IconIndex");
       
   178     if (iAppBitmap && iAppMask)
       
   179     {
       
   180         return EAppMngr2UseSpecificIcon;
       
   181     }
       
   182     return 0;   // Icon 0: qgn_menu_am_midlet
       
   183 }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // CAppMngr2MidletAppInfo::SpecificIconL()
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 CGulIcon* CAppMngr2MidletAppInfo::SpecificIconL() const
       
   190 {
       
   191     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::SpecificIconL");
       
   192     CGulIcon* icon = CGulIcon::NewL(iAppBitmap, iAppMask);
       
   193     icon->SetBitmapsOwnedExternally(ETrue);
       
   194     return icon;
       
   195 }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CAppMngr2MidletAppInfo::Name()
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 const TDesC& CAppMngr2MidletAppInfo::Name() const
       
   202 {
       
   203     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Name");
       
   204     return *iLocalizedMIDletName;
       
   205 }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // CAppMngr2MidletAppInfo::Details()
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 const TDesC& CAppMngr2MidletAppInfo::Details() const
       
   212 {
       
   213     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Details");
       
   214     if (iDetails)
       
   215     {
       
   216         return *iDetails;
       
   217     }
       
   218     return KNullDesC;
       
   219 }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CAppMngr2MidletAppInfo::IndicatorIconIndex()
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 TInt CAppMngr2MidletAppInfo::IndicatorIconIndex() const
       
   226 {
       
   227     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::IndicatorIconIndex");
       
   228     if (iLocation == EAppMngr2LocationMemoryCard)
       
   229     {
       
   230         return EAppMngr2IconQgnIndiAmInstMmcAdd;
       
   231     }
       
   232     if (iLocation == EAppMngr2LocationMassStorage)
       
   233     {
       
   234         return EAppMngr2IconQgnIndiFmgrMsAdd;
       
   235     }
       
   236     return EAppMngr2NoIndicatorIcon;
       
   237 }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CAppMngr2MidletAppInfo::GetMenuItemsL()
       
   241 // ---------------------------------------------------------------------------
       
   242 //
       
   243 void CAppMngr2MidletAppInfo::GetMenuItemsL(
       
   244     RPointerArray<CEikMenuPaneItem::SData>& aMenuCmds)
       
   245 {
       
   246     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::GetMenuItemsL");
       
   247     TInt resourceOffset = iResourceHandler.AddResourceFileL();
       
   248     CEikMenuPaneItem::SData* menuItemData = new(ELeave) CEikMenuPaneItem::SData;
       
   249     CleanupStack::PushL(menuItemData);
       
   250     ReadMenuItemDataFromResourceL(MIDLET_SUITE_SETTINGS_MENU_ITEM, *menuItemData);
       
   251     aMenuCmds.AppendL(menuItemData);
       
   252     CleanupStack::Pop(menuItemData);
       
   253 
       
   254     if (InfoIteratorL().GetUpdateUrlL() != KNullDesC)
       
   255     {
       
   256         menuItemData = new(ELeave) CEikMenuPaneItem::SData;
       
   257         CleanupStack::PushL(menuItemData);
       
   258         ReadMenuItemDataFromResourceL(MIDLET_START_UPDATE_MENU_ITEM, *menuItemData);
       
   259         aMenuCmds.AppendL(menuItemData);
       
   260         CleanupStack::Pop(menuItemData);
       
   261     }
       
   262 
       
   263     if (InfoIteratorL().GetInfoUrlL() != KNullDesC)
       
   264     {
       
   265         menuItemData = new(ELeave) CEikMenuPaneItem::SData;
       
   266         CleanupStack::PushL(menuItemData);
       
   267         ReadMenuItemDataFromResourceL(MIDLET_GOTO_URL_MENU_ITEM, *menuItemData);
       
   268         aMenuCmds.AppendL(menuItemData);
       
   269         CleanupStack::Pop(menuItemData);
       
   270     }
       
   271     if (resourceOffset > 0)
       
   272     {
       
   273         iResourceHandler.DeleteResourceFile(resourceOffset);
       
   274     }
       
   275     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::GetMenuItemsL");
       
   276 }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CAppMngr2MidletAppInfo::SupportsGenericCommand()
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 TBool CAppMngr2MidletAppInfo::SupportsGenericCommand(TInt /*aCmdId*/)
       
   283 {
       
   284     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::SupportsGenericCommand");
       
   285     return ETrue;
       
   286 }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CAppMngr2MidletAppInfo::HandleCommandL()
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 void CAppMngr2MidletAppInfo::HandleCommandL(
       
   293     TInt aCommandId, TRequestStatus& aStatus)
       
   294 {
       
   295     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::HandleCommandL");
       
   296     switch (aCommandId)
       
   297     {
       
   298     case EAppMngr2CmdViewDetails:
       
   299     {
       
   300         ShowDetailsL();
       
   301         TRequestStatus* status = &aStatus;
       
   302         User::RequestComplete(status, KErrNone);
       
   303         break;
       
   304     }
       
   305     case EAppMngr2CmdUninstall:
       
   306     {
       
   307         UninstallL(aStatus);
       
   308         break;
       
   309     }
       
   310     case EAppMngrCmdSetSuiteSettings:
       
   311     {
       
   312         ShowSettingsL();
       
   313         TRequestStatus* status = &aStatus;
       
   314         User::RequestComplete(status, KErrNone);
       
   315         break;
       
   316     }
       
   317     case EAppMngrCmdStartUpdate:
       
   318     {
       
   319         UpdateL();
       
   320         TRequestStatus* status = &aStatus;
       
   321         User::RequestComplete(status, KErrNone);
       
   322         break;
       
   323     }
       
   324     case EAppMngrCmdGoToUrl:
       
   325     {
       
   326         ShowInfoUrlL();
       
   327         TRequestStatus* status = &aStatus;
       
   328         User::RequestComplete(status, KErrNone);
       
   329         break;
       
   330     }
       
   331     default:
       
   332     {
       
   333         // Uknown command
       
   334         TRequestStatus* status = &aStatus;
       
   335         User::RequestComplete(status, KErrNotSupported);
       
   336         break;
       
   337     }
       
   338     }
       
   339     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::HandleCommandL");
       
   340 }
       
   341 
       
   342 // ---------------------------------------------------------------------------
       
   343 // CAppMngr2MidletAppInfo::HandleCommandResultL()
       
   344 // ---------------------------------------------------------------------------
       
   345 //
       
   346 void CAppMngr2MidletAppInfo::HandleCommandResultL(TInt /*aStatus*/)
       
   347 {
       
   348     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::HandleCommandResultL");
       
   349     if (iSWInstLauncher)
       
   350     {
       
   351         iSWInstLauncher->Close();
       
   352         delete iSWInstLauncher;
       
   353         iSWInstLauncher = NULL;
       
   354     }
       
   355     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::HandleCommandResultL");
       
   356 }
       
   357 
       
   358 // ---------------------------------------------------------------------------
       
   359 // CAppMngr2MidletAppInfo::CancelCommand()
       
   360 // ---------------------------------------------------------------------------
       
   361 //
       
   362 void CAppMngr2MidletAppInfo::CancelCommand()
       
   363 {
       
   364     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::CancelCommand");
       
   365     if (iSWInstLauncher)
       
   366     {
       
   367         iSWInstLauncher->CancelAsyncRequest(SwiUI::ERequestUninstall);
       
   368         iSWInstLauncher->Close();
       
   369         delete iSWInstLauncher;
       
   370         iSWInstLauncher = NULL;
       
   371     }
       
   372     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::CancelCommand");
       
   373 }
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // CAppMngr2MidletAppInfo::HandleContentL()
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 TBool CAppMngr2MidletAppInfo::HandleContentL(
       
   380     const TDesC& /*aFileName*/,
       
   381     const CAiwGenericParamList& /*aParamList*/,
       
   382     TBool& /*aContinue */)
       
   383 {
       
   384     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::HandleContentL");
       
   385     return EFalse;
       
   386 }
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CAppMngr2MidletAppInfo::HandleDownloadedContentHandlerReserved1()
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 TAny* CAppMngr2MidletAppInfo::DownloadedContentHandlerReserved1(
       
   393     TAny* /*aAnyParam*/)
       
   394 {
       
   395     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngrMidletAppInfo::DownloadedContentHandlerReserved1");
       
   396     return NULL;
       
   397 }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // CAppMngr2MidletAppInfo::JarFileName()
       
   401 // ---------------------------------------------------------------------------
       
   402 //
       
   403 const TDesC& CAppMngr2MidletAppInfo::JarFileName() const
       
   404 {
       
   405     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::JarFileName");
       
   406     if (iJarPath)
       
   407     {
       
   408         return *iJarPath;
       
   409     }
       
   410     return KNullDesC;
       
   411 }
       
   412 
       
   413 // ---------------------------------------------------------------------------
       
   414 // CAppMngr2MidletAppInfo::JadFileName()
       
   415 // ---------------------------------------------------------------------------
       
   416 //
       
   417 const TDesC& CAppMngr2MidletAppInfo::JadFileName() const
       
   418 {
       
   419     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::JadFileName");
       
   420     if (iJadPath)
       
   421     {
       
   422         return *iJadPath;
       
   423     }
       
   424     return KNullDesC;
       
   425 }
       
   426 
       
   427 // ---------------------------------------------------------------------------
       
   428 // CAppMngr2MidletAppInfo::MimeType()
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 const TDesC8& CAppMngr2MidletAppInfo::MimeType() const
       
   432 {
       
   433     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::MimeType");
       
   434     if (iMimeType)
       
   435     {
       
   436         return *iMimeType;
       
   437     }
       
   438     return KNullDesC8;
       
   439 }
       
   440 
       
   441 // ---------------------------------------------------------------------------
       
   442 // CAppMngr2MidletAppInfo::Version()
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 const TDesC& CAppMngr2MidletAppInfo::Version() const
       
   446 {
       
   447     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Version");
       
   448     if (iVersion)
       
   449     {
       
   450         return *iVersion;
       
   451     }
       
   452     return KNullDesC;
       
   453 }
       
   454 
       
   455 // ---------------------------------------------------------------------------
       
   456 // CAppMngr2MidletAppInfo::Vendor()
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 const TDesC& CAppMngr2MidletAppInfo::Vendor() const
       
   460 {
       
   461     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Vendor");
       
   462     return iEntry->Vendor();
       
   463 }
       
   464 
       
   465 // ---------------------------------------------------------------------------
       
   466 // CAppMngr2MidletAppInfo::SecurityDomainCategory()
       
   467 // ---------------------------------------------------------------------------
       
   468 //
       
   469 const std::wstring CAppMngr2MidletAppInfo::SecurityDomainCategory() const
       
   470 {
       
   471     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletAppInfo::MidletSuiteSecurityDomainCategory ");
       
   472     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletAppInfo::MidletSuiteSecurityDomainCategory ");
       
   473     return iSecurityDomainCategory;
       
   474 }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // CAppMngr2MidletAppInfo::SecurityDomainName()
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 const std::wstring CAppMngr2MidletAppInfo::SecurityDomainName() const
       
   481 {
       
   482     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletAppInfo::MidletSuiteSecurityDomainName ");
       
   483     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletAppInfo::MidletSuiteSecurityDomainName ");
       
   484     return iSecurityDomainName;
       
   485 }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // CAppMngr2MidletAppInfo::()
       
   489 // ---------------------------------------------------------------------------
       
   490 //
       
   491 const TDesC& CAppMngr2MidletAppInfo::DataSize() const
       
   492 {
       
   493     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::DataSize");
       
   494     if (iDataSize)
       
   495     {
       
   496         return *iDataSize;
       
   497     }
       
   498     return KNullDesC;
       
   499 }
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 // CAppMngr2MidletAppInfo::Description()
       
   503 // ---------------------------------------------------------------------------
       
   504 //
       
   505 const TDesC& CAppMngr2MidletAppInfo::Description() const
       
   506 {
       
   507     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Description");
       
   508     if (iDescription)
       
   509     {
       
   510         return *iDescription;
       
   511     }
       
   512     return KNullDesC;
       
   513 }
       
   514 
       
   515 // ---------------------------------------------------------------------------
       
   516 // CAppMngr2MidletAppInfo::InfoUrl()
       
   517 // ---------------------------------------------------------------------------
       
   518 //
       
   519 const TDesC& CAppMngr2MidletAppInfo::InfoUrl() const
       
   520 {
       
   521     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::InfoUrl");
       
   522     if (iInfoUrl)
       
   523     {
       
   524         return *iInfoUrl;
       
   525     }
       
   526     return KNullDesC;
       
   527 }
       
   528 
       
   529 // ---------------------------------------------------------------------------
       
   530 // CAppMngr2MidletAppInfo::UpdateUrl()
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 const TDesC& CAppMngr2MidletAppInfo::UpdateUrl() const
       
   534 {
       
   535     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::UpdateUrl");
       
   536     if (iUpdateUrl)
       
   537     {
       
   538         return *iUpdateUrl;
       
   539     }
       
   540     return KNullDesC;
       
   541 }
       
   542 
       
   543 // ---------------------------------------------------------------------------
       
   544 // CAppMngr2MidletAppInfo::Content()
       
   545 // ---------------------------------------------------------------------------
       
   546 //
       
   547 const TDesC& CAppMngr2MidletAppInfo::Content() const
       
   548 {
       
   549     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Content");
       
   550     if (iContent)
       
   551     {
       
   552         return *iContent;
       
   553     }
       
   554     return KNullDesC;
       
   555 }
       
   556 
       
   557 // ---------------------------------------------------------------------------
       
   558 // CAppMngr2MidletAppInfo::Permissions()
       
   559 // ---------------------------------------------------------------------------
       
   560 //
       
   561 const TDesC& CAppMngr2MidletAppInfo::Permissions() const
       
   562 {
       
   563     LOG(EJavaAppMngrPlugin, EInfo, "CAppMngr2MidletAppInfo::Permissions");
       
   564     if (iPermissions)
       
   565     {
       
   566         return *iPermissions;
       
   567     }
       
   568     return KNullDesC;
       
   569 }
       
   570 
       
   571 // ---------------------------------------------------------------------------
       
   572 // CAppMngr2MidletAppInfo::CAppMngr2MidletAppInfo()
       
   573 // ---------------------------------------------------------------------------
       
   574 //
       
   575 CAppMngr2MidletAppInfo::CAppMngr2MidletAppInfo(CAppMngr2Runtime& aRuntime,
       
   576         RFs& aFsSession, CAppMngr2MidletResourceHandler& aResourceHandler) : CAppMngr2AppInfo(aRuntime, aFsSession), iResourceHandler(aResourceHandler)
       
   577 {
       
   578 }
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 // CAppMngr2MidletAppInfo::ConstructL()
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 void CAppMngr2MidletAppInfo::ConstructL(
       
   585     Java::CJavaRegistryPackageEntry* aEntry)
       
   586 {
       
   587     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ConstructL");
       
   588     CAppMngr2AppInfo::ConstructL();
       
   589 
       
   590     iEntry = aEntry;
       
   591 
       
   592     std::auto_ptr<AppMngr2MidletStorageUtil>storageUtils(
       
   593         new AppMngr2MidletStorageUtil());
       
   594     storageUtils->populateSuiteInformation(iEntry->Uid());
       
   595 
       
   596     _LIT(KJarPath, "JAR_PATH");
       
   597     _LIT(KJadPath, "JAD_PATH");
       
   598 
       
   599     try
       
   600     {
       
   601         iJarPath = storageUtils->attribute(KJarPath);    // Ownership taken.
       
   602         iJadPath = storageUtils->attribute(KJadPath);    // Ownership taken.
       
   603     }
       
   604     catch (java::util::ExceptionBase)
       
   605     {
       
   606         User::Leave(KErrNoMemory);
       
   607     }
       
   608 
       
   609     iDetails = SizeStringWithUnitsL(iEntry->UsedUserDiskSpace());
       
   610 
       
   611     iLocation = TAppMngr2DriveUtils::LocationFromFileNameL(*iJarPath, iFs);
       
   612     iLocationDrive = TDriveUnit(*iJarPath);
       
   613 
       
   614     // Version
       
   615     TAppVersion ver = iEntry->Version();
       
   616     TVersion verType(ver.iMajor, ver.iMinor, ver.iBuild);
       
   617     iVersion = verType.Name().AllocL();
       
   618 
       
   619     // MIME type - AllFiles capability required.
       
   620     HBufC* mimeType = HBufC::NewLC(KMaxDataTypeLength);
       
   621     ContentAccess::CContent* pkgContent
       
   622     = ContentAccess::CContent::NewLC(iJarPath->Des(),
       
   623                                      ContentAccess::EContentShareReadOnly);
       
   624     TPtr mimePtr(mimeType->Des());
       
   625     pkgContent->GetStringAttribute(ContentAccess::EMimeType, mimePtr);
       
   626     CleanupStack::PopAndDestroy(pkgContent);
       
   627     iMimeType = HBufC8::NewL(mimeType->Length());
       
   628     iMimeType->Des().Copy(*mimeType);
       
   629     CleanupStack::PopAndDestroy(mimeType);
       
   630 
       
   631     // Data size
       
   632     const Java::MJavaAttribute* attribute
       
   633     = iEntry->AttributeL(KMIDletDataSize()); // no ownership
       
   634     if (attribute)
       
   635     {
       
   636         iDataSize = attribute->Value().AllocL();
       
   637     }
       
   638     // Description
       
   639     delete attribute;
       
   640     attribute = aEntry->AttributeL(KMIDletDescription()); // no ownership
       
   641     if (attribute)
       
   642     {
       
   643         iDescription = attribute->Value().AllocL();
       
   644     }
       
   645     // Info URL
       
   646     delete attribute;
       
   647     attribute = aEntry->AttributeL(KMIDletInfoURL()); // no ownership
       
   648     if (attribute)
       
   649     {
       
   650         iInfoUrl = attribute->Value().AllocL();
       
   651     }
       
   652     // Update URL
       
   653     delete attribute;
       
   654     attribute = aEntry->AttributeL(KNokiaUpdate()); // no ownership
       
   655     if (attribute)
       
   656     {
       
   657         iUpdateUrl = attribute->Value().AllocL();
       
   658     }
       
   659     else
       
   660     {
       
   661         attribute = aEntry->AttributeL(KNokiaUpdateUrl()); // no ownership
       
   662         if (attribute)
       
   663         {
       
   664             iUpdateUrl = attribute->Value().AllocL();
       
   665         }
       
   666     }
       
   667     delete attribute;
       
   668     // Use localized midlet suite name if it exists
       
   669     attribute = aEntry->AttributeL(KNokiaMIDletName()); // no ownership
       
   670     if (attribute)
       
   671     {
       
   672         iLocalizedMIDletName = attribute->Value().AllocL();
       
   673     }
       
   674     else
       
   675     {
       
   676         // Use non-localized name
       
   677         iLocalizedMIDletName = aEntry->Name().AllocL();
       
   678     }
       
   679     delete attribute;
       
   680 
       
   681     RArray<TUid> midletUids;
       
   682     CleanupClosePushL(midletUids);
       
   683     iEntry->GetEmbeddedEntries(midletUids);
       
   684 
       
   685 
       
   686     // Content
       
   687     TBuf<50> attributeName;
       
   688     TInt contentLength(0);
       
   689     // Count length for content descriptor
       
   690     for (TInt i(0); i < midletUids.Count(); i++)
       
   691     {
       
   692         // Localized MIDlet name
       
   693         attributeName = KNokiaMIDletN();
       
   694         attributeName.AppendNum((i+1));
       
   695         attribute = aEntry->AttributeL(attributeName);
       
   696         if (attribute)
       
   697         {
       
   698             contentLength += attribute->Value().Length();
       
   699             delete attribute;
       
   700         }
       
   701         else
       
   702         {
       
   703             // Non-localized MIDlet name
       
   704             Java::CJavaRegistryApplicationEntry* midlet
       
   705             = (Java::CJavaRegistryApplicationEntry*) iEntry->EmbeddedEntryByNumberL(i);
       
   706             if (midlet)
       
   707             {
       
   708                 CleanupStack::PushL(midlet);
       
   709                 contentLength += midlet->Name().Length();
       
   710                 CleanupStack::PopAndDestroy(midlet);
       
   711             }
       
   712         }
       
   713         contentLength += KListSeparatorAndSpace().Length();
       
   714     }
       
   715 
       
   716     LOG1(EJavaAppMngrPlugin, EInfo, "contentLength is %d", contentLength);
       
   717 
       
   718     // Create content descriptor
       
   719     iContent = HBufC::NewL(contentLength);
       
   720 
       
   721     // Fill content descriptor
       
   722     TPtr ptrContent = iContent->Des();
       
   723     for (TInt i(0); i < midletUids.Count(); i++)
       
   724     {
       
   725         attributeName = KNokiaMIDletN();
       
   726         attributeName.AppendNum((i+1));
       
   727         attribute = aEntry->AttributeL(attributeName);
       
   728         if (attribute)
       
   729         {
       
   730             // Localized MIDlet name
       
   731             if (ptrContent == KNullDesC)
       
   732             {
       
   733                 ptrContent.Append(attribute->Value());
       
   734             }
       
   735             else
       
   736             {
       
   737                 ptrContent.Append(KListSeparatorAndSpace);
       
   738                 ptrContent.Append(attribute->Value());
       
   739             }
       
   740             delete attribute;
       
   741         }
       
   742         else
       
   743         {
       
   744             // Non-localized MIDlet name
       
   745             Java::CJavaRegistryApplicationEntry* midlet
       
   746             = (Java::CJavaRegistryApplicationEntry*) iEntry->EmbeddedEntryByNumberL(i);
       
   747             if (midlet)
       
   748             {
       
   749                 CleanupStack::PushL(midlet);
       
   750                 if (ptrContent == KNullDesC)
       
   751                 {
       
   752                     ptrContent.Append(midlet->Name());
       
   753                 }
       
   754                 else
       
   755                 {
       
   756                     ptrContent.Append(KListSeparatorAndSpace);
       
   757                     ptrContent.Append(midlet->Name());
       
   758                 }
       
   759                 CleanupStack::PopAndDestroy(midlet);
       
   760             }
       
   761         }
       
   762     }
       
   763 
       
   764     // DRM
       
   765     iIsDRMProtected = TAppMngr2DRMUtils::IsDRMProtected(*iJarPath);
       
   766     iIsROMissingOrExpired = EFalse;
       
   767     if (iIsDRMProtected)
       
   768     {
       
   769         iIsROMissingOrExpired
       
   770         = TAppMngr2DRMUtils::IsDRMRightsObjectExpiredOrMissingL(
       
   771               *iJarPath);
       
   772     }
       
   773 
       
   774     // MIDlet suite specific icons
       
   775     if (midletUids.Count() > 0)
       
   776     {
       
   777         AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), midletUids[ 0 ],
       
   778                                    EAknsAppIconTypeList, iAppBitmap, iAppMask);
       
   779         CleanupStack::Pop(2); // iAppBitmap, iAppMask
       
   780     }
       
   781     CleanupStack::PopAndDestroy(&midletUids);
       
   782 
       
   783     // security domain
       
   784     CAppMngr2MidletSettingsHandler* settingsHandler
       
   785     = CAppMngr2MidletSettingsHandler::NewL(*iLocalizedMIDletName, iEntry->Uid(), iResourceHandler);
       
   786     CleanupStack::PushL(settingsHandler);
       
   787     iSecurityDomainCategory = settingsHandler->GetSecurityDomainCategory();
       
   788     iSecurityDomainName = settingsHandler->GetSecurityDomainName();
       
   789     CleanupStack::PopAndDestroy(settingsHandler);
       
   790     if (iSecurityDomainCategory != UNIDENTIFIED_THIRD_PARTY_DOMAIN_CATEGORY)
       
   791     {
       
   792         attribute = aEntry->AttributeL(KMIDletPermissions()); // no ownership
       
   793         if (attribute)
       
   794         {
       
   795             iPermissions = attribute->Value().AllocL();
       
   796             iPermissions->Des().TrimAll();
       
   797         }
       
   798         delete attribute;
       
   799     }
       
   800 
       
   801     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::ConstructL");
       
   802 }
       
   803 
       
   804 // ---------------------------------------------------------------------------
       
   805 // CAppMngr2MidletAppInfo::UninstallL()
       
   806 // ---------------------------------------------------------------------------
       
   807 //
       
   808 void CAppMngr2MidletAppInfo::UninstallL(TRequestStatus& aStatus)
       
   809 {
       
   810     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::UninstallL");
       
   811     if (!iSWInstLauncher)
       
   812     {
       
   813         SwiUI::RSWInstLauncher* swInstLauncher
       
   814         = new(ELeave) SwiUI::RSWInstLauncher;
       
   815         CleanupStack::PushL(swInstLauncher);
       
   816         User::LeaveIfError(swInstLauncher->Connect());
       
   817         CleanupStack::Pop(swInstLauncher);
       
   818         iSWInstLauncher = swInstLauncher;
       
   819         swInstLauncher = NULL;
       
   820     }
       
   821     iSWInstLauncher->Uninstall(aStatus, iEntry->Uid(), SwiUI::KJarMIMEType());
       
   822     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::UninstallL");
       
   823 }
       
   824 
       
   825 // ---------------------------------------------------------------------------
       
   826 // CAppMngr2MidletAppInfo::ShowDetailsL()
       
   827 // ---------------------------------------------------------------------------
       
   828 //
       
   829 void CAppMngr2MidletAppInfo::ShowDetailsL()
       
   830 {
       
   831     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ShowDetailsL");
       
   832     TRAP_IGNORE(ReadCertificatesInfoL());
       
   833     CAppMngr2MidletInfoIterator& iterator = InfoIteratorL(); // Not owned
       
   834     SwiUI::CommonUI::CCUIDetailsDialog* details
       
   835     = SwiUI::CommonUI::CCUIDetailsDialog::NewL();
       
   836 
       
   837     if (iIsDRMProtected && !iIsROMissingOrExpired)
       
   838     {
       
   839         RFile fileHandle;
       
   840         TInt err = fileHandle.Open(
       
   841                        iFs, *iJarPath,  EFileShareReadersOnly | EFileRead);
       
   842         CleanupClosePushL(fileHandle);
       
   843 
       
   844         if (iCertificates.Count())
       
   845         {
       
   846             details->ExecuteLD(iterator, iCertificates, fileHandle);
       
   847         }
       
   848         else
       
   849         {
       
   850             details->ExecuteLD(iterator, fileHandle);
       
   851         }
       
   852 
       
   853         CleanupStack::PopAndDestroy(&fileHandle);
       
   854     }
       
   855     else
       
   856     {
       
   857         if (iCertificates.Count())
       
   858         {
       
   859             details->ExecuteLD(iterator, iCertificates);
       
   860         }
       
   861         else
       
   862         {
       
   863             details->ExecuteLD(iterator);
       
   864         }
       
   865     }
       
   866     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::ShowDetailsL");
       
   867 }
       
   868 
       
   869 
       
   870 // ---------------------------------------------------------------------------
       
   871 // CAppMngr2MidletAppInfo::ShowSettingsL()
       
   872 // ---------------------------------------------------------------------------
       
   873 //
       
   874 void CAppMngr2MidletAppInfo::ShowSettingsL()
       
   875 {
       
   876     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ShowSettingsL");
       
   877     CAknViewAppUi* appUi
       
   878     = static_cast<CAknViewAppUi*>(CEikonEnv::Static()->EikAppUi());
       
   879     appUi->RemoveView(KMidletSuiteSettingsViewId);
       
   880     CAppMngr2MidletSettingsView* settingsView = CAppMngr2MidletSettingsView::NewL(
       
   881                 *iLocalizedMIDletName,
       
   882                 iEntry->Uid(),
       
   883                 iResourceHandler);
       
   884     CleanupStack::PushL(settingsView);
       
   885     appUi->AddViewL(settingsView);      // transfer ownership to CAknViewAppUi
       
   886     CleanupStack::Pop(settingsView);
       
   887     appUi->ActivateLocalViewL(KMidletSuiteSettingsViewId);
       
   888     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::ShowSettingsL");
       
   889 }
       
   890 
       
   891 // ---------------------------------------------------------------------------
       
   892 // CAppMngr2MidletAppInfo::UpdateL()
       
   893 // ---------------------------------------------------------------------------
       
   894 //
       
   895 void CAppMngr2MidletAppInfo::UpdateL()
       
   896 {
       
   897     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::UpdateL");
       
   898     CBrowserLauncher* launcher = CBrowserLauncher::NewLC();
       
   899     // open browser with info url from jad
       
   900     const TDesC* url = &InfoIteratorL().GetUpdateUrlL();
       
   901 
       
   902     HBufC* urlParam = HBufC::NewLC(url->Length()
       
   903                                    + KBrowserStartContinueParam().Length());
       
   904     TPtr urlParamPtr = urlParam->Des();
       
   905     urlParamPtr.Append(KBrowserStartContinueParam);
       
   906     urlParamPtr.Append(*url);
       
   907 
       
   908     launcher->LaunchBrowserSyncEmbeddedL(urlParamPtr, this);
       
   909 
       
   910     CleanupStack::PopAndDestroy(urlParam);
       
   911     CleanupStack::PopAndDestroy(launcher);
       
   912     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::UpdateL");
       
   913 }
       
   914 
       
   915 // ---------------------------------------------------------------------------
       
   916 // CAppMngr2MidletAppInfo::ShowInfoUrlL()
       
   917 // ---------------------------------------------------------------------------
       
   918 //
       
   919 void CAppMngr2MidletAppInfo::ShowInfoUrlL()
       
   920 {
       
   921     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ShowInfoUrlL");
       
   922     CBrowserLauncher* launcher = CBrowserLauncher::NewLC();
       
   923     // open browser with info url from jad
       
   924     const TDesC* url = &InfoIteratorL().GetInfoUrlL();
       
   925 
       
   926     HBufC* urlParam = HBufC::NewLC(url->Length()
       
   927                                    + KBrowserStartContinueParam().Length());
       
   928     TPtr urlParamPtr = urlParam->Des();
       
   929     urlParamPtr.Append(KBrowserStartContinueParam);
       
   930     urlParamPtr.Append(*url);
       
   931 
       
   932     launcher->LaunchBrowserSyncEmbeddedL(urlParamPtr, this);
       
   933 
       
   934     CleanupStack::PopAndDestroy(urlParam);
       
   935     CleanupStack::PopAndDestroy(launcher);
       
   936     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ShowInfoUrlL");
       
   937 }
       
   938 
       
   939 // ---------------------------------------------------------------------------
       
   940 // CAppMngr2MidletAppInfo::InfoIteratorL()
       
   941 // ---------------------------------------------------------------------------
       
   942 //
       
   943 CAppMngr2MidletInfoIterator& CAppMngr2MidletAppInfo::InfoIteratorL()
       
   944 {
       
   945     if (!iInfoIterator)
       
   946     {
       
   947         iInfoIterator = CAppMngr2MidletInfoIterator::NewL(*this,
       
   948                         EAppMngr2StatusInstalled, iFs, iResourceHandler);
       
   949     }
       
   950     return *iInfoIterator;
       
   951 }
       
   952 
       
   953 // ---------------------------------------------------------------------------
       
   954 // CAppMngr2MidletAppInfo::ReadCertificatesInfoL()
       
   955 // ---------------------------------------------------------------------------
       
   956 //
       
   957 void CAppMngr2MidletAppInfo::ReadCertificatesInfoL()
       
   958 {
       
   959     LOG(EJavaAppMngrPlugin, EInfo, "+ CAppMngr2MidletAppInfo::ReadCertificatesInfoL");
       
   960     if (iCertsRead)
       
   961     {
       
   962         return;
       
   963     }
       
   964 
       
   965     // Creates certificate info
       
   966     for (TInt i(0); i < iEntry->NumberOfCertificateChains(); i++)
       
   967     {
       
   968         CX509CertChain* certChain = new(ELeave)CX509CertChain();
       
   969         CleanupStack::PushL(certChain);
       
   970         CArrayPtrFlat<CX509Certificate>* chain = NULL;
       
   971         // In case of leave, decode next certificate
       
   972         TRAPD(err, chain = certChain->DecodeCertsL(iEntry->CertificateChain(i)));
       
   973         if (err != KErrNone)
       
   974         {
       
   975             CleanupStack::PopAndDestroy(certChain);
       
   976             continue;
       
   977         }
       
   978         CleanupStack::PushL(chain); // chain
       
   979         CleanupResetAndDestroyPushL(*chain); // *chain
       
   980         for (TInt certs(0); certs < chain->Count(); certs++)
       
   981         {
       
   982             CX509Certificate* cert = NULL;
       
   983             cert = static_cast<CX509Certificate*>(chain->At(certs));
       
   984             SwiUI::CommonUI::CCUICertificateInfo* commonCert =
       
   985                 SwiUI::CommonUI::CCUICertificateInfo::NewL(*cert);
       
   986             iCertificates.Append(commonCert); // ownership transfered
       
   987         }
       
   988         CleanupStack::PopAndDestroy(chain); // *chain.ResetAndDestroy()
       
   989         CleanupStack::PopAndDestroy(chain); // chain
       
   990         CleanupStack::PopAndDestroy(certChain);
       
   991     }
       
   992 
       
   993     iCertsRead = ETrue;
       
   994     LOG(EJavaAppMngrPlugin, EInfo, "- CAppMngr2MidletAppInfo::ReadCertificatesInfoL");
       
   995 }