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. |
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 } |