94
|
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 |
*/
|
98
|
17 |
#include <HbParameterLengthLimiter>
|
94
|
18 |
#include <QMetaType>
|
|
19 |
#include <QScopedPointer>
|
98
|
20 |
#include <QStringList>
|
94
|
21 |
|
|
22 |
#include <usif/scr/scr.h>
|
|
23 |
#include <usif/scr/screntries.h>
|
|
24 |
#include <xqconversions.h>
|
96
|
25 |
#include <driveinfo.h>
|
94
|
26 |
|
|
27 |
#include "casoftwareregistry.h"
|
|
28 |
#include "casoftwareregistry_p.h"
|
|
29 |
|
|
30 |
using namespace Usif;
|
|
31 |
|
98
|
32 |
_LIT(KConfirmMessageKey, "MIDlet-Delete-Confirm");
|
|
33 |
|
94
|
34 |
template <typename RClass>
|
|
35 |
struct RClassDeleter
|
|
36 |
{
|
|
37 |
static inline void cleanup(RClass *ptr)
|
|
38 |
{
|
|
39 |
ptr->Close();
|
|
40 |
}
|
|
41 |
};
|
|
42 |
|
|
43 |
typedef QScopedPointer<RSoftwareComponentRegistry,
|
|
44 |
RClassDeleter<RSoftwareComponentRegistry> > ScrScopedPointer;
|
96
|
45 |
|
|
46 |
typedef QScopedPointer<RFs,
|
|
47 |
RClassDeleter<RFs> > RFSScopedPointer;
|
94
|
48 |
/*!
|
|
49 |
Constructor
|
|
50 |
\param servicePublic Pointer to object of the public class.
|
|
51 |
*/
|
|
52 |
CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate(
|
|
53 |
CaSoftwareRegistry *servicePublic):
|
|
54 |
m_q(servicePublic)
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
/*!
|
|
59 |
Destructor.
|
|
60 |
*/
|
|
61 |
CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
|
|
62 |
{
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
98
|
66 |
Provides details needed for uninstalling process of Java applications.
|
|
67 |
\param[in] componentId component id of an application to be uninstalled.
|
|
68 |
\param[out] componentName a name of the component.
|
|
69 |
\param[out] applicationsUids a list of uids of applications in the package
|
|
70 |
of the given component id.
|
|
71 |
\param[out] confirmationMessage optional deletion confirmation message,
|
|
72 |
null string means the lack of the message.
|
|
73 |
\retval true if there is no error.
|
|
74 |
*/
|
|
75 |
|
|
76 |
bool CaSoftwareRegistryPrivate::getUninstallDetails(int componentId,
|
|
77 |
QString &componentName,
|
|
78 |
QStringList &applicationsUids,
|
|
79 |
QString &confirmationMessage)
|
|
80 |
{
|
|
81 |
TRAPD(error, getUninstallDetailsL(componentId,
|
|
82 |
componentName,
|
|
83 |
applicationsUids,
|
|
84 |
confirmationMessage)
|
|
85 |
);
|
|
86 |
return error == KErrNone;
|
|
87 |
}
|
|
88 |
|
|
89 |
/*!
|
|
90 |
Provides a list of uids of applications installed by the given package.
|
|
91 |
\param[in] componentId component id of an application to be uninstalled.
|
|
92 |
\param[out] applicationsUids a list of uids of applications in the package
|
|
93 |
of the given component id.
|
|
94 |
\retval true if there is no error.
|
|
95 |
*/
|
|
96 |
|
|
97 |
bool CaSoftwareRegistryPrivate::getApplicationsUids(int componentId,
|
|
98 |
QStringList &applicationsUids)
|
|
99 |
{
|
|
100 |
TRAPD(error, getApplicationsUidsL(componentId, applicationsUids));
|
|
101 |
return error == KErrNone;
|
|
102 |
}
|
|
103 |
|
|
104 |
/*!
|
|
105 |
Provides details needed for uninstalling process of Java applications
|
|
106 |
(leaving version).
|
|
107 |
\param[in] componentId component id of an application to be uninstalled.
|
|
108 |
\param[out] componentName a name of the component.
|
|
109 |
\param[out] applicationsUids a list of uids of applications in the package
|
|
110 |
of the given component id.
|
|
111 |
\param[out] confirmationMessage optional deletion confirmation message,
|
|
112 |
null string means the lack of the message.
|
|
113 |
*/
|
|
114 |
void CaSoftwareRegistryPrivate::getUninstallDetailsL(int componentId,
|
|
115 |
QString &componentName,
|
|
116 |
QStringList &appUids,
|
|
117 |
QString &confirmationMessage)
|
|
118 |
{
|
|
119 |
componentName.clear();
|
|
120 |
appUids.clear();
|
|
121 |
confirmationMessage.clear();
|
|
122 |
|
|
123 |
if (componentId >= 1) {
|
|
124 |
TComponentId componentIdValue(componentId);
|
|
125 |
RArray<TUid> appUidsArray;
|
|
126 |
CleanupClosePushL(appUidsArray);
|
|
127 |
CLocalizablePropertyEntry *confirmationMessageProperty = NULL;
|
|
128 |
|
|
129 |
RSoftwareComponentRegistry softwareComponentRegistry;
|
|
130 |
CleanupClosePushL(softwareComponentRegistry);
|
|
131 |
User::LeaveIfError(softwareComponentRegistry.Connect());
|
|
132 |
|
|
133 |
CComponentEntry *entry = CComponentEntry::NewLC();
|
|
134 |
softwareComponentRegistry.GetComponentL(componentId, *entry);
|
|
135 |
softwareComponentRegistry.GetAppUidsForComponentL(componentIdValue,
|
|
136 |
appUidsArray);
|
|
137 |
|
|
138 |
CPropertyEntry *confirmationProperty =
|
|
139 |
softwareComponentRegistry.GetComponentPropertyL(componentId,
|
|
140 |
KConfirmMessageKey);
|
|
141 |
if (confirmationProperty &&
|
|
142 |
confirmationProperty->PropertyType() ==
|
|
143 |
CPropertyEntry::ELocalizedProperty) {
|
|
144 |
confirmationMessageProperty =
|
|
145 |
static_cast<CLocalizablePropertyEntry *>(
|
|
146 |
confirmationProperty);
|
|
147 |
} else {
|
|
148 |
delete confirmationProperty;
|
|
149 |
confirmationProperty = NULL;
|
|
150 |
}
|
|
151 |
|
|
152 |
QT_TRYCATCH_LEAVING(componentName =
|
|
153 |
XQConversions::s60DescToQString(entry->Name());
|
|
154 |
for (TInt i = 0; i<appUidsArray.Count(); i++) {
|
|
155 |
appUids.append(QString::number(appUidsArray[i].iUid));
|
|
156 |
}
|
|
157 |
if (confirmationMessageProperty) {
|
|
158 |
confirmationMessage = XQConversions::s60DescToQString(
|
|
159 |
confirmationMessageProperty->StrValue());
|
|
160 |
}
|
|
161 |
);
|
|
162 |
|
|
163 |
CleanupStack::PopAndDestroy(3, &appUidsArray);
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
/*!
|
|
168 |
Provides details needed for uninstalling process of Java applications
|
|
169 |
(leaving version).
|
|
170 |
\param[in] componentId component id of an application to be uninstalled.
|
|
171 |
\param[out] applicationsUids a list of uids of applications in the package
|
|
172 |
of the given component id.
|
|
173 |
*/
|
|
174 |
void CaSoftwareRegistryPrivate::getApplicationsUidsL(int componentId,
|
|
175 |
QStringList &appUids)
|
|
176 |
{
|
|
177 |
appUids.clear();
|
|
178 |
if (componentId >= 1) {
|
|
179 |
TComponentId componentIdValue(componentId);
|
|
180 |
RArray<TUid> appUidsArray;
|
|
181 |
CleanupClosePushL(appUidsArray);
|
|
182 |
|
|
183 |
RSoftwareComponentRegistry softwareComponentRegistry;
|
|
184 |
CleanupClosePushL(softwareComponentRegistry);
|
|
185 |
User::LeaveIfError(softwareComponentRegistry.Connect());
|
|
186 |
|
|
187 |
softwareComponentRegistry.GetAppUidsForComponentL(componentIdValue,
|
|
188 |
appUidsArray);
|
|
189 |
|
|
190 |
QT_TRYCATCH_LEAVING(
|
|
191 |
for (TInt i = 0; i<appUidsArray.Count(); i++) {
|
|
192 |
appUids.append(QString::number(appUidsArray[i].iUid));
|
|
193 |
}
|
|
194 |
);
|
|
195 |
CleanupStack::PopAndDestroy(2, &appUidsArray);
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
/*!
|
94
|
200 |
\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
|
|
202 |
empty map otherwise.
|
|
203 |
*/
|
|
204 |
CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
|
|
205 |
int componentId) const
|
|
206 |
{
|
|
207 |
CaSoftwareRegistry::DetailMap result;
|
|
208 |
|
|
209 |
if (componentId >= 1) {
|
96
|
210 |
RSoftwareComponentRegistry softwareComponentRegistry;
|
|
211 |
ScrScopedPointer scr(&softwareComponentRegistry);
|
98
|
212 |
if (scr->Connect() == KErrNone) {
|
|
213 |
|
|
214 |
QScopedPointer<CComponentEntry> entry;
|
|
215 |
|
|
216 |
QT_TRAP_THROWING(entry.reset(CComponentEntry::NewL()));
|
|
217 |
|
|
218 |
TBool resultCode = EFalse;
|
|
219 |
TRAPD(leaveCode, resultCode = scr->GetComponentL(componentId, *entry));
|
|
220 |
if (leaveCode == KErrNone && resultCode) {
|
|
221 |
result = entryDetails(*entry);
|
|
222 |
}
|
|
223 |
}
|
94
|
224 |
}
|
|
225 |
|
|
226 |
return result;
|
|
227 |
}
|
|
228 |
|
|
229 |
/*!
|
|
230 |
\param entry Software registry entry providing details.
|
|
231 |
\return Map with details for the component represented by \entry.
|
|
232 |
*/
|
|
233 |
CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
|
|
234 |
const CComponentEntry& entry) const
|
|
235 |
{
|
|
236 |
CaSoftwareRegistry::DetailMap detailMap;
|
|
237 |
|
|
238 |
detailMap[CaSoftwareRegistry::componentNameKey()] =
|
|
239 |
XQConversions::s60DescToQString(entry.Name());
|
|
240 |
|
|
241 |
detailMap[CaSoftwareRegistry::componentVersionKey()] =
|
|
242 |
XQConversions::s60DescToQString(entry.Version());
|
|
243 |
|
|
244 |
detailMap[CaSoftwareRegistry::componentVendorKey()] =
|
|
245 |
XQConversions::s60DescToQString(entry.Vendor());
|
|
246 |
|
|
247 |
QString drives;
|
98
|
248 |
QString drv;
|
|
249 |
TChar drive;
|
96
|
250 |
|
94
|
251 |
const TInt driveListLen(entry.InstalledDrives().Length());
|
|
252 |
for (TInt i( 0 ); i < driveListLen; ++i) {
|
|
253 |
if (entry.InstalledDrives()[i] != '\0') {
|
96
|
254 |
|
94
|
255 |
if (!drives.isEmpty()) {
|
|
256 |
drives = drives.append(",");
|
98
|
257 |
}
|
|
258 |
drv = QString(QChar('A'+ i)).append(":");
|
|
259 |
if(DriveInfo::GetDefaultDrive(
|
|
260 |
DriveInfo::EDefaultPhoneMemory, drive ) == KErrNone
|
96
|
261 |
&& QChar('A'+ i) == QChar(drive))
|
|
262 |
{
|
98
|
263 |
drives = drives.append(
|
|
264 |
HbParameterLengthLimiter("txt_applib_dialog_1_device_memory").arg(
|
|
265 |
QString(QChar('A'+ i)).append(":")));
|
96
|
266 |
}
|
98
|
267 |
else if(DriveInfo::GetDefaultDrive(
|
|
268 |
DriveInfo::EDefaultMassStorage, drive ) == KErrNone
|
96
|
269 |
&& QChar('A'+ i) == QChar(drive))
|
|
270 |
{
|
98
|
271 |
drives = drives.append(
|
|
272 |
HbParameterLengthLimiter("txt_applib_dialog_1_mass_storage").arg(
|
|
273 |
QString(QChar('A'+ i)).append(":")));
|
96
|
274 |
}
|
98
|
275 |
else if(DriveInfo::GetDefaultDrive(
|
|
276 |
DriveInfo::EDefaultRemovableMassStorage, drive ) == KErrNone
|
96
|
277 |
&& QChar('A'+ i) == QChar(drive))
|
|
278 |
{
|
|
279 |
RFs fs;
|
|
280 |
RFSScopedPointer fSPointer(&fs);
|
98
|
281 |
if (fs.Connect() == KErrNone) {
|
|
282 |
TInt driveNumber;
|
|
283 |
TVolumeInfo tv;
|
|
284 |
DriveInfo::GetDefaultDrive(
|
|
285 |
DriveInfo::EDefaultRemovableMassStorage, driveNumber );
|
|
286 |
qt_symbian_throwIfError(fs.Volume(tv, driveNumber));
|
|
287 |
if(tv.iName.Length()) {
|
|
288 |
drives = drives.append(
|
|
289 |
HbParameterLengthLimiter("txt_applib_dialog_1_2").arg(
|
|
290 |
QString(QChar('A'+ i)).append(":")).arg(
|
|
291 |
XQConversions::s60DescToQString(tv.iName)));
|
|
292 |
}
|
|
293 |
else {
|
|
294 |
drives = drives.append(
|
|
295 |
HbParameterLengthLimiter("txt_applib_dialog_1_memory_card").arg(
|
|
296 |
QString(QChar('A'+ i)).append(":")));
|
|
297 |
}
|
96
|
298 |
}
|
98
|
299 |
} else {
|
96
|
300 |
drives = drives.append(QChar('A'+ i)).append(":");
|
|
301 |
}
|
94
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
|
98
|
306 |
|
|
307 |
|
|
308 |
static const TInt64 KKilo = 1024;
|
|
309 |
static const TInt64 KMega = KKilo * KKilo;
|
|
310 |
if(entry.ComponentSize() >= KMega) {
|
|
311 |
detailMap[CaSoftwareRegistry::componentSizeKey()] =
|
|
312 |
HbParameterLengthLimiter("txt_applib_dialog_l1_mb").arg(QString().setNum(
|
|
313 |
static_cast<double>(entry.ComponentSize() / KMega)));
|
|
314 |
}
|
|
315 |
else {
|
|
316 |
detailMap[CaSoftwareRegistry::componentSizeKey()] =
|
|
317 |
HbParameterLengthLimiter("txt_applib_dialog_l1_kb").arg(QString().setNum(
|
|
318 |
static_cast<double>(entry.ComponentSize() / KKilo)));
|
|
319 |
}
|
|
320 |
|
94
|
321 |
|
|
322 |
detailMap[CaSoftwareRegistry::componentTypeKey()] =
|
|
323 |
XQConversions::s60DescToQString(entry.SoftwareType());
|
|
324 |
|
|
325 |
return detailMap;
|
|
326 |
}
|