javamanager/javasettings/appmngrplugin/src/appmngr2midletinfoiterator.cpp
changeset 21 2a9601315dfc
child 71 d5e927d5853b
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Implementation of CAppMngr2MidletInfoIterator
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <StringLoader.h>               // StringLoader
       
    20 #include <SWInstCommonUI.rsg>           // Resource IDs
       
    21 #include <javaapplicationsettings.rsg>           // Midlet resource IDs
       
    22 #include <AknUtils.h>                   // AknTextUtils
       
    23 #include <SWInstDefs.h>                 // KJadMimeType
       
    24 #include <appmngr2drmutils.h>           // TAppMngr2DRMUtils
       
    25 
       
    26 #include "appmngr2midletinfoiterator.h" // CAppMngr2MidletInfoIterator
       
    27 #include "appmngr2midletappinfo.h"      // CAppMngr2MidletAppInfo
       
    28 #include "appmngr2midletpackageinfo.h"  // CAppMngr2MidletPackageInfo
       
    29 #include "appmngr2midletmanifestreader.h"
       
    30 #include "appmngr2midletresourcehandler.h" // CAppMngr2MidletResourceHandler
       
    31 
       
    32 #include "logger.h"
       
    33 #include "securitystoragedatadefs.h"
       
    34 #include "s60commonutils.h"
       
    35 
       
    36 using namespace std;
       
    37 using namespace java::util;
       
    38 
       
    39 _LIT(KJava, "\x202AJava\x2122\x202C"); // Trade mark sign
       
    40 _LIT(KLRE, "\x202A"); // Bidirectional text control
       
    41 _LIT(KPDF, "\x202C"); // Bidirectional text control
       
    42 _LIT(KLeftParenthes, "(");
       
    43 _LIT(KListSeparatorAndSpace, ", ");
       
    44 
       
    45 /*void CleanUpResetAndDestroy(TAny *aArray)
       
    46 {
       
    47     if (aArray)
       
    48     {
       
    49         RPointerArray<HBufC>* array=(RPointerArray<HBufC>*)aArray;
       
    50         array->ResetAndDestroy();
       
    51         array->Close();
       
    52     }
       
    53 }*/
       
    54 
       
    55 
       
    56 // ======== MEMBER FUNCTIONS ========
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CAppMngr2MidletInfoIterator::NewL()
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CAppMngr2MidletInfoIterator* CAppMngr2MidletInfoIterator::NewL(
       
    63     CAppMngr2InfoBase& aMidlet, TAppMngr2InfoType aInfoType, RFs& aFs, CAppMngr2MidletResourceHandler& aResourceHandler)
       
    64 {
       
    65     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletInfoIterator::NewL ");
       
    66     CAppMngr2MidletInfoIterator* self =
       
    67         new(ELeave) CAppMngr2MidletInfoIterator(aMidlet, aInfoType, aFs, aResourceHandler);
       
    68     CleanupStack::PushL(self);
       
    69     self->ConstructL();
       
    70     CleanupStack::Pop(self);
       
    71     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletInfoIterator::NewL ");
       
    72     return self;
       
    73 }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CAppMngr2MidletInfoIterator::~CAppMngr2MidletInfoIterator()
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CAppMngr2MidletInfoIterator::~CAppMngr2MidletInfoIterator()
       
    80 {
       
    81     LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletInfoIterator::~CAppMngr2MidletInfoIterator ");
       
    82     delete iInfoUrl;
       
    83     iInfoUrl = NULL;
       
    84     delete iUpdateUrl;
       
    85     iUpdateUrl = NULL;
       
    86 }
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // CAppMngr2MidletInfoIterator::GetInfoUrlL()
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 const TDesC& CAppMngr2MidletInfoIterator::GetInfoUrlL()
       
    93 {
       
    94     if (!iInfoUrl)
       
    95     {
       
    96         return KNullDesC;
       
    97     }
       
    98     return *iInfoUrl;
       
    99 }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CAppMngr2MidletInfoIterator::GetUpdateUrlL()
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 const TDesC& CAppMngr2MidletInfoIterator::GetUpdateUrlL()
       
   106 {
       
   107     if (!iUpdateUrl)
       
   108     {
       
   109         return KNullDesC;
       
   110     }
       
   111     return *iUpdateUrl;
       
   112 }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CAppMngr2MidletInfoIterator::ConstructL()
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CAppMngr2MidletInfoIterator::ConstructL()
       
   119 {
       
   120     LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletInfoIterator::ConstructL ");
       
   121     BaseConstructL();
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CAppMngr2MidletInfoIterator::SetAllFieldsL()
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CAppMngr2MidletInfoIterator::SetAllFieldsL()
       
   129 {
       
   130     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletInfoIterator::SetAllFieldsL ");
       
   131     SetFieldL(R_SWCOMMON_DETAIL_NAME, iInfo.Name());
       
   132 
       
   133     if (iInfoType == EAppMngr2StatusInstalled)
       
   134     {
       
   135         CAppMngr2MidletAppInfo* midletInfo =
       
   136             reinterpret_cast<CAppMngr2MidletAppInfo*>(&iInfo);
       
   137         SetInstalledAppsInfoL(*midletInfo);
       
   138     }
       
   139     else
       
   140     {
       
   141         CAppMngr2MidletPackageInfo* packageInfo =
       
   142             reinterpret_cast<CAppMngr2MidletPackageInfo*>(&iInfo);
       
   143         // Create at least base iterator
       
   144         TRAP_IGNORE(SetNotInstalledAppsInfoL(*packageInfo));
       
   145     }
       
   146     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletInfoIterator::SetAllFieldsL ");
       
   147 }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CAppMngr2MidletInfoIterator::SetInstalledAppsInfoL()
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void CAppMngr2MidletInfoIterator::SetInstalledAppsInfoL(
       
   154     CAppMngr2MidletAppInfo& aMidlet)
       
   155 {
       
   156     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletInfoIterator::SetInstalledAppsInfoL ");
       
   157     //Version
       
   158     SetVersionL(aMidlet.Version());
       
   159     //Supplier
       
   160     SetVendorNameL(aMidlet.Vendor());
       
   161     //Status
       
   162     SetStatusL();
       
   163     //Memory
       
   164     SetLocationL();
       
   165     //Size
       
   166     SetFieldL(R_SWCOMMON_DETAIL_APPSIZE, aMidlet.Details());
       
   167     //Domain category
       
   168     SetDomainL(aMidlet.SecurityDomainCategory(), aMidlet.SecurityDomainName());
       
   169     //Technology
       
   170     SetFieldL(R_SWCOMMON_DETAIL_TECHNOLOGY, KJava);
       
   171     //Data size
       
   172     SetDataL(aMidlet.DataSize());
       
   173     //Info URL
       
   174     SetInfoUrlL(aMidlet.InfoUrl());
       
   175     //Content
       
   176     SetContentL(aMidlet.Content());
       
   177     // Permissions
       
   178     SetPermissionsL(aMidlet.Permissions());
       
   179     //Description
       
   180     SetTypeL(aMidlet.Description());
       
   181     // Update URL
       
   182     SetUpdateUrlL(aMidlet.UpdateUrl());
       
   183 
       
   184     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletInfoIterator::SetInstalledAppsInfoL ");
       
   185 }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CAppMngr2MidletInfoIterator::SetNotInstalledAppsInfoL()
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 void CAppMngr2MidletInfoIterator::SetNotInstalledAppsInfoL(
       
   192     CAppMngr2MidletPackageInfo& aPackage)
       
   193 {
       
   194     LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletInfoIterator::SetNotInstalledAppsInfoL ");
       
   195     TFileName protectedFileName = aPackage.ProtectedFileName();
       
   196 
       
   197     if ((aPackage.IsDRMProtected()) &&
       
   198             (TAppMngr2DRMUtils::IsDRMRightsObjectMissingL(protectedFileName)))
       
   199     {
       
   200         // Application DRM protected. Rights object is missing
       
   201         return;
       
   202     }
       
   203 
       
   204     std::auto_ptr<AppMngr2MidletManifestReader>reader(
       
   205         new AppMngr2MidletManifestReader(iFs));
       
   206 
       
   207     RPointerArray<MJavaAttribute> attributes;
       
   208 
       
   209     reader->ReadManifestL(aPackage.FileName(), attributes);
       
   210 
       
   211     if (attributes.Count() == 0)
       
   212     {
       
   213         // no midlet suite attributes
       
   214         return;
       
   215     }
       
   216 
       
   217     // Version
       
   218     _LIT(KMIDletVersion, "MIDlet-Version");
       
   219     TInt index = AttributeValueIndex(attributes, KMIDletVersion);
       
   220     if (KErrNotFound != index)
       
   221     {
       
   222         SetVersionL(attributes[index]->Value());
       
   223     }
       
   224     //Status
       
   225     SetStatusL();
       
   226     //Memory
       
   227     SetLocationL();
       
   228     //Size
       
   229     SetFieldL(R_SWCOMMON_DETAIL_APPSIZE, aPackage.Details());
       
   230     //Data, we do not show, if package is not installed
       
   231     //Technology
       
   232     SetFieldL(R_SWCOMMON_DETAIL_TECHNOLOGY, KJava);
       
   233 
       
   234     //Description
       
   235     _LIT(KMIDletDescription, "MIDlet-Description");
       
   236     index = AttributeValueIndex(attributes, KMIDletDescription);
       
   237     if (KErrNotFound != index)
       
   238     {
       
   239         SetTypeL(attributes[index]->Value());
       
   240     }
       
   241 
       
   242     //URL
       
   243     _LIT(KMIDletInfoURL, "MIDlet-Info-URL");
       
   244     index = AttributeValueIndex(attributes, KMIDletInfoURL);
       
   245     if (KErrNotFound != index)
       
   246     {
       
   247         SetInfoUrlL(attributes[index]->Value());
       
   248     }
       
   249 
       
   250     //Required permissions, we do not show, if package is not installed
       
   251     //Domain category, we do not show, if package is not installed
       
   252     //Content
       
   253     SetContentL(attributes);
       
   254 
       
   255     //CleanupStack::PopAndDestroy(); //suiteAttributes host
       
   256     //attributes.ResetAndDestroy();
       
   257     //CleanupStack::PopAndDestroy(&attributes);
       
   258     attributes.ResetAndDestroy();
       
   259 
       
   260 
       
   261     LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletInfoIterator::SetNotInstalledAppsInfoL ");
       
   262 }
       
   263 
       
   264 
       
   265 // ---------------------------------------------------------
       
   266 // CAppMngr2MidletInfoIterator::SetStatusL()
       
   267 // ---------------------------------------------------------
       
   268 //
       
   269 void CAppMngr2MidletInfoIterator::SetStatusL()
       
   270 {
       
   271     HBufC* status = NULL;
       
   272     TInt resourceOffset = iResourceHandler.AddResourceFileL();
       
   273     if (iInfoType == EAppMngr2StatusInstalled)
       
   274     {
       
   275         status = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_INSTALLED);
       
   276     }
       
   277     else  // iInfoType is EAppMngr2StatusNotInstalled
       
   278     {
       
   279         CAppMngr2MidletPackageInfo* pckg
       
   280         = static_cast<CAppMngr2MidletPackageInfo*>(&iInfo); // Not own
       
   281         if (pckg->JadFileName() != KNullDesC()
       
   282                 && pckg->JarFileName() == KNullDesC())
       
   283         {
       
   284             status = StringLoader::LoadLC(R_JAVA_INFO_STAT_NOT_LOADED);
       
   285         }
       
   286         else
       
   287         {
       
   288             status = StringLoader::LoadLC(
       
   289                          R_SWCOMMON_DETAIL_VALUE_NOT_INSTALLED);
       
   290         }
       
   291     }
       
   292     if (resourceOffset > 0)
       
   293     {
       
   294         iResourceHandler.DeleteResourceFile(resourceOffset);
       
   295     }
       
   296     SetFieldL(R_SWCOMMON_DETAIL_STATUS, *status);
       
   297     CleanupStack::PopAndDestroy(status);
       
   298 }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // CAppMngr2MidletInfoIterator::CAppMngr2MidletInfoIterator()
       
   302 // ---------------------------------------------------------------------------
       
   303 //
       
   304 CAppMngr2MidletInfoIterator::CAppMngr2MidletInfoIterator(
       
   305     CAppMngr2InfoBase& aMidlet, TAppMngr2InfoType aInfoType, RFs& aFs, CAppMngr2MidletResourceHandler& aResourceHandler) :
       
   306         CAppMngr2InfoIterator(aMidlet, aInfoType), iFs(aFs), iResourceHandler(aResourceHandler)
       
   307 {
       
   308     LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletInfoIterator::CAppMngr2MidletInfoIterator ");
       
   309 }
       
   310 
       
   311 // ---------------------------------------------------------
       
   312 // CAppMngr2MidletInfoIterator::SetVersionL()
       
   313 // ---------------------------------------------------------
       
   314 //
       
   315 void CAppMngr2MidletInfoIterator::SetVersionL(const TDesC& aVersion)
       
   316 {
       
   317     HBufC* version = aVersion.AllocLC();
       
   318     TPtr ptrVersion = version->Des();
       
   319     AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptrVersion);
       
   320     HBufC* tmpBuf = HBufC::NewLC(
       
   321                         KLRE().Length() + version->Length() + KPDF().Length());
       
   322 
       
   323     TInt position = version->Find(KLeftParenthes());
       
   324     if (position >= 0)
       
   325     {
       
   326         // Add bidirectional text control
       
   327         tmpBuf->Des() = version->Mid(0, position);
       
   328         tmpBuf->Des() += KLRE();
       
   329         tmpBuf->Des() += version->Mid(position, version->Length() - position);
       
   330         tmpBuf->Des() += KPDF();
       
   331     }
       
   332     else
       
   333     {
       
   334         tmpBuf->Des() = *version;
       
   335     }
       
   336 
       
   337     SetFieldL(R_SWCOMMON_DETAIL_VERSION, *tmpBuf);
       
   338     CleanupStack::PopAndDestroy(tmpBuf);
       
   339     CleanupStack::PopAndDestroy(version);
       
   340 }
       
   341 
       
   342 // ---------------------------------------------------------
       
   343 // CAppMngr2MidletInfoIterator::SetVendorNameL()
       
   344 // ---------------------------------------------------------
       
   345 //
       
   346 void CAppMngr2MidletInfoIterator::SetVendorNameL(const TDesC& aVendor)
       
   347 {
       
   348     //Set vendor
       
   349     HBufC* vendor = NULL;
       
   350     if (aVendor.Length() > 0)
       
   351     {
       
   352         vendor = aVendor.AllocL();
       
   353     }
       
   354     else
       
   355     {
       
   356         vendor = StringLoader::LoadL(R_SWCOMMON_DETAIL_VALUE_UNKNOWN_SUPPLIER);
       
   357     }
       
   358     CleanupStack::PushL(vendor);
       
   359     SetFieldL(R_SWCOMMON_DETAIL_SUPPLIER, *vendor);
       
   360     CleanupStack::PopAndDestroy(vendor);
       
   361 }
       
   362 
       
   363 // ---------------------------------------------------------
       
   364 // CAppMngr2MidletInfoIterator::SetDomainL()
       
   365 // ---------------------------------------------------------
       
   366 //
       
   367 void CAppMngr2MidletInfoIterator::SetDomainL(const std::wstring aSecurityDomainCategory, const std::wstring /*aSecurityDomainName*/)
       
   368 {
       
   369     HBufC* domainString = NULL;
       
   370     if (aSecurityDomainCategory == UNIDENTIFIED_THIRD_PARTY_DOMAIN_CATEGORY)
       
   371     {
       
   372         domainString = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_UNT_3RD_PARTY);
       
   373     }
       
   374     else if (aSecurityDomainCategory == IDENTIFIED_THIRD_PARTY_DOMAIN_CATEGORY)
       
   375     {
       
   376         domainString = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_3RD_PARTY);
       
   377     }
       
   378     else if (aSecurityDomainCategory == OPERATOR_DOMAIN_CATEGORY)
       
   379     {
       
   380         domainString = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_OPERATOR);
       
   381     }
       
   382     else if (aSecurityDomainCategory == MANUFACTURER_DOMAIN_CATEGORY)
       
   383     {
       
   384         domainString = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_MANUFACTURER);
       
   385     }
       
   386     else
       
   387     {
       
   388         domainString = S60CommonUtils::wstringToDes(aSecurityDomainCategory.c_str());
       
   389         CleanupStack::PushL(domainString);
       
   390     }
       
   391     SetFieldL(R_SWCOMMON_DETAIL_DOMAIN, *domainString);
       
   392     CleanupStack::PopAndDestroy(domainString);
       
   393 }
       
   394 
       
   395 // CAppMngr2MidletInfoIterator::SetDataL()
       
   396 // -----------------------------------------------------------------------------
       
   397 //
       
   398 void CAppMngr2MidletInfoIterator::SetDataL(const TDesC& aDataSize)
       
   399 {
       
   400     if (aDataSize != KNullDesC)
       
   401     {
       
   402         TLex numLexer(aDataSize);
       
   403         TInt32 id(0);
       
   404         User::LeaveIfError(numLexer.Val(id));
       
   405         HBufC* data = StringLoader::LoadLC(R_SWCOMMON_DETAIL_VALUE_SIZE,
       
   406                                            id / 1024);
       
   407         SetFieldL(R_SWCOMMON_DETAIL_DATASIZE, *data);
       
   408         CleanupStack::PopAndDestroy(data);
       
   409     }
       
   410     else
       
   411     {
       
   412         HBufC* unknow = StringLoader::LoadLC(
       
   413                             R_SWCOMMON_DETAIL_VALUE_UNKNOWN_DATA);
       
   414         SetFieldL(R_SWCOMMON_DETAIL_DATASIZE, *unknow);
       
   415         CleanupStack::PopAndDestroy(unknow);
       
   416     }
       
   417 }
       
   418 
       
   419 // ---------------------------------------------------------
       
   420 // CAppMngr2MidletInfoIterator::SetInfoUrlL()
       
   421 // ---------------------------------------------------------
       
   422 //
       
   423 void CAppMngr2MidletInfoIterator::SetInfoUrlL(const TDesC& aInfoUrl)
       
   424 {
       
   425     if (aInfoUrl.Length() > 0)
       
   426     {
       
   427         SetFieldL(R_SWCOMMON_DETAIL_INFO_URL, aInfoUrl);
       
   428         if (iInfoUrl)
       
   429         {
       
   430             delete iInfoUrl;
       
   431             iInfoUrl = NULL;
       
   432         }
       
   433         iInfoUrl = aInfoUrl.AllocL();
       
   434     }
       
   435     else
       
   436     {
       
   437         HBufC* unknow = StringLoader::LoadLC(
       
   438                             R_SWCOMMON_DETAIL_VALUE_UNKNOWN_URL);
       
   439         SetFieldL(R_SWCOMMON_DETAIL_INFO_URL, *unknow);
       
   440         CleanupStack::PopAndDestroy(unknow);
       
   441     }
       
   442 }
       
   443 
       
   444 // ---------------------------------------------------------
       
   445 // CAppMngr2MidletInfoIterator::SetUpdateUrlL()
       
   446 // ---------------------------------------------------------
       
   447 //
       
   448 void CAppMngr2MidletInfoIterator::SetUpdateUrlL(const TDesC& aUpdateUrl)
       
   449 {
       
   450     delete iUpdateUrl;
       
   451     iUpdateUrl = NULL;
       
   452     iUpdateUrl = aUpdateUrl.AllocL();
       
   453 }
       
   454 
       
   455 // ---------------------------------------------------------
       
   456 // CAppMngr2MidletInfoIterator::SetContentL()
       
   457 // ---------------------------------------------------------
       
   458 //
       
   459 void CAppMngr2MidletInfoIterator::SetContentL(const TDesC& aContent)
       
   460 {
       
   461     SetFieldL(R_SWCOMMON_DETAIL_CONTENT, aContent);
       
   462 }
       
   463 
       
   464 // ---------------------------------------------------------
       
   465 // CAppMngr2MidletInfoIterator::SetPermisisonsL()
       
   466 // ---------------------------------------------------------
       
   467 //
       
   468 void CAppMngr2MidletInfoIterator::SetPermissionsL(const TDesC& aPermissions)
       
   469 {
       
   470     if (aPermissions.Length() > 0)
       
   471     {
       
   472         SetFieldL(R_SWCOMMON_DETAIL_PERMISSIONS, aPermissions);
       
   473     }
       
   474 }
       
   475 
       
   476 // ---------------------------------------------------------
       
   477 // CAppMngr2MidletInfoIterator::SetContentL()
       
   478 // ---------------------------------------------------------
       
   479 //
       
   480 void CAppMngr2MidletInfoIterator::SetContentL(
       
   481     const RPointerArray<Java::MJavaAttribute>& aAttributes)
       
   482 {
       
   483     // Read MIdlet-x attributes until not found.
       
   484     _LIT(KMIDletIndexPrefix, "MIDlet-%d");
       
   485     _LIT(KColon, ",");
       
   486 
       
   487     TInt index = KErrNone;
       
   488     TInt midletIndex = 1;
       
   489 
       
   490     // Read all MIDlet names belogning to the suite.
       
   491     HBufC16* names = NULL;
       
   492 
       
   493     while (index != KErrNotFound)
       
   494     {
       
   495         TBuf16<15> midletAttrName;
       
   496         midletAttrName.Format(KMIDletIndexPrefix, midletIndex);
       
   497         index = AttributeValueIndex(aAttributes, midletAttrName);
       
   498 
       
   499         if (KErrNotFound != index)
       
   500         {
       
   501             std::auto_ptr<HBufC16>midletName(
       
   502                 aAttributes[index]->Value().AllocL());
       
   503             TPtrC16 midletNamePtr(midletName->Des());
       
   504 
       
   505             TInt delimIndex = midletNamePtr.Find(KColon);
       
   506 
       
   507             if (KErrNotFound != delimIndex)
       
   508             {
       
   509                 // Use only name.
       
   510                 TPtrC16 onlyName = midletNamePtr.Left(delimIndex);
       
   511 
       
   512                 //if (firstRound)
       
   513                 if (names == NULL || names->Des() == KNullDesC)
       
   514                 {
       
   515                     // Append MIDlet name to names.
       
   516                     names = HBufC16::NewL(onlyName.Length());
       
   517                     TPtr namesPtr(names->Des());
       
   518                     namesPtr.Append(onlyName);
       
   519                     CleanupStack::PushL(names);
       
   520                 }
       
   521                 else
       
   522                 {
       
   523                     // Append MIDlet name to names.
       
   524                     HBufC16* tmp = HBufC16::NewL(names->Length()
       
   525                                                  + KListSeparatorAndSpace().Length()
       
   526                                                  + onlyName.Length());
       
   527                     TPtr tmpPtr(tmp->Des());
       
   528                     tmpPtr.Copy(*names);
       
   529                     tmpPtr.Append(KListSeparatorAndSpace);
       
   530                     tmpPtr.Append(onlyName);
       
   531                     CleanupStack::PopAndDestroy(names);
       
   532                     names = tmp;
       
   533                     CleanupStack::PushL(names);
       
   534                 }
       
   535             }
       
   536             midletIndex++;
       
   537         }
       
   538     }
       
   539     SetContentL(*names);
       
   540     CleanupStack::PopAndDestroy(names);
       
   541 }
       
   542 
       
   543 // ---------------------------------------------------------
       
   544 // CAppMngr2MidletInfoIterator::SetTypeL()
       
   545 // ---------------------------------------------------------
       
   546 //
       
   547 void CAppMngr2MidletInfoIterator::SetTypeL(const TDesC& aDescription)
       
   548 {
       
   549     if (aDescription.Length() > 0)
       
   550     {
       
   551         SetFieldL(R_SWCOMMON_DETAIL_TYPE, aDescription);
       
   552     }
       
   553     else
       
   554     {
       
   555         HBufC* unknow = StringLoader::LoadLC(
       
   556                             R_SWCOMMON_DETAIL_VALUE_UNKNOWN_TYPE);
       
   557         SetFieldL(R_SWCOMMON_DETAIL_TYPE, *unknow);
       
   558         CleanupStack::PopAndDestroy(unknow);
       
   559     }
       
   560 }
       
   561 
       
   562 // ---------------------------------------------------------
       
   563 // CAppMngr2MidletInfoIterator::AttributeValueIndex()
       
   564 // ---------------------------------------------------------
       
   565 //
       
   566 TInt CAppMngr2MidletInfoIterator::AttributeValueIndex(
       
   567     const RPointerArray<MJavaAttribute>& aAttrs, const TDesC& aName)
       
   568 {
       
   569     TInt index = KErrNotFound;
       
   570     for (TInt i = 0; i < aAttrs.Count(); i++)
       
   571     {
       
   572         if (aAttrs[i]->Name() == aName)
       
   573         {
       
   574             index = i;
       
   575             break;
       
   576         }
       
   577     }
       
   578     return index;
       
   579 }