contentstorage/casoftwareregistry/s60/src/casoftwareregistry_p.cpp
changeset 127 7b66bc3c6dc9
parent 125 26079c1bb561
equal deleted inserted replaced
126:efda7c0771b9 127:7b66bc3c6dc9
    18 #include <HbExtendedLocale>
    18 #include <HbExtendedLocale>
    19 #include <QMetaType>
    19 #include <QMetaType>
    20 #include <QScopedPointer>
    20 #include <QScopedPointer>
    21 #include <QStringList>
    21 #include <QStringList>
    22 #include <QDateTime>
    22 #include <QDateTime>
    23 #undef SYMBIAN_ENABLE_SPLIT_HEADERS //TODO this is work around
       
    24 #include <usif/scr/screntries.h>
       
    25 #include <usif/scr/scr.h>
    23 #include <usif/scr/scr.h>
    26 #include <xqconversions.h>
    24 #include <xqconversions.h>
    27 #include <driveinfo.h>
    25 #include <driveinfo.h>
    28 #include <hbtextresolversymbian.h>
    26 #include <hbtextresolversymbian.h>
    29 
    27 
    33 #include "casoftwareregistry_p.h"
    31 #include "casoftwareregistry_p.h"
    34 #include "cadefs.h"
    32 #include "cadefs.h"
    35 #include "caarraycleanup.inl"
    33 #include "caarraycleanup.inl"
    36 #include "cautils.h"
    34 #include "cautils.h"
    37 
    35 
       
    36 
    38 using namespace Usif;
    37 using namespace Usif;
    39 _LIT(KConfirmMessageKey, "MIDlet-Delete-Confirm");
    38 _LIT(KConfirmMessageKey, "MIDlet-Delete-Confirm");
    40 _LIT(KCaScrPropertyDomainCategory, "Domain-Category");
    39 _LIT(KCaScrPropertyDomainCategory, "Domain-Category");
    41 _LIT(KCaScrPropertyMidletDescryption, "MIDlet-Description");
    40 _LIT(KCaScrPropertyMidletDescryption, "MIDlet-Description");
    42 _LIT(KNotNamedMmc, "NO NAME");
    41 _LIT(KNotNamedMmc, "NO NAME");
    43 const int maxLogsCount = 20;  // should be 50 - workaround for
    42 
    44 // ou1cimx1#476143 Dialog crash when label contains big amount of lines
    43 const int maxLogsCount = 50;
       
    44 const TInt64 KLongKilo = 1024;
       
    45 const TInt64 KLongMega = KLongKilo * KLongKilo;
    45 
    46 
    46 /*!
    47 /*!
    47  Constructor
    48  Constructor
    48  \param servicePublic Pointer to object of the public class.
    49  \param servicePublic Pointer to object of the public class.
    49  */
    50  */
    56 /*!
    57 /*!
    57  Destructor.
    58  Destructor.
    58  */
    59  */
    59 CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
    60 CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
    60 {
    61 {
    61 
       
    62 }
    62 }
    63 
    63 
    64 /*!
    64 /*!
    65  Provides details needed for uninstalling process of Java applications.
    65  Provides details needed for uninstalling process of Java applications.
    66  \param[in] componentId component id of an application to be uninstalled.
    66  \param[in] componentId component id of an application to be uninstalled.
    71       null string means the lack of the message.
    71       null string means the lack of the message.
    72  \retval true if there is no error.
    72  \retval true if there is no error.
    73  */
    73  */
    74 
    74 
    75 bool CaSoftwareRegistryPrivate::getUninstallDetails(int componentId,
    75 bool CaSoftwareRegistryPrivate::getUninstallDetails(int componentId,
    76         QString &componentName,
    76         QString &componentName, QStringList &applicationsUids,
    77         QStringList &applicationsUids,
       
    78         QString &confirmationMessage)
    77         QString &confirmationMessage)
    79 {
    78 {
    80     TRAPD(error, getUninstallDetailsL(componentId,
    79     TRAPD(error, getUninstallDetailsL(
    81             componentName,
    80             componentId, componentName, applicationsUids, confirmationMessage)
    82             applicationsUids,
       
    83             confirmationMessage)
       
    84              );
    81              );
    85     return error == KErrNone;
    82     return error == KErrNone;
    86 }
    83 }
    87 
    84 
    88 /*!
    85 /*!
   109       of the given component id.
   106       of the given component id.
   110  \param[out] confirmationMessage optional deletion confirmation message,
   107  \param[out] confirmationMessage optional deletion confirmation message,
   111       null string means the lack of the message.
   108       null string means the lack of the message.
   112  */
   109  */
   113 void CaSoftwareRegistryPrivate::getUninstallDetailsL(int componentId,
   110 void CaSoftwareRegistryPrivate::getUninstallDetailsL(int componentId,
   114         QString &componentName,
   111         QString &componentName, QStringList &appUids,
   115         QStringList &appUids,
       
   116         QString &confirmationMessage)
   112         QString &confirmationMessage)
   117 {
   113 {
   118     componentName.clear();
   114     if (componentId > 0) {
   119     appUids.clear();
       
   120     confirmationMessage.clear();
       
   121 
       
   122     if (componentId >= 1) {
       
   123         TComponentId componentIdValue(componentId);
   115         TComponentId componentIdValue(componentId);
   124         RArray<TUid> appUidsArray;
   116         RArray<TUid> appUidsArray;
   125         CleanupClosePushL(appUidsArray);
   117         CleanupClosePushL(appUidsArray);
   126         CLocalizablePropertyEntry *confirmationMessageProperty = NULL;
   118         CLocalizablePropertyEntry *confirmationMessageProperty = NULL;
   127 
   119 
   146         } else {
   138         } else {
   147             delete confirmationProperty;
   139             delete confirmationProperty;
   148             confirmationProperty = NULL;
   140             confirmationProperty = NULL;
   149         }
   141         }
   150 
   142 
       
   143         appUids.clear();
   151         QT_TRYCATCH_LEAVING(componentName =
   144         QT_TRYCATCH_LEAVING(componentName =
   152             XQConversions::s60DescToQString(entry->Name());
   145             XQConversions::s60DescToQString(entry->Name());
   153             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   146             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   154                 appUids.append(QString::number(appUidsArray[i].iUid));
   147                 appUids.append(QString::number(appUidsArray[i].iUid));
   155             }
   148             }
   171       of the given component id.
   164       of the given component id.
   172  */
   165  */
   173 void CaSoftwareRegistryPrivate::getApplicationsUidsL(int componentId,
   166 void CaSoftwareRegistryPrivate::getApplicationsUidsL(int componentId,
   174     QStringList &appUids)
   167     QStringList &appUids)
   175 {
   168 {
   176     appUids.clear();
   169     if (componentId > 0) {
   177     if (componentId >= 1) {
       
   178         TComponentId componentIdValue(componentId);
   170         TComponentId componentIdValue(componentId);
   179         RArray<TUid> appUidsArray;
   171         RArray<TUid> appUidsArray;
   180         CleanupClosePushL(appUidsArray);
   172         CleanupClosePushL(appUidsArray);
   181 
   173 
   182         RSoftwareComponentRegistry softwareComponentRegistry;
   174         RSoftwareComponentRegistry softwareComponentRegistry;
   184         User::LeaveIfError(softwareComponentRegistry.Connect());
   176         User::LeaveIfError(softwareComponentRegistry.Connect());
   185 
   177 
   186         softwareComponentRegistry.GetAppUidsForComponentL(
   178         softwareComponentRegistry.GetAppUidsForComponentL(
   187                 componentIdValue, appUidsArray);
   179                 componentIdValue, appUidsArray);
   188 
   180 
       
   181         appUids.clear();
   189         QT_TRYCATCH_LEAVING(
   182         QT_TRYCATCH_LEAVING(
   190             for (TInt i = 0; i<appUidsArray.Count(); i++) {
   183             for (TInt i = 0; i < appUidsArray.Count(); i++) {
   191                 appUids.append(QString::number(appUidsArray[i].iUid));
   184                 appUids.append(QString::number(appUidsArray[i].iUid));
   192             }
   185             }
   193         );
   186         );
   194         CleanupStack::PopAndDestroy(2, &appUidsArray);
   187         CleanupStack::PopAndDestroy(2, &appUidsArray);
   195     }
   188     }
   202  */
   195  */
   203 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
   196 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
   204     int componentId) const
   197     int componentId) const
   205 {
   198 {
   206     CaSoftwareRegistry::DetailMap result;
   199     CaSoftwareRegistry::DetailMap result;
   207     TRAP_IGNORE(result=entryDetailsL(componentId));
   200     TRAP_IGNORE(result = entryDetailsL(componentId));
   208     return result;
   201     return result;
   209 }
   202 }
   210 
   203 
   211 /*!
   204 /*!
   212  \param componentId Component id of the entry which details are requested for.
   205  \param componentId Component id of the entry which details are requested for.
   225             CComponentEntry* entry = CComponentEntry::NewLC();
   218             CComponentEntry* entry = CComponentEntry::NewLC();
   226             if (scr.GetComponentL(componentId, *entry)) {
   219             if (scr.GetComponentL(componentId, *entry)) {
   227                 result = entryDetailsL(*entry);
   220                 result = entryDetailsL(*entry);
   228                 if (entry->SoftwareType().Compare(KSoftwareTypeJava) == 0) {
   221                 if (entry->SoftwareType().Compare(KSoftwareTypeJava) == 0) {
   229                     CPropertyEntry* domainProperty =
   222                     CPropertyEntry* domainProperty =
   230                         scr.GetComponentPropertyL(componentId,
   223                             scr.GetComponentPropertyL(componentId,
   231                             KCaScrPropertyDomainCategory);
   224                                     KCaScrPropertyDomainCategory);
   232                     CleanupStack::PushL(domainProperty);
   225                     CleanupStack::PushL(domainProperty);
   233                     if (domainProperty &&
   226                     if (domainProperty
   234                         domainProperty->PropertyType() ==
   227                             && domainProperty->PropertyType()
   235                             CPropertyEntry::ELocalizedProperty) {
   228                                 == CPropertyEntry::ELocalizedProperty) {
   236                         const TDesC& domainPropertyValue = static_cast<CLocalizablePropertyEntry*>(
   229                         const TDesC& domainPropertyValue = static_cast<CLocalizablePropertyEntry*>(
   237                                 domainProperty)->StrValue();
   230                                 domainProperty)->StrValue();
   238                         TInt splitIndex = domainPropertyValue.Locate(',');
   231                         TInt splitIndex = domainPropertyValue.Locate(',');
   239                         RBuf qmFileName;
   232                         RBuf qmFileName;
   240                         qmFileName.CleanupClosePushL();
   233                         qmFileName.CleanupClosePushL();
   294 
   287 
   295     QString drives;
   288     QString drives;
   296     TChar drive;
   289     TChar drive;
   297 
   290 
   298     const TInt driveListLen(entry.InstalledDrives().Length());
   291     const TInt driveListLen(entry.InstalledDrives().Length());
   299     for (TInt i( 0 ); i < driveListLen; ++i) {
   292     for (TInt i = 0; i < driveListLen; i++) {
   300         if (entry.InstalledDrives()[i] != '\0') {
   293         if (entry.InstalledDrives()[i] != '\0') {
   301 
   294 
   302             if (!drives.isEmpty()) {
   295             if (!drives.isEmpty()) {
   303                 drives = drives.append("\n");
   296                 drives = drives.append("\n");
   304             }
   297             }
   345             }
   338             }
   346         }
   339         }
   347     }
   340     }
   348     detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
   341     detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
   349 
   342 
   350     static const TInt64 KKilo = 1024;
   343     if(entry.ComponentSize() >= KLongMega) {
   351     static const TInt64 KMega = KKilo * KKilo;
       
   352     if(entry.ComponentSize() >= KMega) {
       
   353         detailMap[CaSoftwareRegistry::componentSizeKey()]
   344         detailMap[CaSoftwareRegistry::componentSizeKey()]
   354                   = HbParameterLengthLimiter("txt_applib_dialog_l1_mb").arg(
   345                   = HbParameterLengthLimiter("txt_applib_dialog_l1_mb").arg(
   355                           static_cast<double>(entry.ComponentSize() / KMega));
   346                           static_cast<double>(entry.ComponentSize()/KLongMega));
   356     } else {
   347     } else {
   357         detailMap[CaSoftwareRegistry::componentSizeKey()]
   348         detailMap[CaSoftwareRegistry::componentSizeKey()]
   358                   = HbParameterLengthLimiter("txt_applib_dialog_l1_kb").arg(
   349                   = HbParameterLengthLimiter("txt_applib_dialog_l1_kb").arg(
   359                           static_cast<double>(entry.ComponentSize() / KKilo));
   350                           static_cast<double>(entry.ComponentSize()/KLongKilo));
   360     }
   351     }
   361     detailMap[CaSoftwareRegistry::componentTypeKey()] =
   352     detailMap[CaSoftwareRegistry::componentTypeKey()] =
   362         XQConversions::s60DescToQString(entry.SoftwareType());
   353         XQConversions::s60DescToQString(entry.SoftwareType());
   363 
   354 
   364     return detailMap;
   355     return detailMap;
   428 
   419 
   429 /*!
   420 /*!
   430  \param operation type.
   421  \param operation type.
   431  \return string representing operation type.
   422  \return string representing operation type.
   432  */
   423  */
   433 QString CaSoftwareRegistryPrivate::operationTypeL(int operationType) const
   424 QString CaSoftwareRegistryPrivate::operationTypeL(
       
   425         Usif::TScrComponentOperationType operationType) const
   434 {
   426 {
   435     QString opType;
   427     QString opType;
   436     switch (operationType) {
   428     switch (operationType) {
   437         case EScrCompInstall:
   429         case EScrCompInstall:
   438             opType = CaSoftwareRegistry::componentInstallValue();
   430             opType = CaSoftwareRegistry::componentInstallValue();