1 /* |
|
2 * Copyright (c) 2000 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: Implementation of applicationmanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AMPreInstallApp.h" |
|
19 #include <pathinfo.h> |
|
20 #include <driveinfo.h> |
|
21 #include "debug.h" |
|
22 #include <apmstd.h> //for KMaxDataTypeLength |
|
23 #include <sisregistrysession.h> |
|
24 #include <sisregistrypackage.h> |
|
25 #include <e32cmn.h> |
|
26 #include<utf.h> |
|
27 #include<sisregistryentry.h> |
|
28 #include <caf/caf.h> |
|
29 #include <apgcli.h> |
|
30 #include <SWInstDefs.h> |
|
31 |
|
32 using namespace NApplicationManagement; |
|
33 CAMPreInstallApp* CAMPreInstallApp::NewL() |
|
34 { |
|
35 CAMPreInstallApp* self = CAMPreInstallApp::NewLC(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 |
|
39 } |
|
40 CAMPreInstallApp* CAMPreInstallApp::NewLC() |
|
41 { |
|
42 CAMPreInstallApp *self = new ( ELeave ) CAMPreInstallApp( ); |
|
43 CleanupStack::PushL( self ) ; |
|
44 self->ConstructL() ; |
|
45 return self; |
|
46 |
|
47 } |
|
48 CAMPreInstallApp::CAMPreInstallApp() |
|
49 { |
|
50 } |
|
51 CAMPreInstallApp::~CAMPreInstallApp() |
|
52 { |
|
53 delete iStorage; |
|
54 iFs.Close(); |
|
55 #ifdef RD_MULTIPLE_DRIVE |
|
56 delete iInstallDocPathArray; |
|
57 #endif |
|
58 iPreInstalledAppParams.ResetAndDestroy(); |
|
59 } |
|
60 void CAMPreInstallApp::ConstructL() |
|
61 { |
|
62 iStorage = CDeliveryComponentStorage::NewL(); |
|
63 User::LeaveIfError(iFs.Connect() ); |
|
64 TPtrC mmcDrive(TParsePtrC( PathInfo::MemoryCardRootPath() ).Drive()); |
|
65 iPreInstallPath.Append(mmcDrive); |
|
66 iPreInstallPath.Append(KPreInstallPath); |
|
67 } |
|
68 void CAMPreInstallApp::GetPreInstalledAppsL(RPointerArray<TPreInstalledAppParams> &aPreInstalledAppParams) |
|
69 { |
|
70 |
|
71 MakeAllInstallPathsL(); |
|
72 ListPreInstalledAppL(); |
|
73 aPreInstalledAppParams = iPreInstalledAppParams; |
|
74 } |
|
75 |
|
76 |
|
77 void CAMPreInstallApp::ListPreInstalledAppL(const TDesC& installDocPath) |
|
78 { |
|
79 |
|
80 RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<<"); |
|
81 CDir* dir= NULL; |
|
82 TInt err = iFs.GetDir(installDocPath, KEntryAttNormal, ESortByName, dir); |
|
83 // _LIT(KInstallpath,"C:\\private\\10202dce\\"); |
|
84 //TInt err = iFs.GetDir(KInstallpath, KEntryAttNormal, ESortByName, dir); |
|
85 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: err in getting dir list : %d",err); |
|
86 |
|
87 if (err==KErrNone) |
|
88 { |
|
89 CleanupStack::PushL(dir); |
|
90 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: no of dir's : %d",dir->Count()); |
|
91 for (TInt i(0); i < dir->Count(); i++) |
|
92 { |
|
93 |
|
94 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< dir entry %d", i); |
|
95 TEntry entry; |
|
96 entry = (*dir)[i]; |
|
97 HBufC* pathAndName = HBufC::NewLC(installDocPath.Length() |
|
98 + entry.iName.Length() ); |
|
99 TPtr ptrPathAndName = pathAndName->Des(); |
|
100 ptrPathAndName.Append(installDocPath); |
|
101 ptrPathAndName.Append(entry.iName); |
|
102 |
|
103 HBufC* mimeType = HBufC::NewLC(KMaxDataTypeLength); |
|
104 //Recognize |
|
105 if (!RecognizeL(*pathAndName, mimeType)) |
|
106 { |
|
107 CleanupStack::PopAndDestroy(mimeType); |
|
108 CleanupStack::PopAndDestroy(pathAndName); |
|
109 continue; |
|
110 } |
|
111 |
|
112 #ifdef RD_MULTIPLE_DRIVE |
|
113 if ( TParsePtrC( installDocPath ).Path().CompareF(KPreInstallPath) == 0 ) |
|
114 #else |
|
115 if (installDocPath.CompareF(iPreInstallPath) == 0) |
|
116 #endif |
|
117 { |
|
118 |
|
119 RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< Entered installDocPath.CompareF(iPreInstallPath)"); |
|
120 Swi::RSisRegistrySession regSession; |
|
121 CleanupClosePushL(regSession); |
|
122 User::LeaveIfError(regSession.Connect() ); |
|
123 |
|
124 RArray<TUid> uids; |
|
125 CleanupClosePushL(uids); |
|
126 |
|
127 regSession.InstalledUidsL(uids); |
|
128 |
|
129 RFile temp; |
|
130 User::LeaveIfError(temp.Open(iFs, *pathAndName, |
|
131 EFileShareReadersOnly | EFileRead) ); |
|
132 CleanupClosePushL(temp); |
|
133 |
|
134 TUid appUid; |
|
135 TInt uidLen = sizeof(TInt32); |
|
136 TInt seekLen = sizeof(TInt32) + sizeof(TInt32); |
|
137 |
|
138 User::LeaveIfError(temp.Seek(ESeekStart, seekLen)); |
|
139 |
|
140 TPckg<TInt32> uid1(appUid.iUid); |
|
141 User::LeaveIfError(temp.Read(uid1, uidLen)); |
|
142 if (uid1.Length() != uidLen) |
|
143 { |
|
144 User::Leave(KErrUnderflow); |
|
145 } |
|
146 |
|
147 //checking whether this is installed or not |
|
148 TBool installed = regSession.IsInstalledL(appUid); |
|
149 Swi::RSisRegistryEntry registryEntry; |
|
150 TInt regEntryError = registryEntry.Open(regSession, appUid); |
|
151 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: RegEntryError : %d",regEntryError); |
|
152 |
|
153 //User::LeaveIfError(regEntryError); |
|
154 if (regEntryError == KErrNone) |
|
155 { |
|
156 CleanupClosePushL(registryEntry); |
|
157 TBool isPreInstalled = registryEntry.PreInstalledL(); |
|
158 RDEBUG_4("Clist_PreInstallAppUi: ListPreInstalledApp: UID is : '0x%X', installed:, preinstalled %d %d",appUid,installed,isPreInstalled); |
|
159 |
|
160 for (TInt i(0); isPreInstalled && i < uids.Count(); i++) |
|
161 { |
|
162 if (appUid == uids[i]) |
|
163 { |
|
164 |
|
165 RDEBUG("Clist_PreInstallAppUi: appUid == uids[i]"); |
|
166 Swi::CSisRegistryPackage* sisRegistry = NULL; |
|
167 TRAPD( err, sisRegistry = regSession.SidToPackageL( uids[i] ) ) ; |
|
168 //User::LeaveIfError(err); |
|
169 if(err == KErrNone) |
|
170 { |
|
171 |
|
172 RDEBUG("Clist_PreInstallAppUi: err == KErrNone"); |
|
173 TPreInstalledAppParams *params = |
|
174 new (ELeave) TPreInstalledAppParams; |
|
175 params->iPreInstalledAppame.Copy(sisRegistry->Name()); |
|
176 params->iPreInstalledAppVendorName.Copy( |
|
177 sisRegistry->Vendor()); |
|
178 params->iPreInstalledAppUid = sisRegistry->Uid(); |
|
179 params->iMimeType.Copy(*mimeType); |
|
180 //Get version |
|
181 TVersion version = registryEntry.VersionL(); |
|
182 TBuf8<KVersionLength> pkgDes; |
|
183 pkgDes.AppendNum(version.iMajor); |
|
184 pkgDes.Append(KLiteralPeriod); |
|
185 pkgDes.AppendNum(version.iMinor); |
|
186 params->iVersion.Copy(pkgDes); |
|
187 |
|
188 iPreInstalledAppParams.Append(params); |
|
189 |
|
190 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",appUid); |
|
191 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Name is: %S",&(sisRegistry->Name())); |
|
192 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Vendor is: %S",&(sisRegistry->Vendor())); |
|
193 RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",sisRegistry->Uid()); |
|
194 delete sisRegistry; |
|
195 } |
|
196 continue; |
|
197 } |
|
198 } |
|
199 |
|
200 CleanupStack::PopAndDestroy(®istryEntry); |
|
201 } |
|
202 CleanupStack::PopAndDestroy(&temp); |
|
203 CleanupStack::PopAndDestroy(&uids); |
|
204 CleanupStack::PopAndDestroy(®Session); |
|
205 CleanupStack::PopAndDestroy(mimeType); |
|
206 CleanupStack::PopAndDestroy(pathAndName); |
|
207 } |
|
208 } |
|
209 CleanupStack::PopAndDestroy(dir); |
|
210 } |
|
211 } |
|
212 void CAMPreInstallApp::ListPreInstalledAppL() |
|
213 { |
|
214 iPreInstalledAppParams.Reset(); |
|
215 #ifdef RD_MULTIPLE_DRIVE |
|
216 TInt count = iInstallDocPathArray->Count(); |
|
217 for ( TInt index(0); index < count; index++ ) |
|
218 { |
|
219 if ( (*iInstallDocPathArray)[index].Length()> 0 ) |
|
220 { |
|
221 ListPreInstalledAppL( (*iInstallDocPathArray)[index] ); |
|
222 } |
|
223 } |
|
224 #else |
|
225 if (iPreInstallDocumentPath.Length() > 0) |
|
226 { |
|
227 ListPreInstalledAppL(iPreInstallDocumentPath); |
|
228 } |
|
229 #endif |
|
230 } |
|
231 TBool CAMPreInstallApp::RecognizeL(TDesC& aPathAndName, HBufC* aMimeType) |
|
232 { |
|
233 TBool IsOK(ETrue); |
|
234 ContentAccess::CContent* pkgContent = ContentAccess::CContent::NewLC( |
|
235 aPathAndName, ContentAccess::EContentShareReadWrite); |
|
236 |
|
237 TPtr mimePtr(aMimeType->Des()); |
|
238 pkgContent->GetStringAttribute(ContentAccess::EMimeType, mimePtr); |
|
239 |
|
240 HBufC8* tmpMime8 = HBufC8::NewLC(aMimeType->Length()); |
|
241 tmpMime8->Des().Copy(*aMimeType); |
|
242 TPtr8 mimePtr8(tmpMime8->Des()); |
|
243 |
|
244 if ((mimePtr8 != SwiUI::KSisxMimeType) && (mimePtr8 |
|
245 != SwiUI::KSisMimeType) && (mimePtr8 != SwiUI::KPipMimeType)) |
|
246 { |
|
247 IsOK = EFalse; |
|
248 } |
|
249 CleanupStack::PopAndDestroy(tmpMime8); |
|
250 CleanupStack::PopAndDestroy(pkgContent); |
|
251 return IsOK; |
|
252 |
|
253 } |
|
254 void CAMPreInstallApp::MakeAllInstallPathsL() |
|
255 { |
|
256 #ifdef RD_MULTIPLE_DRIVE |
|
257 iInstallDocPathArray = new (ELeave) CDesCArrayFlat( 2 ); |
|
258 TDriveList driveList; |
|
259 TInt driveCount = 0; |
|
260 //User::LeaveIfError(iFs.Connect() ); |
|
261 User::LeaveIfError( DriveInfo::GetUserVisibleDrives(iFs, driveList,driveCount)); |
|
262 TUint driveStatus = 0; |
|
263 for (TInt index(0); index < KMaxDrives; index++) |
|
264 { |
|
265 if (driveList[index]) |
|
266 { |
|
267 User::LeaveIfError( DriveInfo::GetDriveStatus(iFs, index, |
|
268 driveStatus)); |
|
269 TFileName path; |
|
270 TDriveUnit driveUnit(index); |
|
271 if ( !(driveStatus & DriveInfo::EDriveRemote )) |
|
272 { |
|
273 if (driveStatus & DriveInfo::EDriveRemovable) |
|
274 { |
|
275 path.Zero(); |
|
276 path.Append(driveUnit.Name() ); |
|
277 path.Append(KPreInstallPath); |
|
278 iInstallDocPathArray->AppendL(path); |
|
279 } |
|
280 } |
|
281 } |
|
282 } |
|
283 //iFs.Close(); |
|
284 #else |
|
285 TPtrC mmcDrive(TParsePtrC( PathInfo::MemoryCardRootPath() ).Drive()); |
|
286 iPreInstallDocumentPath.Append(mmcDrive); |
|
287 iPreInstallDocumentPath.Append(KPreInstallPath); |
|
288 #endif //RD_MULTIPLE_DRIVE |
|
289 } |
|