contentstorage/casoftwareregistry/s60/src/casoftwareregistry_p.cpp
changeset 109 e0aa398e6810
parent 104 9b022b1f357c
child 121 0b3699f6c654
equal deleted inserted replaced
104:9b022b1f357c 109:e0aa398e6810
    13  *
    13  *
    14  * Description:  ?Description
    14  * Description:  ?Description
    15  *
    15  *
    16  */
    16  */
    17 #include <HbParameterLengthLimiter>
    17 #include <HbParameterLengthLimiter>
       
    18 #include <HbExtendedLocale>
    18 #include <QMetaType>
    19 #include <QMetaType>
    19 #include <QScopedPointer>
    20 #include <QScopedPointer>
    20 #include <QStringList>
    21 #include <QStringList>
    21 
    22 #include <QDateTime>
       
    23 #undef SYMBIAN_ENABLE_SPLIT_HEADERS //TODO this is work around
       
    24 #include <usif/scr/screntries.h>
    22 #include <usif/scr/scr.h>
    25 #include <usif/scr/scr.h>
    23 #include <usif/scr/screntries.h>
       
    24 #include <xqconversions.h>
    26 #include <xqconversions.h>
    25 #include <driveinfo.h>
    27 #include <driveinfo.h>
    26 
    28 
       
    29 #include "cauninstallnotifier.h"
       
    30 #include "cauninstallnotifier_p.h"
    27 #include "casoftwareregistry.h"
    31 #include "casoftwareregistry.h"
    28 #include "casoftwareregistry_p.h"
    32 #include "casoftwareregistry_p.h"
       
    33 #include "cadefs.h"
       
    34 #include "caarraycleanup.inl"
    29 
    35 
    30 using namespace Usif;
    36 using namespace Usif;
    31 
    37 
    32 _LIT(KConfirmMessageKey, "MIDlet-Delete-Confirm");
    38 _LIT(KConfirmMessageKey, "MIDlet-Delete-Confirm");
    33 
    39 _LIT(KCaScrPropertyDomainCategory, "Domain-Category");
    34 template <typename RClass>
    40 _LIT(KCaScrPropertyMidletDescryption, "MIDlet-Description");
    35 struct RClassDeleter
    41 const int maxLogsCount = 20;  // should be 50 - workaround for 
    36 {
    42 // ou1cimx1#476143 Dialog crash when label contains big amount of lines
    37     static inline void cleanup(RClass *ptr)
    43 
    38     {
       
    39         ptr->Close();
       
    40     }
       
    41 };
       
    42 
       
    43 typedef QScopedPointer<RSoftwareComponentRegistry, 
       
    44     RClassDeleter<RSoftwareComponentRegistry> > ScrScopedPointer;
       
    45     
       
    46 typedef QScopedPointer<RFs, 
       
    47     RClassDeleter<RFs> > RFSScopedPointer;
       
    48 /*!
    44 /*!
    49  Constructor
    45  Constructor
    50  \param servicePublic Pointer to object of the public class.
    46  \param servicePublic Pointer to object of the public class.
    51  */
    47  */
    52 CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate(
    48 CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate(
    53     CaSoftwareRegistry *servicePublic):
    49         CaSoftwareRegistry *servicePublic):
    54     m_q(servicePublic)
    50     m_q(servicePublic)
    55 {
    51 {
    56 }
    52 }
    57 
    53 
    58 /*!
    54 /*!
    59  Destructor.
    55  Destructor.
    60  */
    56  */
    61 CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
    57 CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
    62 {
    58 {
       
    59     
    63 }
    60 }
    64 
    61 
    65 /*!
    62 /*!
    66  Provides details needed for uninstalling process of Java applications.
    63  Provides details needed for uninstalling process of Java applications.
    67  \param[in] componentId component id of an application to be uninstalled.
    64  \param[in] componentId component id of an application to be uninstalled.
    72       null string means the lack of the message.
    69       null string means the lack of the message.
    73  \retval true if there is no error.
    70  \retval true if there is no error.
    74  */
    71  */
    75 
    72 
    76 bool CaSoftwareRegistryPrivate::getUninstallDetails(int componentId,
    73 bool CaSoftwareRegistryPrivate::getUninstallDetails(int componentId,
    77     QString &componentName,
    74         QString &componentName,
    78     QStringList &applicationsUids,
    75         QStringList &applicationsUids,
    79     QString &confirmationMessage)
    76         QString &confirmationMessage)
    80 {
    77 {
    81     TRAPD(error, getUninstallDetailsL(componentId,
    78     TRAPD(error, getUninstallDetailsL(componentId,
    82         componentName,
    79             componentName,
    83         applicationsUids,
    80             applicationsUids,
    84         confirmationMessage)
    81             confirmationMessage)
    85          );
    82              );
    86     return error == KErrNone;
    83     return error == KErrNone;
    87 }
    84 }
    88 
    85 
    89 /*!
    86 /*!
    90  Provides a list of uids of applications installed by the given package.
    87  Provides a list of uids of applications installed by the given package.
    93       of the given component id.
    90       of the given component id.
    94  \retval true if there is no error.
    91  \retval true if there is no error.
    95  */
    92  */
    96 
    93 
    97 bool CaSoftwareRegistryPrivate::getApplicationsUids(int componentId,
    94 bool CaSoftwareRegistryPrivate::getApplicationsUids(int componentId,
    98     QStringList &applicationsUids)
    95         QStringList &applicationsUids)
    99 {
    96 {
   100     TRAPD(error, getApplicationsUidsL(componentId, applicationsUids));
    97     TRAPD(error, getApplicationsUidsL(componentId, applicationsUids));
   101     return error == KErrNone;
    98     return error == KErrNone;
   102 }
    99 }
   103 
   100 
   110       of the given component id.
   107       of the given component id.
   111  \param[out] confirmationMessage optional deletion confirmation message,
   108  \param[out] confirmationMessage optional deletion confirmation message,
   112       null string means the lack of the message.
   109       null string means the lack of the message.
   113  */
   110  */
   114 void CaSoftwareRegistryPrivate::getUninstallDetailsL(int componentId,
   111 void CaSoftwareRegistryPrivate::getUninstallDetailsL(int componentId,
   115     QString &componentName,
   112         QString &componentName,
   116     QStringList &appUids,
   113         QStringList &appUids,
   117     QString &confirmationMessage)
   114         QString &confirmationMessage)
   118 {
   115 {
   119     componentName.clear();
   116     componentName.clear();
   120     appUids.clear();
   117     appUids.clear();
   121     confirmationMessage.clear();
   118     confirmationMessage.clear();
   122 
   119 
   130         CleanupClosePushL(softwareComponentRegistry);
   127         CleanupClosePushL(softwareComponentRegistry);
   131         User::LeaveIfError(softwareComponentRegistry.Connect());
   128         User::LeaveIfError(softwareComponentRegistry.Connect());
   132 
   129 
   133         CComponentEntry *entry = CComponentEntry::NewLC();
   130         CComponentEntry *entry = CComponentEntry::NewLC();
   134         softwareComponentRegistry.GetComponentL(componentId, *entry);
   131         softwareComponentRegistry.GetComponentL(componentId, *entry);
   135         softwareComponentRegistry.GetAppUidsForComponentL(componentIdValue,
   132         softwareComponentRegistry.GetAppUidsForComponentL(
   136             appUidsArray);
   133                 componentIdValue, appUidsArray);
   137 
   134 
   138         CPropertyEntry *confirmationProperty =
   135         CPropertyEntry *confirmationProperty
   139             softwareComponentRegistry.GetComponentPropertyL(componentId,
   136                 = softwareComponentRegistry.GetComponentPropertyL(
   140             KConfirmMessageKey);
   137                         componentId, KConfirmMessageKey);
   141         if (confirmationProperty &&
   138         if (confirmationProperty
   142             confirmationProperty->PropertyType() ==
   139                 && confirmationProperty->PropertyType()
   143                 CPropertyEntry::ELocalizedProperty) {
   140                         == CPropertyEntry::ELocalizedProperty) {
   144             confirmationMessageProperty =
   141             confirmationMessageProperty
   145                 static_cast<CLocalizablePropertyEntry *>(
   142                     = static_cast<CLocalizablePropertyEntry *>(
   146                     confirmationProperty);
   143                             confirmationProperty);
   147         } else {
   144         } else {
   148             delete confirmationProperty;
   145             delete confirmationProperty;
   149             confirmationProperty = NULL;
   146             confirmationProperty = NULL;
   150         }
   147         }
   151 
   148 
   154             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   151             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   155                 appUids.append(QString::number(appUidsArray[i].iUid));
   152                 appUids.append(QString::number(appUidsArray[i].iUid));
   156             }
   153             }
   157             if (confirmationMessageProperty) {
   154             if (confirmationMessageProperty) {
   158                 confirmationMessage = XQConversions::s60DescToQString(
   155                 confirmationMessage = XQConversions::s60DescToQString(
   159                     confirmationMessageProperty->StrValue());
   156                         confirmationMessageProperty->StrValue());
   160             }
   157             }
   161         );
   158         );
   162 
   159 
   163         CleanupStack::PopAndDestroy(3, &appUidsArray);
   160         CleanupStack::PopAndDestroy(3, &appUidsArray);
   164     }
   161     }
   182 
   179 
   183         RSoftwareComponentRegistry softwareComponentRegistry;
   180         RSoftwareComponentRegistry softwareComponentRegistry;
   184         CleanupClosePushL(softwareComponentRegistry);
   181         CleanupClosePushL(softwareComponentRegistry);
   185         User::LeaveIfError(softwareComponentRegistry.Connect());
   182         User::LeaveIfError(softwareComponentRegistry.Connect());
   186 
   183 
   187         softwareComponentRegistry.GetAppUidsForComponentL(componentIdValue,
   184         softwareComponentRegistry.GetAppUidsForComponentL(
   188             appUidsArray);
   185                 componentIdValue, appUidsArray);
   189 
   186 
   190         QT_TRYCATCH_LEAVING(
   187         QT_TRYCATCH_LEAVING(
   191             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   188             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   192                 appUids.append(QString::number(appUidsArray[i].iUid));
   189                 appUids.append(QString::number(appUidsArray[i].iUid));
   193             }
   190             }
   197 }
   194 }
   198 
   195 
   199 /*!
   196 /*!
   200  \param componentId Component id of the entry which details are requested for.
   197  \param componentId Component id of the entry which details are requested for.
   201  \return Map of component details if component id was greater than 0 or
   198  \return Map of component details if component id was greater than 0 or
   202  empty map otherwise. 
   199  empty map otherwise.
   203  */
   200  */
   204 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
   201 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
   205     int componentId) const
   202     int componentId) const
   206 {
   203 {
   207     CaSoftwareRegistry::DetailMap result;
   204     CaSoftwareRegistry::DetailMap result;
       
   205     TRAP_IGNORE(result=entryDetailsL(componentId));
       
   206     return result;
       
   207 }
       
   208 
       
   209 /*!
       
   210  \param componentId Component id of the entry which details are requested for.
       
   211  \return Map of component details if component id was greater than 0 or
       
   212  empty map otherwise.
       
   213  */
       
   214 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetailsL(
       
   215     int componentId) const
       
   216 {
       
   217     CaSoftwareRegistry::DetailMap result;
   208 
   218 
   209     if (componentId >= 1) {
   219     if (componentId >= 1) {
   210         RSoftwareComponentRegistry softwareComponentRegistry;
   220         RSoftwareComponentRegistry scr;
   211         ScrScopedPointer scr(&softwareComponentRegistry);
   221         CleanupClosePushL(scr);
   212         if (scr->Connect() == KErrNone) {
   222         if (scr.Connect() == KErrNone) {
   213             
   223             CComponentEntry* entry = CComponentEntry::NewLC();
   214             QScopedPointer<CComponentEntry> entry;
   224             if (scr.GetComponentL(componentId, *entry)) {
   215             
   225                 result = entryDetailsL(*entry);
   216             QT_TRAP_THROWING(entry.reset(CComponentEntry::NewL()));
   226                 if (entry->SoftwareType().Compare(KSoftwareTypeJava) == 0) {
   217             
   227                     CPropertyEntry* domainProperty =
   218             TBool resultCode = EFalse;
   228                         scr.GetComponentPropertyL(componentId,
   219             TRAPD(leaveCode, resultCode = scr->GetComponentL(componentId, *entry));
   229                             KCaScrPropertyDomainCategory);
   220             if (leaveCode == KErrNone && resultCode) {
   230                     CleanupStack::PushL(domainProperty);
   221                 result = entryDetails(*entry);
   231                     if (domainProperty &&
   222             }
   232                         domainProperty->PropertyType() ==
       
   233                             CPropertyEntry::ELocalizedProperty) {
       
   234                         result[CaSoftwareRegistry::componentProtectionDomainKey()] =
       
   235                             XQConversions::s60DescToQString(
       
   236                                 static_cast<CLocalizablePropertyEntry*>(
       
   237                                     domainProperty)->StrValue());
       
   238                     }
       
   239 
       
   240                     CPropertyEntry *midletDescryption =
       
   241                         scr.GetComponentPropertyL(componentId,
       
   242                             KCaScrPropertyMidletDescryption);
       
   243                     CleanupStack::PushL(midletDescryption);
       
   244                     if (midletDescryption &&
       
   245                         midletDescryption->PropertyType() ==
       
   246                             CPropertyEntry::ELocalizedProperty) {
       
   247                         result[CaSoftwareRegistry::componentDescriptionKey()] =
       
   248                             XQConversions::s60DescToQString(
       
   249                                 static_cast<CLocalizablePropertyEntry*>(
       
   250                                     midletDescryption)->StrValue());
       
   251                     }
       
   252                     CleanupStack::PopAndDestroy(midletDescryption);
       
   253                     CleanupStack::PopAndDestroy(domainProperty);
       
   254                 }
       
   255             }
       
   256             CleanupStack::PopAndDestroy(entry);
   223         }
   257         }
   224     }
   258         CleanupStack::PopAndDestroy(&scr);
   225     
   259     }
   226     return result;
   260     return result;
   227 }
   261 }
   228 
   262 
   229 /*!
   263 /*!
   230  \param entry Software registry entry providing details.
   264  \param entry Software registry entry providing details.
   231  \return Map with details for the component represented by \entry.
   265  \return Map with details for the component represented by \entry.
   232  */
   266  */
   233 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
   267 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetailsL(
   234     const CComponentEntry& entry) const
   268     const CComponentEntry& entry) const
   235 {
   269 {
   236     CaSoftwareRegistry::DetailMap detailMap;
   270     CaSoftwareRegistry::DetailMap detailMap;
   237     
   271 
   238     detailMap[CaSoftwareRegistry::componentNameKey()] = 
   272     detailMap[CaSoftwareRegistry::componentNameKey()] =
   239         XQConversions::s60DescToQString(entry.Name());
   273         XQConversions::s60DescToQString(entry.Name());
   240         
   274 
   241     detailMap[CaSoftwareRegistry::componentVersionKey()] = 
   275     detailMap[CaSoftwareRegistry::componentVersionKey()] =
   242         XQConversions::s60DescToQString(entry.Version());
   276         XQConversions::s60DescToQString(entry.Version());
   243     
   277 
   244     detailMap[CaSoftwareRegistry::componentVendorKey()] = 
   278     detailMap[CaSoftwareRegistry::componentVendorKey()] =
   245         XQConversions::s60DescToQString(entry.Vendor());
   279         XQConversions::s60DescToQString(entry.Vendor());
   246         
   280 
   247     QString drives;
   281     QString drives;
   248     QString drv;
   282     QString drv;
   249     TChar drive;    
   283     TChar drive;
   250     
   284 
   251     const TInt driveListLen(entry.InstalledDrives().Length());
   285     const TInt driveListLen(entry.InstalledDrives().Length());
   252     for (TInt i( 0 ); i < driveListLen; ++i) {
   286     for (TInt i( 0 ); i < driveListLen; ++i) {
   253         if (entry.InstalledDrives()[i] != '\0') {
   287         if (entry.InstalledDrives()[i] != '\0') {
   254             
   288 
   255             if (!drives.isEmpty()) {
   289             if (!drives.isEmpty()) {
   256                 drives = drives.append(",");
   290                 drives = drives.append(",");
   257             }  
   291             }
   258             drv = QString(QChar('A'+ i)).append(":");
   292             drv = QString(QChar('A'+ i)).append(":");
   259             if(DriveInfo::GetDefaultDrive(
   293             if(DriveInfo::GetDefaultDrive(
   260                     DriveInfo::EDefaultPhoneMemory, drive ) == KErrNone 
   294                     DriveInfo::EDefaultPhoneMemory, drive ) == KErrNone
   261                     && QChar('A'+ i) == QChar(drive))
   295                     && QChar('A'+ i) == QChar(drive)) {
   262                 {
   296                 drives = drives.append(HbParameterLengthLimiter(
   263                 drives = drives.append(
   297                         "txt_applib_dialog_1_device_memory").arg(
   264                         HbParameterLengthLimiter("txt_applib_dialog_1_device_memory").arg(
   298                                 QString(QChar('A'+ i))));
   265                           QString(QChar('A'+ i))));
   299             } else if(DriveInfo::GetDefaultDrive(
   266                 }
   300                     DriveInfo::EDefaultMassStorage, drive ) == KErrNone
   267             else if(DriveInfo::GetDefaultDrive(
   301                     && QChar('A'+ i) == QChar(drive)) {
   268                     DriveInfo::EDefaultMassStorage, drive ) == KErrNone 
   302                 drives = drives.append(HbParameterLengthLimiter(
   269                     && QChar('A'+ i) == QChar(drive))
   303                         "txt_applib_dialog_1_mass_storage").arg(
   270                 {
   304                                 QString(QChar('A'+ i))));
   271                 drives = drives.append(
   305                 } else if(DriveInfo::GetDefaultDrive(
   272                         HbParameterLengthLimiter("txt_applib_dialog_1_mass_storage").arg(
   306                     DriveInfo::EDefaultRemovableMassStorage, drive ) == KErrNone
   273                           QString(QChar('A'+ i))));
   307                     && QChar('A'+ i) == QChar(drive)) {
   274                 }
       
   275             else if(DriveInfo::GetDefaultDrive(
       
   276                     DriveInfo::EDefaultRemovableMassStorage, drive ) == KErrNone 
       
   277                     && QChar('A'+ i) == QChar(drive))
       
   278                 {
       
   279                 RFs fs;
   308                 RFs fs;
   280                 RFSScopedPointer fSPointer(&fs);
   309                 CleanupClosePushL(fs);
   281                 if (fs.Connect() == KErrNone) {
   310                 if (fs.Connect() == KErrNone) {
   282                     TInt driveNumber;
   311                     TInt driveNumber;
   283                     TVolumeInfo tv;
   312                     TVolumeInfo tv;
   284                     DriveInfo::GetDefaultDrive(
   313                     DriveInfo::GetDefaultDrive(
   285                             DriveInfo::EDefaultRemovableMassStorage, driveNumber );
   314                             DriveInfo::EDefaultRemovableMassStorage,
   286                     qt_symbian_throwIfError(fs.Volume(tv, driveNumber));
   315                             driveNumber );
   287                     if(tv.iName.Length()) { 
   316                     User::LeaveIfError(fs.Volume(tv, driveNumber));
   288                         drives = drives.append(
   317                     if(tv.iName.Length()) {
   289                                 HbParameterLengthLimiter("txt_applib_dialog_1_2").arg(
   318                         drives = drives.append(HbParameterLengthLimiter(
   290                                    QString(QChar('A'+ i))).arg(
   319                                 "txt_applib_dialog_1_2").arg(
   291                                            XQConversions::s60DescToQString(tv.iName)));                       
   320                                         QString(QChar('A'+ i))).arg(
   292                     }
   321                                                 XQConversions::s60DescToQString(
   293                     else {
   322                                                         tv.iName)));
   294                         drives = drives.append(
   323                     } else {
   295                             HbParameterLengthLimiter("txt_applib_dialog_1_memory_card").arg(
   324                         drives = drives.append(HbParameterLengthLimiter(
   296                               QString(QChar('A'+ i))));           
   325                                 "txt_applib_dialog_1_memory_card").arg(
       
   326                                         QString(QChar('A'+ i))));
   297                     }
   327                     }
   298                 }
   328                 }
       
   329                 CleanupStack::PopAndDestroy(&fs);
   299             } else {
   330             } else {
   300                 drives = drives.append(QChar('A'+ i)).append(":");   
   331                 drives = drives.append(QChar('A'+ i)).append(":");
   301             }
   332             }
   302         }
   333         }
   303     }
   334     }
   304     
       
   305     detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
   335     detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
   306     
       
   307 
   336 
   308     static const TInt64 KKilo = 1024;
   337     static const TInt64 KKilo = 1024;
   309     static const TInt64 KMega = KKilo * KKilo;
   338     static const TInt64 KMega = KKilo * KKilo;
   310     if(entry.ComponentSize() >= KMega) {
   339     if(entry.ComponentSize() >= KMega) {
   311         detailMap[CaSoftwareRegistry::componentSizeKey()] = 
   340         detailMap[CaSoftwareRegistry::componentSizeKey()]
   312             HbParameterLengthLimiter("txt_applib_dialog_l1_mb").arg(
   341                   = HbParameterLengthLimiter("txt_applib_dialog_l1_mb").arg(
   313                     static_cast<double>(entry.ComponentSize() / KMega));
   342                           static_cast<double>(entry.ComponentSize() / KMega));
   314     }
   343     } else {
   315     else {
   344         detailMap[CaSoftwareRegistry::componentSizeKey()]
   316         detailMap[CaSoftwareRegistry::componentSizeKey()] = 
   345                   = HbParameterLengthLimiter("txt_applib_dialog_l1_kb").arg(
   317             HbParameterLengthLimiter("txt_applib_dialog_l1_kb").arg(
   346                           static_cast<double>(entry.ComponentSize() / KKilo));
   318                     static_cast<double>(entry.ComponentSize() / KKilo));
   347     }
   319     }
   348     detailMap[CaSoftwareRegistry::componentTypeKey()] =
   320 
       
   321     
       
   322     detailMap[CaSoftwareRegistry::componentTypeKey()] = 
       
   323         XQConversions::s60DescToQString(entry.SoftwareType());
   349         XQConversions::s60DescToQString(entry.SoftwareType());
   324 
   350 
   325     return detailMap;
   351     return detailMap;
   326 }
   352 }
       
   353 
       
   354 /*!
       
   355  \param entry Software registry entry providing details.
       
   356  \return Map with details for the component represented by \entry.
       
   357  */
       
   358 QList<CaSoftwareRegistryPrivate::DetailMap>
       
   359         CaSoftwareRegistryPrivate::retrieveLogEntries() const
       
   360 {
       
   361     QList<CaSoftwareRegistryPrivate::DetailMap> logMap;
       
   362     TRAP_IGNORE(logMap = retrieveLogEntriesL());
       
   363     return logMap;
       
   364 }
       
   365 /*!
       
   366  Creating uninstall notifier
       
   367  \return CaUninstallNotifier instance
       
   368  */
       
   369 CaUninstallNotifier *CaSoftwareRegistryPrivate::createUninstallNotifier() const
       
   370 {
       
   371     return CaUninstallNotifier::notifier();
       
   372 }
       
   373 
       
   374 /*!
       
   375  \param entry Software registry entry providing installation log.
       
   376  \return List of Maps with installation log.
       
   377  */
       
   378 QList<CaSoftwareRegistryPrivate::DetailMap>
       
   379         CaSoftwareRegistryPrivate::retrieveLogEntriesL() const
       
   380 {
       
   381     QList<CaSoftwareRegistryPrivate::DetailMap> logList;
       
   382 
       
   383     RSoftwareComponentRegistry scr;
       
   384     CleanupClosePushL(scr);
       
   385     User::LeaveIfError(scr.Connect());
       
   386 
       
   387     RPointerArray<CScrLogEntry> logEntries;
       
   388     CleanupResetAndDestroyPushL(logEntries);
       
   389     scr.RetrieveLogEntriesL(logEntries);
       
   390 
       
   391     // 50 log items or less - ui spec
       
   392     TInt lastLog(0);
       
   393     if (logEntries.Count() > maxLogsCount) {
       
   394         lastLog = logEntries.Count() - maxLogsCount;
       
   395     }
       
   396     // iteration through most recent log to the last
       
   397     for (TInt i = logEntries.Count() - 1; i >= lastLog; i--) {
       
   398         CScrLogEntry* entry = logEntries[i];
       
   399         DetailMap logMap;
       
   400         logMap[CaSoftwareRegistry::componentNameKey()]
       
   401                = XQConversions::s60DescToQString(entry->ComponentName());
       
   402         logMap[CaSoftwareRegistry::componentVersionKey()]
       
   403                = XQConversions::s60DescToQString(entry->ComponentVersion());
       
   404         logMap[CaSoftwareRegistry::componentTimeKey()]
       
   405                = operationTime(entry->OperationTime());
       
   406         logMap[CaSoftwareRegistry::componentOperationTypeKey()]
       
   407                = operationTypeL(entry->OperationType());
       
   408         logList.append(logMap);
       
   409     }
       
   410     CleanupStack::PopAndDestroy(&logEntries);
       
   411     CleanupStack::PopAndDestroy(&scr);
       
   412 
       
   413     return logList;
       
   414 }
       
   415 
       
   416 /*!
       
   417  \param operation type.
       
   418  \return string representing operation type.
       
   419  */
       
   420 QString CaSoftwareRegistryPrivate::operationTypeL(int operationType) const
       
   421 {
       
   422     QString opType;
       
   423     switch (operationType) {
       
   424         case EScrCompInstall:
       
   425             opType = CaSoftwareRegistry::componentInstallValue();
       
   426             break;
       
   427         case EScrCompUnInstall:
       
   428             opType = CaSoftwareRegistry::componentUninstallValue();
       
   429             break;
       
   430         case EScrCompUpgrade:
       
   431             opType = CaSoftwareRegistry::componentUpgradeValue();
       
   432             break;
       
   433         case EScrCompHidden:
       
   434             opType = CaSoftwareRegistry::componentHiddenValue();
       
   435             break;
       
   436         default:
       
   437             User::Leave(KErrNotSupported);
       
   438             break;
       
   439     }
       
   440     return opType;
       
   441 }
       
   442 
       
   443 /*!
       
   444  \param operation type.
       
   445  \return string representing operation type.
       
   446  */
       
   447 QString CaSoftwareRegistryPrivate::operationTime(TTime time) const
       
   448 {
       
   449     TDateTime dt = time.DateTime();
       
   450     QDate date(dt.Year(), dt.Month() + 1, dt.Day() + 1);
       
   451     HbExtendedLocale hbLoc;
       
   452     return hbLoc.format(date, r_qtn_date_usual_with_zero);
       
   453 }