|
1 /* |
|
2 * Copyright (c) 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: ?Description |
|
15 * |
|
16 */ |
|
17 #include <QtGlobal> |
|
18 #include <QMetaType> |
|
19 #include <QScopedPointer> |
|
20 #include <QString> |
|
21 |
|
22 #include <usif/scr/scr.h> |
|
23 #include <usif/scr/screntries.h> |
|
24 #include <xqconversions.h> |
|
25 |
|
26 #include "casoftwareregistry.h" |
|
27 #include "casoftwareregistry_p.h" |
|
28 |
|
29 using namespace Usif; |
|
30 |
|
31 template <typename RClass> |
|
32 struct RClassDeleter |
|
33 { |
|
34 static inline void cleanup(RClass *ptr) |
|
35 { |
|
36 ptr->Close(); |
|
37 } |
|
38 }; |
|
39 |
|
40 typedef QScopedPointer<RSoftwareComponentRegistry, |
|
41 RClassDeleter<RSoftwareComponentRegistry> > ScrScopedPointer; |
|
42 /*! |
|
43 Constructor |
|
44 \param servicePublic Pointer to object of the public class. |
|
45 */ |
|
46 CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate( |
|
47 CaSoftwareRegistry *servicePublic): |
|
48 m_q(servicePublic) |
|
49 { |
|
50 } |
|
51 |
|
52 /*! |
|
53 Destructor. |
|
54 */ |
|
55 CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate() |
|
56 { |
|
57 } |
|
58 |
|
59 /*! |
|
60 \param componentId Component id of the entry which details are requested for. |
|
61 \return Map of component details if component id was greater than 0 or |
|
62 empty map otherwise. |
|
63 */ |
|
64 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails( |
|
65 int componentId) const |
|
66 { |
|
67 CaSoftwareRegistry::DetailMap result; |
|
68 |
|
69 if (componentId >= 1) { |
|
70 ScrScopedPointer scr(new RSoftwareComponentRegistry); |
|
71 QT_TRAP_THROWING(User::LeaveIfError(scr->Connect())); |
|
72 |
|
73 QScopedPointer<CComponentEntry> entry; |
|
74 |
|
75 QT_TRAP_THROWING(entry.reset(CComponentEntry::NewL())); |
|
76 QT_TRAP_THROWING(scr->GetComponentL(componentId, *entry)); |
|
77 result = entryDetails(*entry); |
|
78 } |
|
79 |
|
80 return result; |
|
81 } |
|
82 |
|
83 /*! |
|
84 \param entry Software registry entry providing details. |
|
85 \return Map with details for the component represented by \entry. |
|
86 */ |
|
87 CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails( |
|
88 const CComponentEntry& entry) const |
|
89 { |
|
90 CaSoftwareRegistry::DetailMap detailMap; |
|
91 |
|
92 detailMap[CaSoftwareRegistry::componentNameKey()] = |
|
93 XQConversions::s60DescToQString(entry.Name()); |
|
94 |
|
95 detailMap[CaSoftwareRegistry::componentVersionKey()] = |
|
96 XQConversions::s60DescToQString(entry.Version()); |
|
97 |
|
98 detailMap[CaSoftwareRegistry::componentVendorKey()] = |
|
99 XQConversions::s60DescToQString(entry.Vendor()); |
|
100 |
|
101 QString drives; |
|
102 const TInt driveListLen(entry.InstalledDrives().Length()); |
|
103 for (TInt i( 0 ); i < driveListLen; ++i) { |
|
104 if (entry.InstalledDrives()[i] != '\0') { |
|
105 if (!drives.isEmpty()) { |
|
106 drives = drives.append(","); |
|
107 } |
|
108 drives = drives.append(QChar('A'+ i)).append(":"); |
|
109 } |
|
110 } |
|
111 |
|
112 detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives; |
|
113 detailMap[CaSoftwareRegistry::componentSizeKey()].setNum( |
|
114 entry.ComponentSize() / 1024); |
|
115 |
|
116 detailMap[CaSoftwareRegistry::componentTypeKey()] = |
|
117 XQConversions::s60DescToQString(entry.SoftwareType()); |
|
118 |
|
119 return detailMap; |
|
120 } |