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 |
*/
|
|
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>
|
96
|
25 |
#include <driveinfo.h>
|
94
|
26 |
|
|
27 |
#include "casoftwareregistry.h"
|
|
28 |
#include "casoftwareregistry_p.h"
|
|
29 |
|
|
30 |
using namespace Usif;
|
|
31 |
|
|
32 |
template <typename RClass>
|
|
33 |
struct RClassDeleter
|
|
34 |
{
|
|
35 |
static inline void cleanup(RClass *ptr)
|
|
36 |
{
|
|
37 |
ptr->Close();
|
|
38 |
}
|
|
39 |
};
|
|
40 |
|
|
41 |
typedef QScopedPointer<RSoftwareComponentRegistry,
|
|
42 |
RClassDeleter<RSoftwareComponentRegistry> > ScrScopedPointer;
|
96
|
43 |
|
|
44 |
typedef QScopedPointer<RFs,
|
|
45 |
RClassDeleter<RFs> > RFSScopedPointer;
|
94
|
46 |
/*!
|
|
47 |
Constructor
|
|
48 |
\param servicePublic Pointer to object of the public class.
|
|
49 |
*/
|
|
50 |
CaSoftwareRegistryPrivate::CaSoftwareRegistryPrivate(
|
|
51 |
CaSoftwareRegistry *servicePublic):
|
|
52 |
m_q(servicePublic)
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
/*!
|
|
57 |
Destructor.
|
|
58 |
*/
|
|
59 |
CaSoftwareRegistryPrivate::~CaSoftwareRegistryPrivate()
|
|
60 |
{
|
|
61 |
}
|
|
62 |
|
|
63 |
/*!
|
|
64 |
\param componentId Component id of the entry which details are requested for.
|
|
65 |
\return Map of component details if component id was greater than 0 or
|
|
66 |
empty map otherwise.
|
|
67 |
*/
|
|
68 |
CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
|
|
69 |
int componentId) const
|
|
70 |
{
|
|
71 |
CaSoftwareRegistry::DetailMap result;
|
|
72 |
|
|
73 |
if (componentId >= 1) {
|
96
|
74 |
RSoftwareComponentRegistry softwareComponentRegistry;
|
|
75 |
ScrScopedPointer scr(&softwareComponentRegistry);
|
94
|
76 |
QT_TRAP_THROWING(User::LeaveIfError(scr->Connect()));
|
|
77 |
|
|
78 |
QScopedPointer<CComponentEntry> entry;
|
|
79 |
|
|
80 |
QT_TRAP_THROWING(entry.reset(CComponentEntry::NewL()));
|
|
81 |
QT_TRAP_THROWING(scr->GetComponentL(componentId, *entry));
|
|
82 |
result = entryDetails(*entry);
|
|
83 |
}
|
|
84 |
|
|
85 |
return result;
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
\param entry Software registry entry providing details.
|
|
90 |
\return Map with details for the component represented by \entry.
|
|
91 |
*/
|
|
92 |
CaSoftwareRegistryPrivate::DetailMap CaSoftwareRegistryPrivate::entryDetails(
|
|
93 |
const CComponentEntry& entry) const
|
|
94 |
{
|
|
95 |
CaSoftwareRegistry::DetailMap detailMap;
|
|
96 |
|
|
97 |
detailMap[CaSoftwareRegistry::componentNameKey()] =
|
|
98 |
XQConversions::s60DescToQString(entry.Name());
|
|
99 |
|
|
100 |
detailMap[CaSoftwareRegistry::componentVersionKey()] =
|
|
101 |
XQConversions::s60DescToQString(entry.Version());
|
|
102 |
|
|
103 |
detailMap[CaSoftwareRegistry::componentVendorKey()] =
|
|
104 |
XQConversions::s60DescToQString(entry.Vendor());
|
|
105 |
|
|
106 |
QString drives;
|
96
|
107 |
TChar drive;
|
|
108 |
|
94
|
109 |
const TInt driveListLen(entry.InstalledDrives().Length());
|
|
110 |
for (TInt i( 0 ); i < driveListLen; ++i) {
|
|
111 |
if (entry.InstalledDrives()[i] != '\0') {
|
96
|
112 |
|
94
|
113 |
if (!drives.isEmpty()) {
|
|
114 |
drives = drives.append(",");
|
96
|
115 |
}
|
|
116 |
|
|
117 |
if(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultPhoneMemory, drive ) == KErrNone
|
|
118 |
&& QChar('A'+ i) == QChar(drive))
|
|
119 |
{
|
|
120 |
drives = drives.append(QChar('A'+ i)).append(":").append(
|
|
121 |
" txt_applib_dialog_1_device_memory");
|
|
122 |
}
|
|
123 |
else if(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, drive ) == KErrNone
|
|
124 |
&& QChar('A'+ i) == QChar(drive))
|
|
125 |
{
|
|
126 |
drives = drives.append(QChar('A'+ i)).append(":").append(
|
|
127 |
" txt_applib_dialog_1_mass_storage");
|
|
128 |
}
|
|
129 |
else if(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, drive ) == KErrNone
|
|
130 |
&& QChar('A'+ i) == QChar(drive))
|
|
131 |
{
|
|
132 |
RFs fs;
|
|
133 |
RFSScopedPointer fSPointer(&fs);
|
|
134 |
qt_symbian_throwIfError(fs.Connect());
|
|
135 |
|
|
136 |
TInt driveNumber;
|
|
137 |
TVolumeInfo tv;
|
|
138 |
DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, driveNumber );
|
|
139 |
|
|
140 |
qt_symbian_throwIfError(fs.Volume(tv, driveNumber));
|
|
141 |
if(tv.iName.Length()) {
|
|
142 |
drives = drives.append(QChar('A'+ i)).append(": ").append(
|
|
143 |
XQConversions::s60DescToQString(tv.iName));
|
|
144 |
}
|
|
145 |
else {
|
|
146 |
drives = drives.append(QChar('A'+ i)).append(":").append(
|
|
147 |
" txt_applib_dialog_1_memory_card");
|
|
148 |
}
|
|
149 |
}
|
|
150 |
else {
|
|
151 |
drives = drives.append(QChar('A'+ i)).append(":");
|
|
152 |
}
|
94
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
detailMap[CaSoftwareRegistry::componentDriveInfoKey()] = drives;
|
|
157 |
detailMap[CaSoftwareRegistry::componentSizeKey()].setNum(
|
|
158 |
entry.ComponentSize() / 1024);
|
|
159 |
|
|
160 |
detailMap[CaSoftwareRegistry::componentTypeKey()] =
|
|
161 |
XQConversions::s60DescToQString(entry.SoftwareType());
|
|
162 |
|
|
163 |
return detailMap;
|
|
164 |
}
|