|
1 /* |
|
2 * Copyright (c) 2008-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 the License "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: |
|
15 * Defines the class which implements SCR's service requests. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 #include "scrrequestimpl.h" |
|
27 #include "scrdatabase.h" |
|
28 #include "screntries.h" |
|
29 #include "scrserver.h" |
|
30 #include "scrcommon.h" |
|
31 #include "scrsubsession.h" |
|
32 #include "usiflog.h" |
|
33 #include "usiferror.h" |
|
34 #include "scrrepository.h" |
|
35 #include <s32mem.h> |
|
36 #include <bautils.h> |
|
37 #include <scs/streamingarray.h> |
|
38 #include <scs/ipcstream.h> |
|
39 #include <scs/ipcstream.inl> |
|
40 #include <scs/cleanuputils.h> |
|
41 #include <e32hashtab.h> |
|
42 #include <usif/sts/sts.h> |
|
43 |
|
44 using namespace Usif; |
|
45 |
|
46 _LIT(KComponentIdColumnName, "ComponentId"); |
|
47 _LIT(KCompFileIdColumnName, "CmpFileId"); |
|
48 _LIT(KAppIdColumnName, "AppUid"); |
|
49 _LIT(KComponentPropertiesTable, "ComponentProperties"); |
|
50 _LIT(KFilePropertiesTable, "FileProperties"); |
|
51 _LIT(KFileOwnershipInfoTable, "FileOwnershipInfo"); |
|
52 _LIT(KServiceInfoTable, "ServiceInfo"); |
|
53 _LIT(KLocalizableAppInfoTable, "LocalizableAppInfo"); |
|
54 _LIT(KViewDataTable, "ViewData"); |
|
55 _LIT(KAppRegistrationInfoTable, "AppRegistrationInfo"); |
|
56 _LIT(KAppPropertiesTable, "AppProperties"); |
|
57 |
|
58 |
|
59 /** Maximum number of log records could be recorded by SCR. */ |
|
60 // It is estimated that a thousand log entries create 40K-100K log file. |
|
61 const TInt KMaxScrLogEntries = 1000; |
|
62 /** The file path of SCR log file. */ |
|
63 _LIT(KScrLogFileName, "!:\\private\\10285bc0\\scr.log"); |
|
64 /** The file path of SCR temporary log file. */ |
|
65 _LIT(KScrTempLogFileName, "!:\\private\\10285bc0\\scr_tmp.log"); |
|
66 |
|
67 const TUint KDbInterfaceMajorVersion = 1; |
|
68 const TUint KDbInterfaceMinorVersion = 1; |
|
69 #ifdef _DEBUG |
|
70 const TUint KDbInterfaceBuildNumber = 1; |
|
71 #endif |
|
72 |
|
73 enum TScrPanicId |
|
74 { |
|
75 KScrIllegalCallSequence = 1, |
|
76 KScrIllegalParameter = 2 |
|
77 }; |
|
78 |
|
79 static void PanicClient(const RMessagePtr2& aMessage, TScrPanicId aPanic) |
|
80 { |
|
81 _LIT(KPanicMessage, "ScrServer"); |
|
82 aMessage.Panic(KPanicMessage, aPanic); |
|
83 } |
|
84 |
|
85 HBufC* UpdateFilePathDriveLC(const TDesC& aFilePath, TChar aDrive) |
|
86 { |
|
87 HBufC *fileName = HBufC::NewLC(aFilePath.Length()); |
|
88 TPtr ptrFileName(fileName->Des()); |
|
89 ptrFileName.Copy(aFilePath); |
|
90 ptrFileName[0] = aDrive; |
|
91 return fileName; |
|
92 } |
|
93 |
|
94 //////////////////////// |
|
95 // CScrRequestImpl |
|
96 //////////////////////// |
|
97 |
|
98 CScrRequestImpl::CScrRequestImpl(RFs& aFs) |
|
99 : iFs(aFs) |
|
100 { |
|
101 } |
|
102 |
|
103 CScrRequestImpl::~CScrRequestImpl() |
|
104 { |
|
105 delete iDbHandle; |
|
106 delete iComponentEntry; |
|
107 iProperties.ResetAndDestroy(); |
|
108 delete iSingleProperty; |
|
109 iFileComponents.Close(); |
|
110 iVerCompIdList.ResetAndDestroy(); |
|
111 iDeletedMimeTypes.ResetAndDestroy(); |
|
112 iLogEntries.ResetAndDestroy(); |
|
113 iMatchingSupportedLanguageList.Close(); |
|
114 |
|
115 //Delete the instance of CScrRepository, if present. |
|
116 CScrRepository::DeleteRepositoryInstance(); |
|
117 } |
|
118 |
|
119 CScrRequestImpl* CScrRequestImpl::CScrRequestImpl::NewL(RFs& aFs, RFile& aDatabaseFile, RFile& aJournalFile) |
|
120 { |
|
121 CScrRequestImpl *self = new(ELeave) CScrRequestImpl(aFs); |
|
122 CleanupStack::PushL(self); |
|
123 self->ConstructL(aDatabaseFile, aJournalFile); |
|
124 CleanupStack::Pop(self); |
|
125 return self; |
|
126 } |
|
127 |
|
128 void CScrRequestImpl::ConstructL(RFile& aDatabaseFile, RFile& aJournalFile) |
|
129 { |
|
130 iDbHandle = CDatabase::NewL(aDatabaseFile, aJournalFile); |
|
131 InitializeDbVersionL(); |
|
132 VerifyDbVersionCompatibilityL(); |
|
133 // Make sure that private directory exists - required for temporary and log files |
|
134 _LIT(KPrivateDirPath, "!:\\private\\10285bc0\\"); |
|
135 HBufC* privateDirPath = UpdateFilePathDriveLC(KPrivateDirPath, iFs.GetSystemDriveChar()); |
|
136 TInt res = iFs.MkDirAll(*privateDirPath); |
|
137 __ASSERT_ALWAYS(res == KErrNone || res == KErrAlreadyExists, User::Leave(res)); |
|
138 CleanupStack::PopAndDestroy(privateDirPath); |
|
139 } |
|
140 |
|
141 HBufC* CScrRequestImpl::ReadDescLC(const RMessage2& aMessage, TInt aSlot) |
|
142 { |
|
143 TInt len = aMessage.GetDesLengthL(aSlot); |
|
144 HBufC* desc = HBufC::NewLC(len); |
|
145 TPtr ptrDesc(desc->Des()); |
|
146 aMessage.ReadL(aSlot, ptrDesc); |
|
147 return desc; |
|
148 } |
|
149 |
|
150 HBufC8* CScrRequestImpl::ReadDesc8LC(const RMessage2& aMessage, TInt aSlot) |
|
151 { |
|
152 TInt len = aMessage.GetDesLengthL(aSlot); |
|
153 HBufC8* desc = HBufC8::NewLC(len); |
|
154 TPtr8 ptrDesc(desc->Des()); |
|
155 aMessage.ReadL(aSlot, ptrDesc); |
|
156 return desc; |
|
157 } |
|
158 |
|
159 HBufC* CScrRequestImpl::FormatStatementLC(const TDesC& aStatement, TInt aFormattedLength,...) const |
|
160 { |
|
161 VA_LIST list; |
|
162 VA_START(list, aFormattedLength); |
|
163 HBufC* statementStr = HBufC::NewLC(aStatement.Length() + aFormattedLength + 1); |
|
164 TPtr statementStrPtr(statementStr->Des()); |
|
165 statementStrPtr.FormatList(aStatement, list); |
|
166 VA_END(list); |
|
167 |
|
168 // SQLite requires the statement string to end with NULL char. |
|
169 statementStrPtr.Append('\0'); |
|
170 return statementStr; |
|
171 } |
|
172 |
|
173 void CScrRequestImpl::CreateTransactionL() |
|
174 { |
|
175 DEBUG_PRINTF(_L8("Create Transaction request received.")); |
|
176 _LIT(KBeginTransaction, "BEGIN IMMEDIATE;"); |
|
177 ExecuteStatementL(KBeginTransaction()); |
|
178 DEBUG_PRINTF(_L8("Transaction has begun!")); |
|
179 } |
|
180 |
|
181 void CScrRequestImpl::RollbackTransactionL() |
|
182 { |
|
183 DEBUG_PRINTF(_L8("Rollback Transaction request received.")); |
|
184 _LIT(KRollbackTransaction, "ROLLBACK;"); |
|
185 ExecuteStatementL(KRollbackTransaction()); |
|
186 DEBUG_PRINTF(_L8("Transaction has been rolled back successfuly!")); |
|
187 } |
|
188 |
|
189 void CScrRequestImpl::CommitTransactionL() |
|
190 { |
|
191 DEBUG_PRINTF(_L8("Commit Transaction request received.")); |
|
192 _LIT(KCommitTransaction, "COMMIT;"); |
|
193 ExecuteStatementL(KCommitTransaction()); |
|
194 DEBUG_PRINTF(_L8("Transaction has been committed successfully!")); |
|
195 } |
|
196 |
|
197 HBufC* CScrRequestImpl::GenerateGlobalIdL(const TDesC& aUniqueSwTypeName, const TDesC& aGlobalId) const |
|
198 { |
|
199 DEBUG_PRINTF(_L8("Generating Global ID.")); |
|
200 HBufC *globalIdBuf = HBufC::NewL(aUniqueSwTypeName.Length() + aGlobalId.Length() + 1); // 1 is extra memory to put NULL char |
|
201 TPtr globalIdDes(globalIdBuf->Des()); |
|
202 |
|
203 globalIdDes.Copy(aUniqueSwTypeName); |
|
204 globalIdDes.Append('\0'); |
|
205 globalIdDes.Append(aGlobalId); |
|
206 |
|
207 return globalIdBuf; |
|
208 } |
|
209 |
|
210 TComponentId CScrRequestImpl::CommonAddComponentL(const TDesC& aUniqueSwTypeName, const TDesC& aGlobalId) |
|
211 { |
|
212 DEBUG_PRINTF(_L8("Adding a base component.")); |
|
213 // Get the current time |
|
214 TTime time; |
|
215 time.HomeTime(); |
|
216 TDateTime datetime = time.DateTime(); |
|
217 TBuf<16> installTime; |
|
218 // We cannot use TTime::FormatL, since it starts months and days with 01, which is not accepted by TTime::Set() which starts them from 0 |
|
219 installTime.Format(_L("%04d%02d%02d:%02d%02d%02d"), datetime.Year(), datetime.Month(), datetime.Day(), datetime.Hour(), datetime.Minute(), datetime.Second()); |
|
220 |
|
221 // SoftwareTypeId is the hash of unique software type name. For more information, see CScrRequestImpl::AddSoftwareTypeL. |
|
222 // In Components table, both SoftwareTypeId and unique SoftwareTypeName is stored so that the software type name of a component |
|
223 // can be returned even if the corresponding installer (software type) has been uninstalled. The unique sofware type name |
|
224 // might be used by the client to identify the installer required to uninstall the component. |
|
225 TUint32 swTypeId = HashCaseSensitiveL(aUniqueSwTypeName); |
|
226 |
|
227 if(aGlobalId.CompareF(KNullDesC())) |
|
228 { // Global Id is supplied by client |
|
229 HBufC *globalId = GenerateGlobalIdL(aUniqueSwTypeName, aGlobalId); |
|
230 CleanupStack::PushL(globalId); |
|
231 TUint32 globalIdHash = HashCaseSensitiveL(*globalId); |
|
232 |
|
233 _LIT(KInsertComponent,"INSERT INTO Components(SoftwareTypeId,SoftwareTypeName,GlobalIdHash,GlobalId,InstallTime) VALUES(?,?,?,?,?);"); |
|
234 TInt numberOfValues = 5; |
|
235 ExecuteStatementL(KInsertComponent(), numberOfValues, EValueInteger, swTypeId, EValueString, &aUniqueSwTypeName, EValueInteger, globalIdHash, EValueString, globalId, EValueString, &installTime); |
|
236 CleanupStack::PopAndDestroy(globalId); |
|
237 } |
|
238 else |
|
239 {// Global Id is NOT supplied by client |
|
240 _LIT(KInsertComponent,"INSERT INTO Components(SoftwareTypeId,SoftwareTypeName,InstallTime) VALUES(?,?,?);"); |
|
241 TInt numberOfValues = 3; |
|
242 ExecuteStatementL(KInsertComponent(), numberOfValues, EValueInteger, swTypeId, EValueString, &aUniqueSwTypeName, EValueString, &installTime); |
|
243 } |
|
244 |
|
245 DEBUG_PRINTF(_L8("The new component has been added to Components table successfully.")); |
|
246 return iDbHandle->LastInsertedIdL(); |
|
247 } |
|
248 |
|
249 void CScrRequestImpl::AddComponentLocalizablesL(TComponentId aCompId, TLanguage aLocale, const TDesC& aName, const TDesC& aVendor) |
|
250 { |
|
251 DEBUG_PRINTF4(_L("Adding the component(%d) localizables: name(%S) and vendor(%S)."), aCompId, &aName, &aVendor); |
|
252 |
|
253 if(!aName.CompareF(KNullDesC())) |
|
254 {// Component name cannot be empty |
|
255 DEBUG_PRINTF(_L8("Component name cannot be NULL string.")); |
|
256 User::Leave(KErrArgument); |
|
257 } |
|
258 |
|
259 _LIT(KInsertComponentLocalizables, "INSERT INTO ComponentLocalizables(ComponentId,Locale,Name,Vendor) VALUES(?,?,?,?);"); |
|
260 TInt numberOfValues = 4; |
|
261 ExecuteStatementL(KInsertComponentLocalizables(), numberOfValues, EValueInteger, aCompId, EValueInteger, aLocale, EValueString, &aName, EValueString, &aVendor); |
|
262 |
|
263 DEBUG_PRINTF(_L8("The component localizables have been added successfully.")); |
|
264 } |
|
265 |
|
266 void CScrRequestImpl::ComponentRollback(TAny* aParam) |
|
267 { |
|
268 TRollbackParams *param = static_cast<TRollbackParams*>(aParam); |
|
269 _LIT(KDeleteComponents, "DELETE FROM Components WHERE ComponentId=?;"); |
|
270 TInt numberOfValues = 1; |
|
271 TRAP_IGNORE(param->iReqImplHandle.ExecuteStatementL(KDeleteComponents, numberOfValues, EValueInteger, param->iIdColumnVal);); |
|
272 } |
|
273 |
|
274 void CScrRequestImpl::ComponentLocalizablesRollback(TAny* aParam) |
|
275 { |
|
276 TRollbackParams *param = static_cast<TRollbackParams*>(aParam); |
|
277 _LIT(KDeleteComponentLocalizables, "DELETE FROM ComponentLocalizables WHERE ComponentId=?;"); |
|
278 TInt numberOfValues = 1; |
|
279 TRAP_IGNORE(param->iReqImplHandle.ExecuteStatementL(KDeleteComponentLocalizables, numberOfValues, EValueInteger, param->iIdColumnVal);); |
|
280 } |
|
281 |
|
282 void CScrRequestImpl::AddComponentL(const RMessage2& aMessage) |
|
283 { |
|
284 DEBUG_PRINTF(_L8("Adding a new component.")); |
|
285 // First check if the supplied operation type is valid |
|
286 TScrComponentOperationType compOpType; |
|
287 TPckg<TScrComponentOperationType> opTypePckg(compOpType); |
|
288 aMessage.ReadL(3, opTypePckg, 0); |
|
289 |
|
290 if(compOpType != EScrCompInstall && compOpType != EScrCompUpgrade && compOpType != EScrCompHidden) |
|
291 { |
|
292 DEBUG_PRINTF2(_L("Unexpected component operation type (%d) was provided!"), static_cast<TInt>(compOpType)); |
|
293 User::Leave(KErrArgument); |
|
294 } |
|
295 |
|
296 RIpcReadStream componentInfoReader; |
|
297 CleanupClosePushL(componentInfoReader); |
|
298 componentInfoReader.Open(aMessage, 1); |
|
299 |
|
300 RPointerArray<CLocalizableComponentInfo> componentInfoArray; |
|
301 CleanupResetAndDestroyPushL(componentInfoArray); |
|
302 InternalizePointersArrayL(componentInfoArray, componentInfoReader); |
|
303 TInt arrayCount = componentInfoArray.Count(); |
|
304 // This check is done at the client side - if we get this condition here, this means that a rogue client-server call bypassed the R-class |
|
305 __ASSERT_ALWAYS(arrayCount > 0, PanicClient(aMessage, KScrIllegalParameter)); |
|
306 |
|
307 HBufC *uniqueSwTypeName = GetSoftwareTypeNameFromMsgLC(aMessage); |
|
308 HBufC *globalId = ReadDescLC(aMessage, 2); |
|
309 TComponentId newComponentId = CommonAddComponentL(*uniqueSwTypeName, *globalId); |
|
310 |
|
311 // Add the newly added component into the cleanupstack so that it can be deleted in case of leaving. |
|
312 TRollbackParams cleanupParam(newComponentId, *this); |
|
313 CleanupStack::PushL(TCleanupItem(CScrRequestImpl::ComponentRollback, &cleanupParam)); |
|
314 // Add the component localizables cleanup into the cleanupstack so that they can be deleted in case of leaving. |
|
315 CleanupStack::PushL(TCleanupItem(CScrRequestImpl::ComponentLocalizablesRollback, &cleanupParam)); |
|
316 |
|
317 // For a log record, the component name is chosen for the current locale. If it doesn't exist, |
|
318 // then the non-localized component name is picked. If none of them exist, the first name in the names |
|
319 // array is used as default. |
|
320 TInt componentNameIndexForLog (0); |
|
321 TInt indexForCurrentLocale = KErrNotFound; |
|
322 TInt indexForNonLocalized = KErrNotFound; |
|
323 for(TInt i=0; i<arrayCount; ++i) |
|
324 { |
|
325 TLanguage locale(componentInfoArray[i]->Locale()); |
|
326 const TDesC& name = componentInfoArray[i]->NameL(); |
|
327 const TDesC& vendor = componentInfoArray[i]->VendorL(); |
|
328 AddComponentLocalizablesL(newComponentId, locale, name, vendor); |
|
329 if(locale == User::Language()) |
|
330 indexForCurrentLocale = i; |
|
331 else if(locale == KNonLocalized) |
|
332 indexForNonLocalized = i; |
|
333 } |
|
334 CleanupStack::Pop(2, &cleanupParam); // cleanupitem for ComponentRollback, cleanupitem for ComponentLocalizablesRollback |
|
335 |
|
336 if(indexForCurrentLocale != KErrNotFound) |
|
337 componentNameIndexForLog = indexForCurrentLocale; |
|
338 else if(indexForNonLocalized != KErrNotFound) |
|
339 componentNameIndexForLog = indexForNonLocalized; |
|
340 |
|
341 if(EScrCompHidden != compOpType) |
|
342 { |
|
343 CScrLogEntry *logRecord = CScrLogEntry::NewLC(componentInfoArray[componentNameIndexForLog]->NameL(), *uniqueSwTypeName, *globalId, KNullDesC, compOpType); |
|
344 logRecord->iComponentId = newComponentId; |
|
345 iLogEntries.AppendL(logRecord); |
|
346 CleanupStack::Pop(logRecord); // Ownershipd is transferred |
|
347 } |
|
348 CleanupStack::PopAndDestroy(4, &componentInfoReader); // componentInfoReader, componentInfoArray, uniqueSwTypeName, globalId |
|
349 |
|
350 TPckg<TComponentId> componentIdDes(newComponentId); |
|
351 aMessage.WriteL(3, componentIdDes); |
|
352 |
|
353 DEBUG_PRINTF(_L8("New component added successfully.")); |
|
354 } |
|
355 |
|
356 HBufC* CScrRequestImpl::ReadAndGetGlobalIdLC(const RMessage2& aMessage, TInt aSlot) const |
|
357 { |
|
358 // Read global id object from the message |
|
359 CGlobalComponentId *globalId = ReadObjectFromMessageLC<CGlobalComponentId>(aMessage, aSlot); |
|
360 HBufC *globalIdBuf = GenerateGlobalIdL(globalId->SoftwareTypeName(), globalId->GlobalIdName()); |
|
361 CleanupStack::PopAndDestroy(globalId); |
|
362 CleanupStack::PushL(globalIdBuf); |
|
363 return globalIdBuf; |
|
364 } |
|
365 |
|
366 TUint32 CScrRequestImpl::HashGlobalIdsL(const TDesC& aDependantId, const TDesC& aSupplierId) const |
|
367 { |
|
368 RBuf concatGlobalIds; |
|
369 concatGlobalIds.CreateL(aDependantId.Length() + aSupplierId.Length()); |
|
370 concatGlobalIds.CleanupClosePushL(); |
|
371 concatGlobalIds.Copy(aDependantId); |
|
372 concatGlobalIds.Append(aSupplierId); |
|
373 TUint32 globalIdsHash = HashCaseSensitiveL(concatGlobalIds); |
|
374 CleanupStack::PopAndDestroy(&concatGlobalIds); |
|
375 return globalIdsHash; |
|
376 } |
|
377 |
|
378 void CScrRequestImpl::AddComponentDependencyL(const RMessage2& aMessage) |
|
379 { |
|
380 DEBUG_PRINTF(_L8("Adding a new component dependency.")); |
|
381 |
|
382 CVersionedComponentId *verCompId = ReadObjectFromMessageLC<CVersionedComponentId>(aMessage, 1); |
|
383 HBufC *suppGlobalId = GenerateGlobalIdL(verCompId->GlobalId().SoftwareTypeName(), verCompId->GlobalId().GlobalIdName()); |
|
384 CleanupStack::PushL(suppGlobalId); |
|
385 TUint32 suppGlobalIdHash = HashCaseSensitiveL(*suppGlobalId); |
|
386 |
|
387 HBufC *depGlobalId = ReadAndGetGlobalIdLC(aMessage, 2); |
|
388 TUint32 depGlobalIdHash = HashCaseSensitiveL(*depGlobalId); |
|
389 |
|
390 TUint32 globalIdsHash = HashGlobalIdsL(*depGlobalId, *suppGlobalId); |
|
391 |
|
392 const TDesC* versionFrom = verCompId->VersionFrom(); |
|
393 const TDesC* versionTo = verCompId->VersionTo(); |
|
394 |
|
395 _LIT(KInsertDependencyFront, "INSERT INTO ComponentDependencies(GlobalIdHash,DependantGlobalIdHash,SupplierGlobalIdHash,DependantGlobalId,SupplierGlobalId"); |
|
396 _LIT(KInsertDependencyEnd, ") VALUES(?,?,?,?,?"); |
|
397 |
|
398 const TInt KMaxInsertDependencyLength = 180; ///< Maximum length of a possible dependency insert statement (KInsertDependencyFront + KInsertDependencyEnd + some space for optional columns) |
|
399 const TInt KMaxInsertDependencyValueLength = 30; ///< Maximum length of the end part of a possible dependency insert statement (KInsertDependencyEnd + some space for optional values). |
|
400 |
|
401 TInt numberOfValues = 5; // 5->(GlobalIdHash, DependantGlobalIdHash, SupplierGlobalIdHash, DependantGlobalId, SupplierGlobalId) |
|
402 RBuf insertStmtStr; |
|
403 insertStmtStr.CreateL(KMaxInsertDependencyLength); |
|
404 insertStmtStr.CleanupClosePushL(); |
|
405 insertStmtStr.Copy(KInsertDependencyFront()); |
|
406 |
|
407 RBuf insertStmtEndStr; |
|
408 insertStmtEndStr.CreateL(KMaxInsertDependencyValueLength); |
|
409 insertStmtEndStr.CleanupClosePushL(); |
|
410 insertStmtEndStr.Copy(KInsertDependencyEnd()); |
|
411 |
|
412 // VersionFrom and VersionTo values are optional. Hence, a dynamic insert statement will be created. |
|
413 // insertStmtStr is initialized with the statement including mandatory columns. Then versionFrom/To |
|
414 // values are checked. If any of them is provided, then the corresponding column name is added to the statement. |
|
415 // insertStmtEndStr is constructed with a number of value characters(?) as new value chars will be added |
|
416 // if new columns are added to the statement |
|
417 // In the end, insertStmtEndStr is added to insertStmtStr in order to complete the dependency insert statement. |
|
418 |
|
419 const TDesC* firstVersionParam(0); |
|
420 const TDesC* secondVersionParam(0); |
|
421 |
|
422 _LIT(KInsertValue, ",?"); |
|
423 if(versionFrom) |
|
424 { |
|
425 _LIT(KVersionFrom, ",VersionFrom"); |
|
426 insertStmtStr.Append(KVersionFrom()); |
|
427 insertStmtEndStr.Append(KInsertValue()); |
|
428 firstVersionParam = versionFrom; |
|
429 ++numberOfValues; |
|
430 } |
|
431 |
|
432 if(versionTo) |
|
433 { |
|
434 _LIT(KVersionTo, ",VersionTo"); |
|
435 insertStmtStr.Append(KVersionTo()); |
|
436 insertStmtEndStr.Append(KInsertValue()); |
|
437 if(firstVersionParam) |
|
438 { |
|
439 secondVersionParam = versionTo; |
|
440 } |
|
441 else |
|
442 { |
|
443 firstVersionParam = versionTo; |
|
444 } |
|
445 ++numberOfValues; |
|
446 } |
|
447 |
|
448 // Append the end part of the statement to the front part. |
|
449 insertStmtStr.Append(insertStmtEndStr); |
|
450 // Close the statement |
|
451 _LIT(KInsertClose,");"); |
|
452 insertStmtStr.Append(KInsertClose()); |
|
453 // SQLite requires the statement string to end with NULL char. |
|
454 insertStmtStr.Append('\0'); |
|
455 // All parameters are supplied, but numberOfValues of them will be taken into account. |
|
456 ExecuteStatementL(insertStmtStr, numberOfValues, EValueInteger, globalIdsHash, EValueInteger, depGlobalIdHash, EValueInteger, suppGlobalIdHash, EValueString, depGlobalId, EValueString, suppGlobalId, EValueString, firstVersionParam, EValueString, secondVersionParam); |
|
457 |
|
458 CleanupStack::PopAndDestroy(5, verCompId); // verCompId, suppGlobalId, depGlobalId, insertStmtStr, insertStmtEndStr |
|
459 |
|
460 DEBUG_PRINTF(_L8("New component dependency added successfully.")); |
|
461 } |
|
462 |
|
463 CStatement* CScrRequestImpl::CreateGeneralPropertyStatementWithLocaleL(const TDesC& aStmtStr, TInt aIdColumnValue, TLanguage aLocale, const TDesC& aPropName, TBool aDoLocaleResolving) const |
|
464 { |
|
465 CStatement *stmt(0); |
|
466 TInt numberOfValues = 3; |
|
467 |
|
468 if(KUnspecifiedLocale == aLocale) |
|
469 { |
|
470 // No locale is specified. Client wants SCR to find the property automatically. |
|
471 // So, first look up the properties for the current locale and its downgraded languages. |
|
472 ASSERT(aDoLocaleResolving); // We cannot get a situation where KUnspecifiedLocale is given with locale resolving disabled: it is an undefined state. |
|
473 stmt = CreateStatementObjectWithLocaleL(aStmtStr, User::Language(), numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueLanguage); |
|
474 |
|
475 if(!stmt) |
|
476 { |
|
477 // No property is defined with the current locale. Look up the non-localized properties. |
|
478 stmt = CreateStatementObjectWithLocaleL(aStmtStr, KNonLocalized, numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueLanguage); |
|
479 } |
|
480 } |
|
481 else if(KNonLocalized == aLocale) |
|
482 { |
|
483 // Non-localized properties are requested. Look up the non-localized properties. |
|
484 stmt = CreateStatementObjectWithLocaleL(aStmtStr, KNonLocalized, numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueLanguage); |
|
485 } |
|
486 else |
|
487 { |
|
488 // A particular language is specified. Look up the properties with for this particular language |
|
489 // and its downgraded languages. |
|
490 stmt = aDoLocaleResolving ? |
|
491 CreateStatementObjectWithLocaleL(aStmtStr, aLocale, numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueLanguage, aDoLocaleResolving) : |
|
492 CreateStatementObjectWithLocaleNoDowngradeL(aStmtStr, aLocale, numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueLanguage, aDoLocaleResolving); |
|
493 } |
|
494 return stmt; |
|
495 } |
|
496 |
|
497 TInt CScrRequestImpl::FindGeneralPropertyNoLocaleDowngradeL(const TDesC& aTableName, const TDesC& aIdColumnName, TInt aIdColumnValue, const TDesC& aPropertyName, TLanguage aLocale, TPropertyType& aPropertyType) const |
|
498 { |
|
499 _LIT(KFindProperty, "SELECT PropertyId,IntValue,StrValue,IsStr8Bit FROM %S WHERE Name=? AND %S=? AND Locale=?;"); |
|
500 TInt formattedLen = aTableName.Length() + aIdColumnName.Length(); |
|
501 HBufC *statementStr = FormatStatementLC(KFindProperty(), formattedLen, &aTableName, &aIdColumnName); |
|
502 |
|
503 // As we do not require downgrading locales, the last parameter is EFalse |
|
504 CStatement *stmtFind = CreateGeneralPropertyStatementWithLocaleL(*statementStr, aIdColumnValue, aLocale, aPropertyName, EFalse); |
|
505 if(!stmtFind) |
|
506 { // the property does not exist, return |
|
507 CleanupStack::PopAndDestroy(statementStr); |
|
508 return KErrNotFound; |
|
509 } |
|
510 CleanupStack::PushL(stmtFind); |
|
511 |
|
512 // the property in question exists in the properties table |
|
513 TInt propertyId = stmtFind->IntColumnL(0); // 0 -> PropertyId |
|
514 TBool isIntPropertyNull = stmtFind->IsFieldNullL(1); // 2 -> IntValue |
|
515 TBool isStrPropertyNull = stmtFind->IsFieldNullL(2); // 3 -> StrValue |
|
516 |
|
517 if(!isIntPropertyNull) |
|
518 { |
|
519 aPropertyType = CScrRequestImpl::EPropertyInteger; |
|
520 } |
|
521 else if(!isStrPropertyNull) |
|
522 { |
|
523 TBool is8BitString = (stmtFind->IntColumnL(3) == 1); |
|
524 aPropertyType = is8BitString ? CScrRequestImpl::EPropertyBinary : CScrRequestImpl::EPropertyLocalizable; |
|
525 } |
|
526 else // None of the columns is defined - corrupt DB |
|
527 { |
|
528 DEBUG_PRINTF(_L8("Unexpected situation! Neither int value nor str value are defined for a property")); |
|
529 User::Leave(KErrCorrupt); |
|
530 } |
|
531 CleanupStack::PopAndDestroy(2, statementStr); // stmtFind, statementStr |
|
532 return propertyId; |
|
533 } |
|
534 |
|
535 void CScrRequestImpl::BindStatementValuesL(CStatement& aStatement, TLanguage aLanguage, TInt aValuesNum, VA_LIST aList) const |
|
536 { |
|
537 TInt bindIdx(0); |
|
538 while(aValuesNum--) |
|
539 { |
|
540 CScrRequestImpl::TValueType t = static_cast<CScrRequestImpl::TValueType>(VA_ARG(aList, TInt)); |
|
541 switch(t) |
|
542 { |
|
543 case EValueString: |
|
544 { |
|
545 const TDesC* strVal = VA_ARG(aList, const TDesC*); |
|
546 aStatement.BindStrL(++bindIdx, *strVal); |
|
547 break; |
|
548 } |
|
549 case EValueInteger: |
|
550 { |
|
551 TInt intVal = VA_ARG(aList, TInt); |
|
552 aStatement.BindIntL(++bindIdx, intVal); |
|
553 break; |
|
554 } |
|
555 case EValueInteger64: |
|
556 { |
|
557 TInt64 intVal64 = VA_ARG(aList, TInt64); |
|
558 aStatement.BindInt64L(++bindIdx, intVal64); |
|
559 break; |
|
560 } |
|
561 case EValueLanguage: |
|
562 { |
|
563 aStatement.BindIntL(++bindIdx, aLanguage); |
|
564 break; |
|
565 } |
|
566 case EValueBinary: |
|
567 { |
|
568 const TDesC8* binaryVal = VA_ARG(aList, const TDesC8*); |
|
569 aStatement.BindBinaryL(++bindIdx, *binaryVal); |
|
570 break; |
|
571 } |
|
572 default: |
|
573 DEBUG_PRINTF2(_L8("Encountered unexpected value type (%d)!"), t); |
|
574 ASSERT(0); |
|
575 } // switch |
|
576 } // while |
|
577 } // End of the function |
|
578 |
|
579 void CScrRequestImpl::ExecuteStatementL(TRefByValue<const TDesC> aStatement, TInt aValuesNum,...) |
|
580 {// TRefByValue is used to suppress rcvt compile warning |
|
581 VA_LIST argList; |
|
582 VA_START(argList, aValuesNum); |
|
583 |
|
584 CStatement *stmt = iDbHandle->PrepareStatementLC(aStatement); |
|
585 BindStatementValuesL(*stmt, KLangNone, aValuesNum, argList); |
|
586 stmt->ExecuteStatementL(); |
|
587 CleanupStack::PopAndDestroy(stmt); |
|
588 |
|
589 VA_END(argList); |
|
590 } |
|
591 |
|
592 void CScrRequestImpl::SetGeneralLocalizablePropertyL(CScrRequestImpl::TPropertyType aPropType, TInt aPropertyId, const TDesC& aIdColumnName, TInt aIdColumnValue, const TDesC& aPropName, TLanguage aLocale, const TDesC& aPropValue) |
|
593 { |
|
594 switch(aPropType) |
|
595 { |
|
596 case CScrRequestImpl::EPropertyUndefined: |
|
597 {// the property does NOT exist, insert a new one |
|
598 _LIT(KInsertProperty, "INSERT INTO ComponentProperties(Name,Locale,%S,StrValue) VALUES(?,?,?,?);"); |
|
599 TInt formattedLen = aIdColumnName.Length(); |
|
600 HBufC *statementStr = FormatStatementLC(KInsertProperty(), formattedLen, &aIdColumnName ); |
|
601 TInt numberOfValues = 4; |
|
602 ExecuteStatementL(*statementStr, numberOfValues, EValueString, &aPropName, EValueInteger, aLocale, EValueInteger, aIdColumnValue, EValueString, &aPropValue); |
|
603 CleanupStack::PopAndDestroy(statementStr); |
|
604 break; |
|
605 } |
|
606 case CScrRequestImpl::EPropertyLocalizable: |
|
607 { |
|
608 // the property exists, update it |
|
609 _LIT(KUpdateProperty, "UPDATE ComponentProperties SET StrValue=? WHERE PropertyId=?;"); |
|
610 TInt numberOfValues = 2; |
|
611 ExecuteStatementL(KUpdateProperty(), numberOfValues, EValueString, &aPropValue, EValueInteger, aPropertyId); |
|
612 break; |
|
613 } |
|
614 default: |
|
615 DEBUG_PRINTF(_L8("The property type isn't localizable string and cannot be updated with this API.")) |
|
616 User::Leave(KErrAbort); |
|
617 } |
|
618 } |
|
619 |
|
620 void CScrRequestImpl::SetGeneralBinaryPropertyL(CScrRequestImpl::TPropertyType aPropType, TInt aPropertyId, const TDesC& aTableName, const TDesC& aIdColumnName, TInt aIdColumnValue, const TDesC& aPropName, const TDesC8& aPropValue) |
|
621 { |
|
622 switch(aPropType) |
|
623 { |
|
624 case CScrRequestImpl::EPropertyUndefined: |
|
625 {// the property does NOT exist, insert a new one |
|
626 _LIT(KInsertProperty, "INSERT INTO %S(Name,%S,StrValue,IsStr8Bit) VALUES(?,?,?,1);"); |
|
627 TInt formattedLen = aTableName.Length() + aIdColumnName.Length(); |
|
628 HBufC *statementStr = FormatStatementLC(KInsertProperty(), formattedLen, &aTableName, &aIdColumnName ); |
|
629 TInt numberOfValues = 3; |
|
630 ExecuteStatementL(*statementStr, numberOfValues, EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueBinary, &aPropValue); |
|
631 CleanupStack::PopAndDestroy(statementStr); |
|
632 break; |
|
633 } |
|
634 case CScrRequestImpl::EPropertyBinary: |
|
635 { |
|
636 // the property exists, update it |
|
637 _LIT(KUpdateProperty, "UPDATE %S SET StrValue=? WHERE PropertyId=?;"); |
|
638 HBufC *statementStr = FormatStatementLC(KUpdateProperty(), aTableName.Length(), &aTableName); |
|
639 TInt numberOfValues = 2; |
|
640 ExecuteStatementL(*statementStr, numberOfValues, EValueBinary, &aPropValue, EValueInteger, aPropertyId); |
|
641 CleanupStack::PopAndDestroy(statementStr); |
|
642 break; |
|
643 } |
|
644 default: |
|
645 DEBUG_PRINTF(_L8("The property type isn't an 8-bit string and cannot be updated with this API.")) |
|
646 User::Leave(KErrAbort); |
|
647 } |
|
648 } |
|
649 |
|
650 void CScrRequestImpl::SetGeneralIntPropertyL(TPropertyType aPropType, TInt aPropertyId, const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, TInt64 aPropValue) |
|
651 { |
|
652 switch(aPropType) |
|
653 { |
|
654 case CScrRequestImpl::EPropertyUndefined: |
|
655 {// the property does NOT exist, insert a new one |
|
656 _LIT(KInsertProperty, "INSERT INTO %S(Name,%S,IntValue) VALUES(?,?,?)"); |
|
657 TInt formattedLen = aTableName.Length() + aIdColumnName.Length(); |
|
658 HBufC* statementStr = FormatStatementLC(KInsertProperty(), formattedLen, &aTableName, &aIdColumnName ); |
|
659 TInt numberOfValues = 3; |
|
660 ExecuteStatementL(*statementStr, numberOfValues,EValueString, &aPropName, EValueInteger, aIdColumnValue, EValueInteger64, aPropValue); |
|
661 CleanupStack::PopAndDestroy(statementStr); |
|
662 break; |
|
663 } |
|
664 case CScrRequestImpl::EPropertyInteger: |
|
665 {// the property exists, update it |
|
666 _LIT(KUpdateProperty, "UPDATE %S SET IntValue=? WHERE PropertyId=?;"); |
|
667 HBufC *statementStr = FormatStatementLC(KUpdateProperty(), aTableName.Length(), &aTableName); |
|
668 TInt numberOfValues = 2; |
|
669 ExecuteStatementL(*statementStr, numberOfValues, EValueInteger64, aPropValue, EValueInteger, aPropertyId); |
|
670 CleanupStack::PopAndDestroy(statementStr); |
|
671 break; |
|
672 } |
|
673 default: |
|
674 DEBUG_PRINTF(_L8("The property type isn't integer and cannot be updated with this API.")); |
|
675 User::Leave(KErrAbort); |
|
676 } |
|
677 } |
|
678 |
|
679 template <class A> void VerifySetPropertyParamsL(HBufC* aPropName, A* aPropValue) |
|
680 { |
|
681 if (!aPropName || !aPropValue) |
|
682 User::Leave(KErrArgument); |
|
683 } |
|
684 |
|
685 void CScrRequestImpl::SetComponentLocalizablePropertyL(const RMessage2& aMessage) |
|
686 { |
|
687 DEBUG_PRINTF(_L8("Setting component string property.")); |
|
688 // N.B. Don't change the order of IPC parameter reading, otherwise fails in UREL mode. |
|
689 HBufC *propName = ReadDescLC(aMessage, 1); |
|
690 HBufC *propValue = ReadDescLC(aMessage, 2); |
|
691 VerifySetPropertyParamsL(propName, propValue); |
|
692 |
|
693 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
694 TLanguage locale = TLanguage(aMessage.Int3()); |
|
695 |
|
696 CScrRequestImpl::TPropertyType propType(CScrRequestImpl::EPropertyUndefined); |
|
697 // The function name states that we don't want automatic locale resolving. If, e.g. we set a property for ELangAmerican, we don't want FindGeneralProperty to match existing value for ELangEnglish |
|
698 TInt propertyId = FindGeneralPropertyNoLocaleDowngradeL(KComponentPropertiesTable(), KComponentIdColumnName(), componentId, *propName, locale, propType); |
|
699 SetGeneralLocalizablePropertyL(propType, propertyId, KComponentIdColumnName(), componentId, *propName, locale, *propValue); |
|
700 CleanupStack::PopAndDestroy(2, propName); |
|
701 } |
|
702 |
|
703 void CScrRequestImpl::SetComponentBinaryPropertyL(const RMessage2& aMessage) |
|
704 { |
|
705 DEBUG_PRINTF(_L8("Setting component binary property.")); |
|
706 // N.B. Don't change the order of IPC parameter reading, otherwise fails in UREL mode. |
|
707 HBufC *propName = ReadDescLC(aMessage, 1); |
|
708 HBufC8 *propValue = ReadDesc8LC(aMessage, 2); |
|
709 |
|
710 VerifySetPropertyParamsL(propName, propValue); |
|
711 |
|
712 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
713 |
|
714 CScrRequestImpl::TPropertyType propType(CScrRequestImpl::EPropertyUndefined); |
|
715 TInt propertyId = FindGeneralPropertyNoLocaleDowngradeL(KComponentPropertiesTable(), KComponentIdColumnName(), componentId, *propName, KLangNone, propType); |
|
716 SetGeneralBinaryPropertyL(propType, propertyId, KComponentPropertiesTable(), KComponentIdColumnName(), componentId, *propName, *propValue); |
|
717 CleanupStack::PopAndDestroy(2, propName); |
|
718 } |
|
719 |
|
720 void CScrRequestImpl::SetComponentIntPropertyL(const RMessage2& aMessage) |
|
721 { |
|
722 DEBUG_PRINTF(_L8("Setting component integer property.")); |
|
723 // N.B. Don't change the order of IPC parameter reading, otherwise fails in UREL mode. |
|
724 HBufC* propName = ReadDescLC(aMessage, 1); |
|
725 |
|
726 if (!propName) |
|
727 User::Leave(KErrArgument); |
|
728 |
|
729 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
730 TInt64 propValue = MAKE_TINT64(aMessage.Int2(), aMessage.Int3()); |
|
731 |
|
732 TPropertyType propType(CScrRequestImpl::EPropertyUndefined); |
|
733 TInt propertyId = FindGeneralPropertyNoLocaleDowngradeL(KComponentPropertiesTable(), KComponentIdColumnName(), componentId, *propName, KLangNone, propType); |
|
734 SetGeneralIntPropertyL(propType, propertyId, KComponentPropertiesTable(), KComponentIdColumnName(), componentId, *propName, propValue); |
|
735 CleanupStack::PopAndDestroy(propName); |
|
736 } |
|
737 |
|
738 TUint32 CScrRequestImpl::HashCaseInsensitiveL(const TDesC& aName) |
|
739 { |
|
740 RBuf temp; |
|
741 temp.CreateMaxL(aName.Length()); |
|
742 temp.CleanupClosePushL(); |
|
743 temp.Copy(aName); |
|
744 temp.LowerCase(); // The hashed column is case-insensitive. So, the hashed value must be |
|
745 // case-insensitive too. To achieve that we need to set to lower-case. |
|
746 TUint32 hashVal = HashCaseSensitiveL(temp); |
|
747 CleanupStack::PopAndDestroy(&temp); |
|
748 return hashVal; |
|
749 } |
|
750 |
|
751 TUint32 CScrRequestImpl::HashCaseSensitiveL(const TDesC& aName) |
|
752 { |
|
753 TUint32 hashVal = 0; |
|
754 Mem::Crc32(hashVal,aName.Ptr(),aName.Size()); |
|
755 return hashVal; |
|
756 } |
|
757 |
|
758 TInt CScrRequestImpl::GetComponentFileIdL(const TDesC& aFileName, TComponentId aComponentId) const |
|
759 { |
|
760 DEBUG_PRINTF3(_L("Looking up a component(%d) file(%S)"), aComponentId, &aFileName); |
|
761 |
|
762 TUint32 hash = HashCaseInsensitiveL(aFileName); |
|
763 _LIT(KFindComponentFile, "SELECT CmpFileId FROM ComponentsFiles WHERE ComponentId=? AND LocationHash=?;"); |
|
764 CStatement *stmtFind = iDbHandle->PrepareStatementLC(KFindComponentFile()); |
|
765 stmtFind->BindIntL(1, aComponentId); |
|
766 stmtFind->BindIntL(2, hash); |
|
767 |
|
768 if(!stmtFind->ProcessNextRowL()) |
|
769 { |
|
770 DEBUG_PRINTF3(_L("Component %d does not have File=%S!"), aComponentId, &aFileName); |
|
771 CleanupStack::PopAndDestroy(stmtFind); |
|
772 return KErrNotFound; |
|
773 } |
|
774 TInt componentFileId = stmtFind->IntColumnL(0); |
|
775 CleanupStack::PopAndDestroy(stmtFind); |
|
776 return componentFileId; |
|
777 } |
|
778 |
|
779 TInt CScrRequestImpl::FindComponentFileL(const TDesC& aFileName, TComponentId aComponentId) const |
|
780 { |
|
781 TInt cmpFileId = GetComponentFileIdL(aFileName, aComponentId); |
|
782 if(KErrNotFound == cmpFileId) |
|
783 { |
|
784 User::Leave(KErrNotFound); |
|
785 } |
|
786 return cmpFileId; |
|
787 } |
|
788 |
|
789 TInt CScrRequestImpl::GetDriveFromFilePath(const TDesC& aFilePath, TDriveUnit& aDriveUnit) const |
|
790 { |
|
791 if(!iFs.IsValidName(aFilePath)) |
|
792 {// even if the file name validity is checked before registering the file, do double check |
|
793 // to be on the safe side. Because, if the file format is invalid, the rest of the code may panic. |
|
794 DEBUG_PRINTF2(_L("The file (%S) doesn't have a valid name format!"), &aFilePath); |
|
795 return KErrArgument; |
|
796 } |
|
797 |
|
798 TParsePtrC fileParser(aFilePath); |
|
799 TPtrC driveLetter(fileParser.Drive()); |
|
800 if(driveLetter == KNullDesC()) |
|
801 { |
|
802 DEBUG_PRINTF2(_L("The file (%S) doesn't contain any drive letter!"), &aFilePath); |
|
803 return KErrArgument; |
|
804 } |
|
805 aDriveUnit = driveLetter; |
|
806 return KErrNone; |
|
807 } |
|
808 |
|
809 TInt CScrRequestImpl::InstalledDrivesToBitmaskL(const TDriveList& aDriveList) const |
|
810 { |
|
811 TInt installedDrives(0); |
|
812 for(TInt driveNum=EDriveA; driveNum<=EDriveZ; ++driveNum) |
|
813 { |
|
814 if(aDriveList[driveNum]) |
|
815 { |
|
816 installedDrives |= 1<<driveNum; |
|
817 } |
|
818 } |
|
819 return installedDrives; |
|
820 } |
|
821 |
|
822 TInt CScrRequestImpl::GetInstalledDrivesBitmaskL(TComponentId aComponentId) const |
|
823 { |
|
824 // Get installed drives list from database |
|
825 _LIT(KSelectInstalledDrivesBitmask, "SELECT InstalledDrives FROM Components WHERE ComponentId=?;"); |
|
826 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectInstalledDrivesBitmask); |
|
827 stmt->BindIntL(1, aComponentId); |
|
828 if(!stmt->ProcessNextRowL()) |
|
829 { |
|
830 DEBUG_PRINTF2(_L8("Component (%d) couldn't be found in the SCR database."), aComponentId); |
|
831 User::Leave(KErrNotFound); |
|
832 } |
|
833 TInt res = stmt->IntColumnL(0); |
|
834 CleanupStack::PopAndDestroy(stmt); |
|
835 return res; |
|
836 } |
|
837 |
|
838 TBool CScrRequestImpl::HasFilesOnDriveL(TDriveUnit aDrive, TComponentId aComponentId) |
|
839 { |
|
840 CStatement *stmt = OpenFileListStatementL(aComponentId); |
|
841 CleanupStack::PushL(stmt); |
|
842 HBufC *nextFilePath(NULL); |
|
843 TBool returnValue(EFalse); |
|
844 |
|
845 while ( returnValue == EFalse && (nextFilePath = GetNextFilePathL(*stmt)) != NULL) |
|
846 { |
|
847 TDriveUnit fileDrive; |
|
848 TInt res = GetDriveFromFilePath(*nextFilePath, fileDrive); |
|
849 // Files with invalid paths are ignored |
|
850 if (res == KErrNone && fileDrive == aDrive) |
|
851 { |
|
852 returnValue = ETrue; |
|
853 } |
|
854 delete nextFilePath; |
|
855 } |
|
856 |
|
857 CleanupStack::PopAndDestroy(stmt); |
|
858 return returnValue; |
|
859 } |
|
860 |
|
861 void CScrRequestImpl::UpdateInstalledDrivesL(TComponentId aComponentId, const TDesC& aFilePath, TFileOperationType aType) |
|
862 { |
|
863 TDriveUnit drive; |
|
864 User::LeaveIfError(GetDriveFromFilePath(aFilePath, drive)); |
|
865 |
|
866 TInt driveNum = static_cast<TInt>(drive); |
|
867 TInt oldDrivesBitmask = GetInstalledDrivesBitmaskL(aComponentId); |
|
868 |
|
869 TInt newDrivesBitmask = oldDrivesBitmask; |
|
870 // Update the list of installed drives |
|
871 if(aType == EFileRegistered) |
|
872 { |
|
873 newDrivesBitmask |= 0x1 << driveNum; |
|
874 } |
|
875 else // aType == EFileUnregistered |
|
876 { |
|
877 TBool hasOtherFilesOnTheDrive = HasFilesOnDriveL(drive, aComponentId); |
|
878 if (!hasOtherFilesOnTheDrive) |
|
879 { |
|
880 // Do a logical AND with a bitmask which looks like 111110111111 |
|
881 TInt andBitmask = ~(0x1 << driveNum); |
|
882 newDrivesBitmask &= andBitmask; |
|
883 } |
|
884 } |
|
885 |
|
886 if (newDrivesBitmask != oldDrivesBitmask) |
|
887 { |
|
888 // Write back the updated installed drives and list |
|
889 _LIT(KUpdateInstalledDrives, "UPDATE Components SET InstalledDrives=? WHERE ComponentId=?;"); |
|
890 TInt numberOfValues = 2; |
|
891 ExecuteStatementL(KUpdateInstalledDrives, numberOfValues, EValueInteger, newDrivesBitmask, EValueInteger, aComponentId); |
|
892 } |
|
893 } |
|
894 |
|
895 void CScrRequestImpl::RegisterComponentFileL(const RMessage2& aMessage) |
|
896 { |
|
897 DEBUG_PRINTF(_L8("Registering component file.")); |
|
898 |
|
899 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
900 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
901 TBool considerFileInDrivesList = aMessage.Int2(); |
|
902 TUint32 hash = HashCaseInsensitiveL(*fileName); |
|
903 TDriveUnit drive(*fileName); |
|
904 TVolumeInfo volInfo; |
|
905 |
|
906 _LIT(KInsertFile, "INSERT INTO ComponentsFiles(ComponentId,LocationHash,Location) VALUES(?,?,?);"); |
|
907 TInt numberOfValues = 3; |
|
908 ExecuteStatementL(KInsertFile(), numberOfValues, EValueInteger, componentId, EValueInteger, hash, EValueString, fileName); |
|
909 // Reflect this file addition in the installed drives field of the components table |
|
910 // Or the drive list is updated in case of a FILENULL operation on a removable drive |
|
911 // If this step fails (for example, this file name is incorrect) then we cannot register the file |
|
912 if (KErrNone == iFs.Volume(volInfo, drive) || considerFileInDrivesList) |
|
913 UpdateInstalledDrivesL(componentId, *fileName, EFileRegistered); |
|
914 |
|
915 CleanupStack::PopAndDestroy(fileName); |
|
916 } |
|
917 |
|
918 void CScrRequestImpl::SetFileStrPropertyL(const RMessage2& aMessage) |
|
919 { |
|
920 DEBUG_PRINTF(_L8("Setting file string property.")); |
|
921 |
|
922 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
923 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
924 |
|
925 TInt compFileId = FindComponentFileL(*fileName, componentId); |
|
926 |
|
927 HBufC* propName = ReadDescLC(aMessage, 2); |
|
928 TPropertyType propType(CScrRequestImpl::EPropertyUndefined); |
|
929 TInt propertyId = FindGeneralPropertyNoLocaleDowngradeL(KFilePropertiesTable(), KCompFileIdColumnName(), compFileId, *propName, KLangNone, propType); |
|
930 |
|
931 HBufC8* propValue = ReadDesc8LC(aMessage, 3); |
|
932 SetGeneralBinaryPropertyL(propType, propertyId, KFilePropertiesTable(), KCompFileIdColumnName(), compFileId, *propName, *propValue); |
|
933 CleanupStack::PopAndDestroy(3, fileName); |
|
934 } |
|
935 |
|
936 void CScrRequestImpl::SetFileIntPropertyL(const RMessage2& aMessage) |
|
937 { |
|
938 DEBUG_PRINTF(_L8("Setting integer file property.")); |
|
939 |
|
940 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
941 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
942 TInt compFileId = FindComponentFileL(*fileName, componentId); |
|
943 |
|
944 HBufC* propName = ReadDescLC(aMessage, 2); |
|
945 TPropertyType propType(CScrRequestImpl::EPropertyUndefined); |
|
946 TInt propertyId = FindGeneralPropertyNoLocaleDowngradeL(KFilePropertiesTable(), KCompFileIdColumnName(), compFileId, *propName, KLangNone, propType); |
|
947 |
|
948 TInt propValue = aMessage.Int3(); |
|
949 SetGeneralIntPropertyL(propType, propertyId, KFilePropertiesTable(), KCompFileIdColumnName(), compFileId, *propName, propValue); |
|
950 CleanupStack::PopAndDestroy(2, fileName); |
|
951 } |
|
952 |
|
953 void CScrRequestImpl::SetComponentLocalizableL(TComponentId aComponentId, TLanguage aLocale, const TDesC& aColumnName, const TDesC& aName, const TDesC& aVendor) |
|
954 { |
|
955 DEBUG_PRINTF(_L8("Setting component Localizable.")); |
|
956 |
|
957 _LIT(KFindComponentLocalizable, "SELECT CompLocalId FROM ComponentLocalizables WHERE ComponentId=? AND Locale=?;"); |
|
958 TInt numberOfValues = 2; |
|
959 CStatement *stmt = CreateStatementObjectWithLocaleL(KFindComponentLocalizable, aLocale, numberOfValues, EValueInteger, aComponentId, EValueLanguage); |
|
960 |
|
961 if(!stmt) |
|
962 {// Add a new name for this component |
|
963 AddComponentLocalizablesL(aComponentId, aLocale, aName, aVendor); |
|
964 } |
|
965 else |
|
966 {// Exists, update the localizable field of the component |
|
967 CleanupStack::PushL(stmt); |
|
968 TInt compLocId = stmt->IntColumnL(0); |
|
969 _LIT(KUpdateComponentName, "UPDATE ComponentLocalizables SET %S=? WHERE CompLocalId=?;"); |
|
970 HBufC *statementStr = FormatStatementLC(KUpdateComponentName, aColumnName.Length(), &aColumnName); |
|
971 const TDesC *value = aName.Length() ? &aName : &aVendor; |
|
972 TInt numberOfValues = 2; |
|
973 ExecuteStatementL(*statementStr, numberOfValues, EValueString, value, EValueInteger, compLocId); |
|
974 CleanupStack::PopAndDestroy(2, stmt); // stmt, statementStr |
|
975 } |
|
976 } |
|
977 |
|
978 void CScrRequestImpl::SetComponentNameL(const RMessage2& aMessage) |
|
979 { |
|
980 DEBUG_PRINTF(_L8("Setting component name.")); |
|
981 |
|
982 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
983 HBufC *componentName = ReadDescLC(aMessage, 1); |
|
984 if (!componentName->CompareF(KNullDesC())) |
|
985 {// Component name cannot be empty |
|
986 DEBUG_PRINTF(_L8("Component name cannot be set or modified to a NULL string.")); |
|
987 User::Leave(KErrArgument); |
|
988 } |
|
989 |
|
990 TLanguage locale = TLanguage(aMessage.Int2()); |
|
991 _LIT(KComponentNameField,"Name"); |
|
992 SetComponentLocalizableL(componentId, locale, KComponentNameField, *componentName, KNullDesC()); |
|
993 CleanupStack::PopAndDestroy(componentName); |
|
994 } |
|
995 |
|
996 void CScrRequestImpl::SetVendorNameL(const RMessage2& aMessage) |
|
997 { |
|
998 DEBUG_PRINTF(_L8("Setting vendor name.")); |
|
999 |
|
1000 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1001 HBufC *vendorName = ReadDescLC(aMessage, 1); |
|
1002 TLanguage locale = TLanguage(aMessage.Int2()); |
|
1003 _LIT(KComponentVendorField,"Vendor"); |
|
1004 SetComponentLocalizableL(componentId, locale, KComponentVendorField, KNullDesC(), *vendorName); |
|
1005 CleanupStack::PopAndDestroy(vendorName); |
|
1006 } |
|
1007 |
|
1008 void CScrRequestImpl::ReadAndSetCommonComponentPropertyL(const RMessage2& aMessage, const TDesC& aPropertyColumn) |
|
1009 { |
|
1010 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1011 TInt propertyValue = aMessage.Int1(); |
|
1012 |
|
1013 _LIT(KUpdateCommonProperty, "UPDATE Components SET %S=? WHERE ComponentId=?;"); |
|
1014 TInt formattedLen = aPropertyColumn.Length(); |
|
1015 HBufC *statementStr = FormatStatementLC(KUpdateCommonProperty(), formattedLen, &aPropertyColumn ); |
|
1016 TInt numberOfValues = 2; |
|
1017 ExecuteStatementL(*statementStr, numberOfValues, EValueInteger, propertyValue, EValueInteger, componentId); |
|
1018 CleanupStack::PopAndDestroy(statementStr); |
|
1019 } |
|
1020 |
|
1021 void CScrRequestImpl::SetIsComponentRemovableL(const RMessage2& aMessage) |
|
1022 { |
|
1023 DEBUG_PRINTF(_L8("Setting the component's removable attribute.")); |
|
1024 _LIT(KColumnNameRemovable, "Removable"); |
|
1025 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameRemovable); |
|
1026 } |
|
1027 |
|
1028 void CScrRequestImpl::SetIsComponentDrmProtectedL(const RMessage2& aMessage) |
|
1029 { |
|
1030 DEBUG_PRINTF(_L8("Setting the component's DRM protected attribute.")); |
|
1031 _LIT(KColumnNameDrmProtected, "DRMProtected"); |
|
1032 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameDrmProtected); |
|
1033 } |
|
1034 |
|
1035 void CScrRequestImpl::SetIsComponentHiddenL(const RMessage2& aMessage) |
|
1036 { |
|
1037 DEBUG_PRINTF(_L8("Setting the component's hidden attribute.")); |
|
1038 _LIT(KColumnNameHidden, "Hidden"); |
|
1039 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameHidden); |
|
1040 } |
|
1041 |
|
1042 void CScrRequestImpl::SetIsComponentKnownRevokedL(const RMessage2& aMessage) |
|
1043 { |
|
1044 DEBUG_PRINTF(_L8("Setting the component's known-revoked attribute.")); |
|
1045 _LIT(KColumnNameKnownRevoked, "KnownRevoked"); |
|
1046 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameKnownRevoked); |
|
1047 } |
|
1048 |
|
1049 void CScrRequestImpl::SetIsComponentOriginVerifiedL(const RMessage2& aMessage) |
|
1050 { |
|
1051 DEBUG_PRINTF(_L8("Setting the component's removable attribute.")); |
|
1052 _LIT(KColumnNameOriginVerified, "OriginVerified"); |
|
1053 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameOriginVerified); |
|
1054 } |
|
1055 |
|
1056 void CScrRequestImpl::SetComponentSizeL(const RMessage2& aMessage) |
|
1057 { |
|
1058 DEBUG_PRINTF(_L8("Setting the component's install-time size.")); |
|
1059 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1060 TInt64 componentSize = MAKE_TINT64(aMessage.Int1(), aMessage.Int2()); |
|
1061 if (componentSize < 0) |
|
1062 { |
|
1063 DEBUG_PRINTF2(_L8("Received incorrect component size: %d."), componentSize); |
|
1064 User::Leave(KErrArgument); |
|
1065 } |
|
1066 _LIT(KUpdateComponentSize, "UPDATE Components SET Size=? WHERE ComponentId=?;"); |
|
1067 TInt numberOfValues = 2; |
|
1068 ExecuteStatementL(KUpdateComponentSize, numberOfValues, EValueInteger64, componentSize, EValueInteger, componentId); |
|
1069 } |
|
1070 |
|
1071 TBool FindLogEntryWithComponentId(const TComponentId *aKey, const CScrLogEntry& aEntry) |
|
1072 { |
|
1073 return (*aKey == aEntry.ComponentId()); |
|
1074 } |
|
1075 |
|
1076 void CScrRequestImpl::SetComponentVersionL(const RMessage2& aMessage) |
|
1077 { |
|
1078 DEBUG_PRINTF(_L8("Setting component version.")); |
|
1079 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1080 HBufC *version = ReadDescLC(aMessage, 1); |
|
1081 |
|
1082 _LIT(KUpdateVersion, "UPDATE Components SET Version=? WHERE ComponentId=?;"); |
|
1083 TInt numberOfValues = 2; |
|
1084 ExecuteStatementL(KUpdateVersion, numberOfValues, EValueString, version, EValueInteger, componentId); |
|
1085 |
|
1086 TInt logIdx = iLogEntries.Find(componentId, FindLogEntryWithComponentId); |
|
1087 if(KErrNotFound == logIdx) |
|
1088 { |
|
1089 CleanupStack::PopAndDestroy(version); |
|
1090 return; |
|
1091 } |
|
1092 DeleteObjectZ(iLogEntries[logIdx]->iVersion); |
|
1093 iLogEntries[logIdx]->iVersion = version; // Ownership is transferred |
|
1094 CleanupStack::Pop(version); |
|
1095 } |
|
1096 |
|
1097 void CScrRequestImpl::DeleteComponentPropertyL(const RMessage2& aMessage) |
|
1098 { |
|
1099 DEBUG_PRINTF(_L8("Deleting component property.")); |
|
1100 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1101 HBufC *name = ReadDescLC(aMessage, 1); |
|
1102 |
|
1103 _LIT(KDeleteComponentProperty, "DELETE FROM ComponentProperties WHERE Name=? AND ComponentId=?;"); |
|
1104 TInt numberOfValues = 2; |
|
1105 ExecuteStatementL(KDeleteComponentProperty, numberOfValues, EValueString, name, EValueInteger, componentId); |
|
1106 CleanupStack::PopAndDestroy(name); |
|
1107 } |
|
1108 |
|
1109 void CScrRequestImpl::DeleteFilePropertyL(const RMessage2& aMessage) |
|
1110 { |
|
1111 DEBUG_PRINTF(_L8("Deleting file property.")); |
|
1112 |
|
1113 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1114 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
1115 |
|
1116 TInt compFileId = FindComponentFileL(*fileName, componentId); |
|
1117 HBufC *propName = ReadDescLC(aMessage, 2); |
|
1118 |
|
1119 _LIT(KDeleteFileProperty, "DELETE FROM FileProperties WHERE CmpFileId=? AND Name=?;"); |
|
1120 TInt numberOfValues = 2; |
|
1121 ExecuteStatementL(KDeleteFileProperty, numberOfValues, EValueInteger, compFileId, EValueString, propName); |
|
1122 CleanupStack::PopAndDestroy(2, fileName); |
|
1123 } |
|
1124 |
|
1125 void CScrRequestImpl::UnregisterComponentFileL(const RMessage2& aMessage) |
|
1126 { |
|
1127 DEBUG_PRINTF(_L8("Unregistering a component file.")); |
|
1128 |
|
1129 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1130 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
1131 |
|
1132 TInt compFileId = GetComponentFileIdL(*fileName, componentId); |
|
1133 if (compFileId == KErrNotFound) |
|
1134 { |
|
1135 CleanupStack::PopAndDestroy(fileName); |
|
1136 return; // If the file is not registered, we do not return an error - this sort of condition is better enforced at upper layers |
|
1137 } |
|
1138 |
|
1139 _LIT(KDeleteComponentFileProperties, "DELETE from FileProperties WHERE CmpFileId=?;"); |
|
1140 TInt numberOfValues = 1; |
|
1141 ExecuteStatementL(KDeleteComponentFileProperties, numberOfValues, EValueInteger, compFileId); |
|
1142 DEBUG_PRINTF3(_L("Properties of the file(%S) of the component(%d) have been deleted."), fileName, componentId); |
|
1143 |
|
1144 _LIT(KUnregisterComponentFile, "DELETE FROM ComponentsFiles WHERE CmpFileId=?;"); |
|
1145 ExecuteStatementL(KUnregisterComponentFile, numberOfValues, EValueInteger, compFileId); |
|
1146 |
|
1147 // Reflect this file deletion in the installed drives field of the components table |
|
1148 UpdateInstalledDrivesL(componentId, *fileName, EFileUnregistered); |
|
1149 CleanupStack::PopAndDestroy(fileName); |
|
1150 } |
|
1151 |
|
1152 void ReadNullableStringFromStatementL(CStatement& aStmt, TPtrC& aValue, TInt aFieldNum) |
|
1153 { |
|
1154 aValue.Set(KNullDesC()); |
|
1155 if(!aStmt.IsFieldNullL(aFieldNum)) |
|
1156 { // If the value is not NULL, set it. |
|
1157 aValue.Set(aStmt.StrColumnL(aFieldNum)); |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 void CScrRequestImpl::DeleteComponentL(const RMessage2& aMessage) |
|
1162 { |
|
1163 DEBUG_PRINTF(_L8("Deleting a component.")); |
|
1164 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1165 |
|
1166 // first delete the applications associated with this id if there are any |
|
1167 DeleteAllAppsWithinPackageInternalL(componentId); |
|
1168 |
|
1169 // Create the log record before deleting the component |
|
1170 _LIT(KSelectComponentInfo, "SELECT SoftwareTypeName,GlobalId,Version FROM Components WHERE ComponentId=?;"); |
|
1171 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectComponentInfo); |
|
1172 stmt->BindIntL(1, componentId); |
|
1173 |
|
1174 // if the component doesn't exist, the code shouldn't come here. It should have left with KErrNotFound at security check level. |
|
1175 __ASSERT_ALWAYS(stmt->ProcessNextRowL(), User::Leave(KErrAbort)); |
|
1176 |
|
1177 CComponentEntry *entry2bDeleted = CComponentEntry::NewLC(); |
|
1178 entry2bDeleted->iSwType = stmt->StrColumnL(0).AllocL(); |
|
1179 |
|
1180 TPtrC globalId; |
|
1181 ReadNullableStringFromStatementL(*stmt, globalId, 1); |
|
1182 if(globalId.Length() > 0) |
|
1183 { |
|
1184 CGlobalComponentId *globalIdObj = ParseGlobalComponendIdLC(globalId); |
|
1185 entry2bDeleted->iGlobalId = globalIdObj->GlobalIdName().AllocL(); |
|
1186 CleanupStack::PopAndDestroy(globalIdObj); |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 entry2bDeleted->iGlobalId = globalId.AllocL(); |
|
1191 } |
|
1192 TPtrC version; |
|
1193 ReadNullableStringFromStatementL(*stmt, version, 2); |
|
1194 entry2bDeleted->iVersion = version.AllocL(); |
|
1195 AddComponentEntryLocalizablesL(componentId, *entry2bDeleted, KUnspecifiedLocale); |
|
1196 |
|
1197 CScrLogEntry *logRecord = CScrLogEntry::NewL(entry2bDeleted->Name(), entry2bDeleted->SoftwareType(), entry2bDeleted->GlobalId(), entry2bDeleted->Version(), EScrCompUnInstall); |
|
1198 logRecord->iComponentId = componentId; |
|
1199 CleanupStack::PopAndDestroy(2, stmt); // stmt, entry2bDeleted |
|
1200 CleanupStack::PushL(logRecord); |
|
1201 |
|
1202 // Now begin the component deletion |
|
1203 TInt numberOfValues = 1; |
|
1204 _LIT(KDeleteComponentProperties,"DELETE FROM ComponentProperties WHERE ComponentId=?;"); |
|
1205 ExecuteStatementL(KDeleteComponentProperties, numberOfValues, EValueInteger, componentId); |
|
1206 DEBUG_PRINTF2(_L8("Properties of component(%d) have been deleted."), componentId); |
|
1207 |
|
1208 _LIT(KDeleteComponentFileProperties, "DELETE from FileProperties WHERE CmpFileId IN \ |
|
1209 (SELECT CmpFileId FROM ComponentsFiles WHERE ComponentId=?);"); |
|
1210 ExecuteStatementL(KDeleteComponentFileProperties, numberOfValues, EValueInteger, componentId); |
|
1211 DEBUG_PRINTF2(_L8("Properties of files of component(%d) have been deleted."), componentId); |
|
1212 |
|
1213 _LIT(KDeleteComponentFiles, "DELETE FROM ComponentsFiles WHERE ComponentId=?;"); |
|
1214 ExecuteStatementL(KDeleteComponentFiles, numberOfValues, EValueInteger, componentId); |
|
1215 DEBUG_PRINTF2(_L8("File registrations of component(%d) have been deleted."), componentId); |
|
1216 |
|
1217 _LIT(KDeleteComponentLocalizables, "DELETE FROM ComponentLocalizables WHERE ComponentId=?;"); |
|
1218 ExecuteStatementL(KDeleteComponentLocalizables, numberOfValues, EValueInteger, componentId); |
|
1219 DEBUG_PRINTF2(_L8("Localizables of component(%d) have been deleted."), componentId); |
|
1220 |
|
1221 // Delete all dependencies where this component is dependant |
|
1222 _LIT(KDeleteComponentDependencies, "DELETE FROM ComponentDependencies WHERE DependantGlobalIdHash IN \ |
|
1223 (SELECT GlobalIdHash FROM Components WHERE ComponentId=?);"); |
|
1224 ExecuteStatementL(KDeleteComponentDependencies, numberOfValues, EValueInteger, componentId); |
|
1225 DEBUG_PRINTF2(_L8("Dependencies of component(%d) have been deleted."), componentId); |
|
1226 |
|
1227 _LIT(KDeleteComponents, "DELETE FROM Components WHERE ComponentId=?;"); |
|
1228 ExecuteStatementL(KDeleteComponents, numberOfValues, EValueInteger, componentId); |
|
1229 DEBUG_PRINTF2(_L8("Finally component(%d) has been deleted."), componentId); |
|
1230 |
|
1231 // Add log record |
|
1232 iLogEntries.Append(logRecord); |
|
1233 CleanupStack::Pop(logRecord); // Ownership is transferred |
|
1234 } |
|
1235 |
|
1236 void CScrRequestImpl::DeleteComponentDependencyL(const RMessage2& aMessage) |
|
1237 { |
|
1238 DEBUG_PRINTF(_L8("Deleting a component dependency.")); |
|
1239 |
|
1240 HBufC *suppGlobalId = ReadAndGetGlobalIdLC(aMessage, 1); |
|
1241 HBufC *depGlobalId = ReadAndGetGlobalIdLC(aMessage, 2); |
|
1242 TUint32 globalIdsHash = HashGlobalIdsL(*depGlobalId, *suppGlobalId); |
|
1243 CleanupStack::PopAndDestroy(2, suppGlobalId); // suppGlobalId,depGlobalId |
|
1244 |
|
1245 _LIT(KDeleteDependency, "DELETE FROM ComponentDependencies WHERE GlobalIdHash=?;"); |
|
1246 TInt numberOfValues = 1; |
|
1247 ExecuteStatementL(KDeleteDependency(), numberOfValues, EValueInteger, globalIdsHash); |
|
1248 } |
|
1249 |
|
1250 TBool CScrRequestImpl::BindAndProcessStatementObjectL(CStatement& aStatementObj, TLanguage aLanguage, TInt aValuesNum, VA_LIST aList) const |
|
1251 { |
|
1252 aStatementObj.ResetL(); |
|
1253 BindStatementValuesL(aStatementObj, aLanguage, aValuesNum, aList); |
|
1254 return aStatementObj.ProcessNextRowL(); |
|
1255 } |
|
1256 |
|
1257 CStatement* CScrRequestImpl::CreateStatementObjectWithoutLocaleL(const TDesC& aStatement, TInt aValuesNum,...) const |
|
1258 { |
|
1259 VA_LIST argList; |
|
1260 VA_START(argList, aValuesNum); |
|
1261 |
|
1262 CStatement *stmt = iDbHandle->PrepareStatementLC(aStatement); |
|
1263 |
|
1264 // The language parameter is irrelevant. The BindAndProcessStatementObjectL is reused here to avoid code duplication. |
|
1265 TBool success = BindAndProcessStatementObjectL(*stmt, ELangNone, aValuesNum, argList); |
|
1266 |
|
1267 VA_END(argList); |
|
1268 |
|
1269 if(!success) |
|
1270 { // if the code reaches here, it means there is no record for the given criteria |
|
1271 CleanupStack::PopAndDestroy(stmt); |
|
1272 return NULL; |
|
1273 } |
|
1274 CleanupStack::Pop(stmt); |
|
1275 return stmt; |
|
1276 } |
|
1277 |
|
1278 CStatement* CScrRequestImpl::CreateStatementObjectWithLocaleNoDowngradeL(const TDesC& aStatement, TLanguage aLocale, TInt aValuesNum,...) const |
|
1279 { |
|
1280 VA_LIST argList; |
|
1281 VA_START(argList, aValuesNum); |
|
1282 |
|
1283 CStatement *stmt = iDbHandle->PrepareStatementLC(aStatement); |
|
1284 TBool success = BindAndProcessStatementObjectL(*stmt, aLocale, aValuesNum, argList); |
|
1285 |
|
1286 if(!success) |
|
1287 { // if the code reaches here, it means there is no record for the given criteria |
|
1288 CleanupStack::PopAndDestroy(stmt); |
|
1289 return NULL; |
|
1290 } |
|
1291 |
|
1292 CleanupStack::Pop(stmt); |
|
1293 return stmt; |
|
1294 |
|
1295 } |
|
1296 |
|
1297 // This function tries automatically downgrading languages to the nearest locale |
|
1298 CStatement* CScrRequestImpl::CreateStatementObjectWithLocaleL(const TDesC& aStatement, TLanguage aLocale, TInt aValuesNum,...) const |
|
1299 { |
|
1300 VA_LIST argList; |
|
1301 VA_START(argList, aValuesNum); |
|
1302 |
|
1303 CStatement *stmt = iDbHandle->PrepareStatementLC(aStatement); |
|
1304 //Avoiding call to BAFL for the current locale. If succeeds, BAFL will not be invoked |
|
1305 TBool success = BindAndProcessStatementObjectL(*stmt, aLocale, aValuesNum, argList); |
|
1306 VA_START(argList, aValuesNum); |
|
1307 |
|
1308 if ( !success ) |
|
1309 { |
|
1310 // Run the given statement for the passed or its equivalent languages |
|
1311 // First, get the Equivalent Language path for the given locale. The first element |
|
1312 // in the array is the given language. |
|
1313 TLanguagePath equivalentLanguages; |
|
1314 BaflUtils::GetEquivalentLanguageList(aLocale, equivalentLanguages); |
|
1315 |
|
1316 TInt i = 1; //skipping the current locale |
|
1317 while ( equivalentLanguages[i] != ELangNone && !success) |
|
1318 { |
|
1319 success = BindAndProcessStatementObjectL(*stmt, equivalentLanguages[i], aValuesNum, argList); |
|
1320 VA_START(argList, aValuesNum); |
|
1321 i++; |
|
1322 } |
|
1323 VA_END(argList); |
|
1324 |
|
1325 if(!success) |
|
1326 { // if the code reaches here, it means there is no record for the given criteria |
|
1327 CleanupStack::PopAndDestroy(stmt); |
|
1328 return NULL; |
|
1329 } |
|
1330 } |
|
1331 else |
|
1332 { |
|
1333 VA_END(argList); |
|
1334 } |
|
1335 |
|
1336 CleanupStack::Pop(stmt); |
|
1337 return stmt; |
|
1338 } |
|
1339 |
|
1340 CComponentEntry* CScrRequestImpl::CreateComponentEntryFromStatementHandleL(CStatement& aStmt) const |
|
1341 { |
|
1342 TComponentId componentId = aStmt.IntColumnL(0); |
|
1343 TInt removable = aStmt.IntColumnL(3); |
|
1344 TInt64 size = aStmt.Int64ColumnL(4); |
|
1345 TScomoState scomoState = TScomoState(aStmt.IntColumnL(5)); |
|
1346 |
|
1347 TInt drmProtected = aStmt.IntColumnL(6); |
|
1348 TInt hidden = aStmt.IntColumnL(7); |
|
1349 TInt knownRevoked = aStmt.IntColumnL(8); |
|
1350 TInt originVerified = aStmt.IntColumnL(9); |
|
1351 |
|
1352 TPtrC globalIdDes; |
|
1353 ReadNullableStringFromStatementL(aStmt, globalIdDes, 10); |
|
1354 HBufC *globalId = NULL; |
|
1355 if(globalIdDes.Length()) |
|
1356 { // if global id is not NULL |
|
1357 CGlobalComponentId *globalIdObj = ParseGlobalComponendIdLC(globalIdDes); |
|
1358 globalId = globalIdObj->GlobalIdName().AllocL(); |
|
1359 CleanupStack::PopAndDestroy(globalIdObj); |
|
1360 CleanupStack::PushL(globalId); |
|
1361 } |
|
1362 else |
|
1363 { // Global Id is NULL |
|
1364 globalId = KNullDesC().AllocLC(); |
|
1365 } |
|
1366 |
|
1367 TInt installedDrivesBitmask = aStmt.IntColumnL(11); |
|
1368 // Convert bitmask to TDriveList |
|
1369 TDriveList installedDriveList; |
|
1370 installedDriveList.FillZ(KMaxDrives); |
|
1371 for (TInt i = 0; i < KMaxDrives && installedDrivesBitmask > 0; ++i, installedDrivesBitmask >>= 1) |
|
1372 { |
|
1373 installedDriveList[i] = installedDrivesBitmask & 0x1; |
|
1374 } |
|
1375 |
|
1376 TPtrC version(KNullDesC()); |
|
1377 if(!aStmt.IsFieldNullL(12)) |
|
1378 version.Set(aStmt.StrColumnL(12)); |
|
1379 |
|
1380 TPtrC installTime = aStmt.StrColumnL(13); |
|
1381 |
|
1382 CComponentEntry *entry = CComponentEntry::NewL(componentId, KNullDesC, KNullDesC, KNullDesC, *globalId, removable, size, scomoState, installedDriveList, version, installTime, drmProtected, hidden, knownRevoked, originVerified); |
|
1383 CleanupStack::PopAndDestroy(globalId); |
|
1384 return entry; |
|
1385 } |
|
1386 |
|
1387 // |
|
1388 // aLocalizableStmtStr = A SELECT statement which queries a table for a specific locale. In other words, the statement has got a locale condition. |
|
1389 // aAnyValueStmtStr = A SELECT statement which doesn't contain a locale condition. The result row set will include records with any locale. |
|
1390 // aConditionIntValue = The value of the integer condition of the statements given. |
|
1391 // aConditionLocale = The value of the locale condition of the localizable statement (first parameter). |
|
1392 // |
|
1393 CStatement* CScrRequestImpl::ExecuteLocalizableStatementL(const TDesC& aLocalizableStmtStr, const TDesC& aAnyValueStmtStr, TInt aConditionIntValue, TLanguage aConditionLocale) const |
|
1394 { |
|
1395 TInt numberOfValues = 2; |
|
1396 CStatement *stmtLoc(0); |
|
1397 |
|
1398 if(KUnspecifiedLocale == aConditionLocale) |
|
1399 { |
|
1400 // The locale is not specified. So, first try to run the statement for the current locale and its downgraded languages. |
|
1401 stmtLoc = CreateStatementObjectWithLocaleL(aLocalizableStmtStr, User::Language(), numberOfValues, EValueInteger, aConditionIntValue, EValueLanguage); |
|
1402 if (!stmtLoc) |
|
1403 { |
|
1404 // No result for the current locale at all. Try to find non-localized values. |
|
1405 stmtLoc = CreateStatementObjectWithLocaleL(aLocalizableStmtStr, KNonLocalized, numberOfValues, EValueInteger, aConditionIntValue, EValueLanguage); |
|
1406 } |
|
1407 |
|
1408 if (!stmtLoc) |
|
1409 { |
|
1410 // No result for the current locale or the non-localized, "neutral" locale. Try finding any locale |
|
1411 stmtLoc = CreateStatementObjectWithoutLocaleL(aAnyValueStmtStr, 1, EValueInteger, aConditionIntValue); |
|
1412 } |
|
1413 } |
|
1414 else if(KNonLocalized == aConditionLocale) |
|
1415 { |
|
1416 // Only non-localized names are requested. |
|
1417 stmtLoc = CreateStatementObjectWithLocaleL(aLocalizableStmtStr, KNonLocalized, numberOfValues, EValueInteger, aConditionIntValue, EValueLanguage); |
|
1418 } |
|
1419 else |
|
1420 { |
|
1421 // Names are requested for a particular locale. |
|
1422 stmtLoc = CreateStatementObjectWithLocaleL(aLocalizableStmtStr, aConditionLocale, numberOfValues, EValueInteger, aConditionIntValue, EValueLanguage); |
|
1423 } |
|
1424 |
|
1425 return stmtLoc; |
|
1426 } |
|
1427 |
|
1428 void CScrRequestImpl::AddComponentEntryLocalizablesL(TComponentId aComponentId, CComponentEntry& aEntry, TLanguage aLocale) const |
|
1429 { |
|
1430 DEBUG_PRINTF(_L8("Adding Component Entry Localizables.")); |
|
1431 _LIT(KSelectLocalizableNames, "SELECT Name,Vendor FROM ComponentLocalizables WHERE ComponentId=? AND Locale=?;"); |
|
1432 _LIT(KSelectAnyNames, "SELECT Name,Vendor FROM ComponentLocalizables WHERE ComponentId=?;"); |
|
1433 |
|
1434 CStatement *stmtLoc = ExecuteLocalizableStatementL(KSelectLocalizableNames, KSelectAnyNames, aComponentId, aLocale); |
|
1435 if(!stmtLoc) |
|
1436 { |
|
1437 DEBUG_PRINTF3(_L8("Name and Vendor couldn't be found for the component (%d) and locale(%d)."), aComponentId, aLocale); |
|
1438 User::Leave(KErrScrUnsupportedLocale); |
|
1439 } |
|
1440 |
|
1441 CleanupStack::PushL(stmtLoc); |
|
1442 |
|
1443 TPtrC name(stmtLoc->StrColumnL(0)); |
|
1444 TPtrC vendor(stmtLoc->StrColumnL(1)); |
|
1445 DeleteObjectZ(aEntry.iName); |
|
1446 aEntry.iName = name.AllocL(); // Ownership is transferred to the entry object |
|
1447 DeleteObjectZ(aEntry.iVendor); |
|
1448 if ( 0 != vendor.Ptr()) |
|
1449 aEntry.iVendor = vendor.AllocL(); // Ownership is transferred to the entry object |
|
1450 else |
|
1451 aEntry.iVendor = HBufC::NewL(1); |
|
1452 |
|
1453 CleanupStack::PopAndDestroy(stmtLoc); |
|
1454 } |
|
1455 |
|
1456 void CScrRequestImpl::AddSoftwareTypeNameToComponentEntryL(CStatement& aStmt, CComponentEntry& aEntry, TLanguage aLocale) const |
|
1457 { |
|
1458 DEBUG_PRINTF(_L8("Adding SoftwareType Name To Component Entry.")); |
|
1459 TInt softwareTypeId = aStmt.IntColumnL(1); |
|
1460 _LIT(KSelectLocalizableSwTypeName, "SELECT Name FROM SoftwareTypeNames WHERE SoftwareTypeId=? AND Locale=?;"); |
|
1461 CStatement *stmtLoc = ExecuteLocalizableStatementL(KSelectLocalizableSwTypeName, KSelectLocalizableSwTypeName, softwareTypeId, aLocale); |
|
1462 if(stmtLoc) |
|
1463 { |
|
1464 CleanupStack::PushL(stmtLoc); |
|
1465 TPtrC name(stmtLoc->StrColumnL(0)); |
|
1466 DeleteObjectZ(aEntry.iSwType); |
|
1467 aEntry.iSwType = name.AllocL(); // Ownership is transferred to the entry object |
|
1468 CleanupStack::PopAndDestroy(stmtLoc); |
|
1469 return; |
|
1470 } |
|
1471 |
|
1472 // The software type doesn't exist or there is no localized name of the software type, add the unique software type name |
|
1473 TPtrC uniqueSwTypeName = aStmt.StrColumnL(2); |
|
1474 DeleteObjectZ(aEntry.iSwType); |
|
1475 aEntry.iSwType = uniqueSwTypeName.AllocL(); // Ownership is transferred to the entry object |
|
1476 } |
|
1477 |
|
1478 void CScrRequestImpl::GetGeneralComponentEntrySizeL(const RMessage2& aMessage, const TDesC& aConditionColumn, TUint32 aConditionValue, TInt aReturnSizeSlot, TLanguage aLocale, CComponentEntry*& aComponentEntry) const |
|
1479 { |
|
1480 _LIT(KSelectComponents, "SELECT ComponentId,SoftwareTypeId,SoftwareTypeName,Removable,Size,ScomoState,DRMProtected,Hidden,KnownRevoked,OriginVerified,GlobalId,InstalledDrives,Version,InstallTime FROM Components WHERE %S=?;"); |
|
1481 |
|
1482 TInt formattedLen = aConditionColumn.Length(); |
|
1483 HBufC *statementStr = FormatStatementLC(KSelectComponents(), formattedLen, &aConditionColumn); |
|
1484 CStatement *stmt = iDbHandle->PrepareStatementLC(*statementStr); |
|
1485 stmt->BindIntL(1, aConditionValue); |
|
1486 |
|
1487 if(!stmt->ProcessNextRowL()) |
|
1488 { |
|
1489 DEBUG_PRINTF2(_L8("The component(%d) couldn't be found. The size returned is zero."), aConditionValue); |
|
1490 WriteIntValueL(aMessage, aReturnSizeSlot, 0); |
|
1491 CleanupStack::PopAndDestroy(2, statementStr); // statementStr, stmt |
|
1492 return; |
|
1493 } |
|
1494 |
|
1495 DeleteObjectZ(aComponentEntry); |
|
1496 aComponentEntry = CreateComponentEntryFromStatementHandleL(*stmt); |
|
1497 AddComponentEntryLocalizablesL(aComponentEntry->ComponentId(), *aComponentEntry, aLocale); |
|
1498 AddSoftwareTypeNameToComponentEntryL(*stmt, *aComponentEntry, aLocale); |
|
1499 |
|
1500 WriteObjectSizeL(aMessage, aReturnSizeSlot, aComponentEntry); |
|
1501 CleanupStack::PopAndDestroy(2, statementStr); // statementStr, stmt |
|
1502 } |
|
1503 |
|
1504 void CScrRequestImpl::GetComponentEntrySizeL(const RMessage2& aMessage) const |
|
1505 { |
|
1506 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1507 DEBUG_PRINTF2(_L8("Returning the entry size of component(%d)."), componentId); |
|
1508 TLanguage locale = TLanguage(aMessage.Int1()); |
|
1509 |
|
1510 _LIT(KConditionColumn, "ComponentId"); |
|
1511 TInt returnSizeSlot=2; |
|
1512 GetGeneralComponentEntrySizeL(aMessage, KConditionColumn(), componentId, returnSizeSlot, locale, iComponentEntry); |
|
1513 } |
|
1514 |
|
1515 void CScrRequestImpl::GetComponentEntryDataL(const RMessage2& aMessage) const |
|
1516 { |
|
1517 DEBUG_PRINTF(_L8("Returning the component entry data.")); |
|
1518 WriteObjectDataL(aMessage, 0, iComponentEntry); |
|
1519 DeleteObjectZ(iComponentEntry); // Delete the object to prevent it to be resent. |
|
1520 } |
|
1521 |
|
1522 void CScrRequestImpl::GetComponentLocalizedEntrySizeL(const RMessage2& aMessage) const |
|
1523 { |
|
1524 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1525 DEBUG_PRINTF2(_L8("Returning the localized information entry size of component(%d)."), componentId); |
|
1526 _LIT(KSelectMatchingSupportedLocales, "SELECT Locale, Name, Vendor FROM ComponentLocalizables WHERE ComponentId=?;"); |
|
1527 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectMatchingSupportedLocales); |
|
1528 stmt->BindIntL(1, componentId); |
|
1529 while(stmt->ProcessNextRowL()) |
|
1530 { |
|
1531 TPtrC name(stmt->StrColumnL(1)); |
|
1532 TPtrC vendor(stmt->StrColumnL(2)); |
|
1533 TInt locale(stmt->IntColumnL(0)); |
|
1534 CLocalizableComponentInfo *compLocalizedInfo = Usif::CLocalizableComponentInfo::NewLC( name, vendor,(TLanguage)locale); |
|
1535 iCompLocalizedInfoArray.Insert(compLocalizedInfo,iCompLocalizedInfoArray.Count()); |
|
1536 CleanupStack::Pop(compLocalizedInfo); |
|
1537 } |
|
1538 // Release allocated memories |
|
1539 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
1540 WriteArraySizeL(aMessage, 1, iCompLocalizedInfoArray); |
|
1541 } |
|
1542 |
|
1543 void CScrRequestImpl::GetComponentLocalizedEntryDataL(const RMessage2& aMessage) const |
|
1544 { |
|
1545 DEBUG_PRINTF(_L8("Returning the localized information entry data.")); |
|
1546 WriteArrayDataL(aMessage, 0, iCompLocalizedInfoArray); |
|
1547 iCompLocalizedInfoArray.ResetAndDestroy(); |
|
1548 } |
|
1549 |
|
1550 TBool CompareProperties(const CPropertyEntry& aRhs, const CPropertyEntry& aLhs) |
|
1551 { |
|
1552 return ((aRhs.PropertyType() == aLhs.PropertyType()) && |
|
1553 (aRhs.PropertyName() == aLhs.PropertyName())); |
|
1554 } |
|
1555 |
|
1556 void CScrRequestImpl::AddGeneralPropertiesArrayWithLocaleL(const TDesC& aStmtStr, TLanguage aLocale, TComponentId aIdColumnValue, RPointerArray<CPropertyEntry>& aProperties) const |
|
1557 { |
|
1558 DEBUG_PRINTF(_L8("Adding General Properties Array With Locale.")); |
|
1559 |
|
1560 TInt numberOfValues = 2; |
|
1561 CStatement *stmt = CreateStatementObjectWithLocaleL(aStmtStr, aLocale, numberOfValues, EValueInteger, aIdColumnValue, EValueLanguage); |
|
1562 if(!stmt) |
|
1563 { |
|
1564 return; |
|
1565 } |
|
1566 CleanupStack::PushL(stmt); |
|
1567 do |
|
1568 { |
|
1569 TPtrC name(stmt->StrColumnL(0)); |
|
1570 CPropertyEntry *entry = GetPropertyEntryL(*stmt, name, 1); // aStartingIndex=1 |
|
1571 CleanupStack::PushL(entry); |
|
1572 if(KErrNotFound == aProperties.Find(entry, TIdentityRelation<CPropertyEntry>(CompareProperties))) |
|
1573 { |
|
1574 aProperties.AppendL(entry); |
|
1575 CleanupStack::Pop(entry); // because array is now owner |
|
1576 } |
|
1577 else |
|
1578 { |
|
1579 CleanupStack::PopAndDestroy(entry); |
|
1580 } |
|
1581 } while(stmt->ProcessNextRowL()); |
|
1582 CleanupStack::PopAndDestroy(stmt); |
|
1583 } |
|
1584 |
|
1585 void CScrRequestImpl::GetGeneralPropertiesArrayL(const TDesC& aTableName, const TDesC& aIdColumnName , TComponentId aIdColumnValue, TLanguage aLocale, RPointerArray<CPropertyEntry>& aProperties) const |
|
1586 { |
|
1587 DEBUG_PRINTF(_L8("Returning General Properties Array.")); |
|
1588 |
|
1589 _LIT(KSelectGeneralLocalizableProperties, "SELECT Name,IntValue,StrValue,Locale,IsStr8Bit FROM %S WHERE %S=? AND Locale=?;"); |
|
1590 TInt formattedLen = aTableName.Length() + aIdColumnName.Length(); |
|
1591 HBufC *statementStr = FormatStatementLC(KSelectGeneralLocalizableProperties, formattedLen, &aTableName, &aIdColumnName ); |
|
1592 |
|
1593 if(KUnspecifiedLocale == aLocale) |
|
1594 { |
|
1595 // Locale is not specified. First get non-localized properties |
|
1596 AddGeneralPropertiesArrayWithLocaleL(*statementStr, KNonLocalized, aIdColumnValue, aProperties); |
|
1597 // Then get the localizable properties with the current locale |
|
1598 AddGeneralPropertiesArrayWithLocaleL(*statementStr, User::Language(), aIdColumnValue, aProperties); |
|
1599 } |
|
1600 else if(KNonLocalized == aLocale) |
|
1601 { |
|
1602 // Only non-localized properties are requested. |
|
1603 AddGeneralPropertiesArrayWithLocaleL(*statementStr, KNonLocalized, aIdColumnValue, aProperties); |
|
1604 } |
|
1605 else |
|
1606 { |
|
1607 // Locale is specified. It means that only properties with this locale are wanted |
|
1608 AddGeneralPropertiesArrayWithLocaleL(*statementStr, aLocale, aIdColumnValue, aProperties); |
|
1609 } |
|
1610 |
|
1611 CleanupStack::PopAndDestroy(statementStr); |
|
1612 #ifdef _DEBUG |
|
1613 if(!aProperties.Count()) |
|
1614 DEBUG_PRINTF4(_L("Property couldn't be found for column name=(%S), column id=%d and locale=%d."), &aIdColumnName, aIdColumnValue, aLocale); |
|
1615 #endif |
|
1616 } |
|
1617 |
|
1618 void CScrRequestImpl::GetFilePropertiesSizeL(const RMessage2& aMessage) const |
|
1619 { |
|
1620 DEBUG_PRINTF(_L8("Returning the size of file properties.")); |
|
1621 |
|
1622 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1623 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
1624 |
|
1625 TInt compFileId = FindComponentFileL(*fileName, componentId); |
|
1626 |
|
1627 iProperties.ResetAndDestroy(); |
|
1628 GetGeneralPropertiesArrayL(KFilePropertiesTable(), KCompFileIdColumnName, compFileId, KNonLocalized, iProperties); |
|
1629 CleanupStack::PopAndDestroy(fileName); |
|
1630 WriteArraySizeL(aMessage, 2, iProperties); |
|
1631 } |
|
1632 |
|
1633 void CScrRequestImpl::GetFilePropertiesDataL(const RMessage2& aMessage) const |
|
1634 { |
|
1635 DEBUG_PRINTF(_L8("Returning the file properties data.")); |
|
1636 WriteArrayDataL(aMessage, 0, iProperties); |
|
1637 } |
|
1638 |
|
1639 CPropertyEntry* CScrRequestImpl::GetPropertyEntryL(CStatement& aStmt, const TDesC& aPropName, TInt aStartingIndex) const |
|
1640 { |
|
1641 DEBUG_PRINTF(_L8("Returning the file properties entry.")); |
|
1642 |
|
1643 CPropertyEntry *entry(0); |
|
1644 |
|
1645 if(!aStmt.IsFieldNullL(aStartingIndex)) |
|
1646 { |
|
1647 TInt64 intVal = aStmt.Int64ColumnL(aStartingIndex); |
|
1648 entry = CIntPropertyEntry::NewL(aPropName, intVal); |
|
1649 } |
|
1650 else if(!aStmt.IsFieldNullL(aStartingIndex+1)) |
|
1651 { |
|
1652 TBool is8BitString = (aStmt.IntColumnL(aStartingIndex + 3) != 0); |
|
1653 if (is8BitString) |
|
1654 { |
|
1655 TPtrC8 binaryVal(aStmt.BinaryColumnL(aStartingIndex+1)); |
|
1656 entry = CBinaryPropertyEntry::NewL(aPropName, binaryVal); |
|
1657 } |
|
1658 else |
|
1659 { |
|
1660 TPtrC strVal(aStmt.StrColumnL(aStartingIndex+1)); |
|
1661 TLanguage locale = TLanguage(aStmt.IntColumnL(aStartingIndex + 2)); |
|
1662 entry = CLocalizablePropertyEntry::NewL(aPropName, strVal, locale); |
|
1663 } |
|
1664 } |
|
1665 else |
|
1666 {// Should never come here - shows DB inconsistency |
|
1667 DEBUG_PRINTF(_L("Both integer and string values are NULL. Inconsistency problem!")); |
|
1668 User::Leave(KErrCorrupt); |
|
1669 } |
|
1670 return entry; |
|
1671 } |
|
1672 |
|
1673 CPropertyEntry* CScrRequestImpl::GetGeneralSinglePropertyL(const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, TLanguage aLocale) const |
|
1674 { |
|
1675 DEBUG_PRINTF5(_L("Getting general single property for %S. PropName=%S, Id=%d, Locale=%d"), &aIdColumnName , &aPropName, aIdColumnValue, aLocale); |
|
1676 |
|
1677 _LIT(KSelectSingleGeneralProperty, "SELECT IntValue,StrValue,Locale,IsStr8Bit FROM %S WHERE Name=? AND %S=? AND Locale=?;"); |
|
1678 TInt formattedLen = aTableName.Length() + aIdColumnName.Length(); |
|
1679 HBufC *statementStr = FormatStatementLC(KSelectSingleGeneralProperty, formattedLen, &aTableName, &aIdColumnName ); |
|
1680 |
|
1681 CStatement *stmt = CreateGeneralPropertyStatementWithLocaleL(*statementStr, aIdColumnValue, aLocale, aPropName); |
|
1682 if(!stmt) |
|
1683 { |
|
1684 DEBUG_PRINTF4(_L("Property couldn't be found for column name=(%S), column id=%d and locale=%d."), &aIdColumnName, aIdColumnValue, aLocale); |
|
1685 CleanupStack::PopAndDestroy(statementStr); |
|
1686 return NULL; |
|
1687 } |
|
1688 CleanupStack::PushL(stmt); |
|
1689 |
|
1690 CPropertyEntry *entry = GetPropertyEntryL(*stmt, aPropName, 0); // aStartingIndex=0 |
|
1691 CleanupStack::PopAndDestroy(2, statementStr); // statementStr, stmt |
|
1692 return entry; |
|
1693 } |
|
1694 |
|
1695 void CScrRequestImpl::GetSingleFilePropertySizeL(const RMessage2& aMessage) const |
|
1696 { |
|
1697 DEBUG_PRINTF(_L8("Returning the size of single file property.")); |
|
1698 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1699 HBufC* fileName = ReadFileNameFromMsgLC(aMessage); |
|
1700 HBufC *propName = ReadDescLC(aMessage, 2); |
|
1701 |
|
1702 TInt compFileId = FindComponentFileL(*fileName, componentId); |
|
1703 |
|
1704 DeleteObjectZ(iSingleProperty); |
|
1705 iSingleProperty = GetGeneralSinglePropertyL(KFilePropertiesTable(), KCompFileIdColumnName, compFileId, *propName, KNonLocalized); |
|
1706 CleanupStack::PopAndDestroy(2, fileName); // fileName, propName |
|
1707 WriteObjectSizeL(aMessage, 3, iSingleProperty); |
|
1708 } |
|
1709 |
|
1710 void CScrRequestImpl::GetSingleFilePropertyDataL(const RMessage2& aMessage) const |
|
1711 { |
|
1712 DEBUG_PRINTF(_L8("Returning the single file property data.")); |
|
1713 WriteObjectDataL(aMessage, 0, iSingleProperty); |
|
1714 DeleteObjectZ(iSingleProperty); // Delete the object to prevent it to be resent. |
|
1715 } |
|
1716 |
|
1717 void CScrRequestImpl::GetComponentFilesCountL(const RMessage2& aMessage) const |
|
1718 { |
|
1719 DEBUG_PRINTF(_L8("Returning the Component Files Count.")); |
|
1720 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1721 |
|
1722 DEBUG_PRINTF2(_L8("Returning the files count for component %d."), componentId); |
|
1723 |
|
1724 _LIT(KGetComponentFilesCount, "SELECT COUNT(CmpFileId) FROM ComponentsFiles WHERE ComponentId=?;"); |
|
1725 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetComponentFilesCount); |
|
1726 stmt->BindIntL(1, componentId); |
|
1727 |
|
1728 TBool res = stmt->ProcessNextRowL(); |
|
1729 // DB Query did not return a single row for component files count query - internal error! |
|
1730 __ASSERT_ALWAYS(res, User::Leave(KErrAbort)); |
|
1731 |
|
1732 TInt filesCountTmp = stmt->IntColumnL(0); |
|
1733 __ASSERT_DEBUG(filesCountTmp >= 0, User::Leave(KErrAbort)); |
|
1734 TUint filesCount = static_cast<TUint>(filesCountTmp); |
|
1735 CleanupStack::PopAndDestroy(stmt); |
|
1736 |
|
1737 TPckg<TUint> filesCountPkg(filesCount); |
|
1738 aMessage.WriteL(1, filesCountPkg); |
|
1739 } |
|
1740 |
|
1741 void CScrRequestImpl::GetFileComponentsL(const TDesC& aFileName, RArray<TComponentId>& aComponents) const |
|
1742 { |
|
1743 DEBUG_PRINTF(_L8("Returning the File Components.")); |
|
1744 _LIT(KSelectFileComponents, "SELECT ComponentId FROM ComponentsFiles WHERE LocationHash=?;"); |
|
1745 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectFileComponents); |
|
1746 TUint32 hash = HashCaseInsensitiveL(aFileName); |
|
1747 stmt->BindIntL(1, hash); |
|
1748 |
|
1749 while(stmt->ProcessNextRowL()) |
|
1750 { |
|
1751 User::LeaveIfError(aComponents.InsertInOrder(stmt->IntColumnL(0))); |
|
1752 } |
|
1753 CleanupStack::PopAndDestroy(stmt); |
|
1754 } |
|
1755 |
|
1756 void CScrRequestImpl::GetFileComponentsSizeL(const RMessage2& aMessage) const |
|
1757 { |
|
1758 HBufC *fileName = ReadDescLC(aMessage, 0); |
|
1759 |
|
1760 iFileComponents.Reset(); |
|
1761 GetFileComponentsL(*fileName, iFileComponents); |
|
1762 CleanupStack::PopAndDestroy(fileName); |
|
1763 |
|
1764 WriteArraySizeL(aMessage, 1, iFileComponents); |
|
1765 } |
|
1766 |
|
1767 void CScrRequestImpl::GetFileComponentsDataL(const RMessage2& aMessage) const |
|
1768 { |
|
1769 DEBUG_PRINTF(_L8("Returning the File Components Data.")); |
|
1770 WriteArrayDataL(aMessage, 0, iFileComponents); |
|
1771 } |
|
1772 |
|
1773 void CScrRequestImpl::GetComponentPropertiesSizeL(const RMessage2& aMessage) const |
|
1774 { |
|
1775 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1776 TLanguage locale = TLanguage(aMessage.Int1()); |
|
1777 |
|
1778 iProperties.ResetAndDestroy(); |
|
1779 GetGeneralPropertiesArrayL(KComponentPropertiesTable(), KComponentIdColumnName, componentId, locale, iProperties); |
|
1780 WriteArraySizeL(aMessage, 2, iProperties); |
|
1781 } |
|
1782 |
|
1783 void CScrRequestImpl::GetComponentPropertiesDataL(const RMessage2& aMessage) const |
|
1784 { |
|
1785 WriteArrayDataL(aMessage, 0, iProperties); |
|
1786 } |
|
1787 |
|
1788 void CScrRequestImpl::GetComponentSinglePropertySizeL(const RMessage2& aMessage) const |
|
1789 { |
|
1790 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1791 HBufC *propName = ReadDescLC(aMessage, 1); |
|
1792 TLanguage locale = TLanguage(aMessage.Int2()); |
|
1793 |
|
1794 DeleteObjectZ(iSingleProperty); |
|
1795 iSingleProperty = GetGeneralSinglePropertyL(KComponentPropertiesTable(), KComponentIdColumnName, componentId, *propName, locale); |
|
1796 CleanupStack::PopAndDestroy(propName); |
|
1797 WriteObjectSizeL(aMessage, 3, iSingleProperty); |
|
1798 } |
|
1799 |
|
1800 void CScrRequestImpl::GetComponentSinglePropertyDataL(const RMessage2& aMessage) const |
|
1801 { |
|
1802 WriteObjectDataL(aMessage, 0, iSingleProperty); |
|
1803 DeleteObjectZ(iSingleProperty); // Delete the object to prevent it to be resent. |
|
1804 } |
|
1805 |
|
1806 TUint32 CScrRequestImpl::ReadAndHashGlobalIdL(const RMessage2& aMessage, TInt aGlobalIdNameSlot, TInt aSwTypeNameSlot) const |
|
1807 { |
|
1808 HBufC *globalIdName = ReadDescLC(aMessage, aGlobalIdNameSlot); |
|
1809 HBufC *swTypeName = ReadDescLC(aMessage, aSwTypeNameSlot); |
|
1810 |
|
1811 // Concatenate the software type id with the global id name |
|
1812 HBufC *globalId = GenerateGlobalIdL(*swTypeName, *globalIdName); |
|
1813 CleanupStack::PushL(globalId); |
|
1814 // Hash the concatenated value |
|
1815 TUint32 globalIdHash = HashCaseSensitiveL(*globalId); |
|
1816 CleanupStack::PopAndDestroy(3, globalIdName); // globalIdName, swTypeName, concatGlobalId |
|
1817 return globalIdHash; |
|
1818 } |
|
1819 |
|
1820 void CScrRequestImpl::GetComponentIdL(const RMessage2& aMessage) const |
|
1821 { |
|
1822 DEBUG_PRINTF(_L8("Returning the local component id of a received global id.")); |
|
1823 |
|
1824 TUint32 globalIdHash = ReadAndHashGlobalIdL(aMessage, 0, 1); |
|
1825 |
|
1826 _LIT(KSelectComponentId, "SELECT ComponentId FROM Components WHERE GlobalIdHash=?;"); |
|
1827 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectComponentId); |
|
1828 stmt->BindIntL(1, globalIdHash); |
|
1829 |
|
1830 if(!stmt->ProcessNextRowL()) |
|
1831 { |
|
1832 DEBUG_PRINTF2(_L8("There is no local component id corresponding to the supplied global id (hash=%d)."), globalIdHash); |
|
1833 User::Leave(KErrNotFound); |
|
1834 } |
|
1835 |
|
1836 TComponentId compId = stmt->IntColumnL(0); |
|
1837 CleanupStack::PopAndDestroy(stmt); |
|
1838 |
|
1839 TPckg<TComponentId> componentIdDes(compId); |
|
1840 aMessage.WriteL(2, componentIdDes); |
|
1841 } |
|
1842 |
|
1843 void CScrRequestImpl::GetComponentWithGlobalIdSizeL(const RMessage2& aMessage) const |
|
1844 { |
|
1845 TUint32 globalIdHash = ReadAndHashGlobalIdL(aMessage, 0, 1); |
|
1846 TLanguage locale = TLanguage(aMessage.Int2()); |
|
1847 |
|
1848 _LIT(KConditionColumn, "GlobalIdHash"); |
|
1849 TInt returnSizeSlot=3; |
|
1850 GetGeneralComponentEntrySizeL(aMessage, KConditionColumn(), globalIdHash, returnSizeSlot, locale, iComponentEntry); |
|
1851 } |
|
1852 |
|
1853 void CScrRequestImpl::GetComponentWithGlobalIdDataL(const RMessage2& aMessage) const |
|
1854 { |
|
1855 WriteObjectDataL(aMessage, 0, iComponentEntry); |
|
1856 DeleteObjectZ(iComponentEntry); // Delete the object to prevent the usage of this function |
|
1857 // without calling GetComponentWithGlobalIdSizeL. |
|
1858 } |
|
1859 |
|
1860 CGlobalComponentId* CScrRequestImpl::ParseGlobalComponendIdLC(const TDesC& aGlobalId) const |
|
1861 { |
|
1862 TChar nullCr = '\0'; |
|
1863 TInt pos = aGlobalId.Locate(nullCr); |
|
1864 __ASSERT_ALWAYS(pos != KErrNotFound, User::Leave(KErrCorrupt)); |
|
1865 |
|
1866 TPtrC swTypeName = aGlobalId.Left(pos); |
|
1867 TPtrC globalIdName = aGlobalId.Right(aGlobalId.Length() - pos - 1); |
|
1868 |
|
1869 return CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
1870 } |
|
1871 |
|
1872 void CScrRequestImpl::GetGeneralDependencyListL(const TDesC& aSelectColumn, const TDesC& aConditionColumn, const TDesC& aConditionValue, RPointerArray<CVersionedComponentId> &aVerCompIdList) const |
|
1873 { |
|
1874 DEBUG_PRINTF(_L8("Returning General Dependency List.")); |
|
1875 _LIT(KSelectDependencies, "SELECT %S,VersionFrom,VersionTo FROM ComponentDependencies WHERE %S=?;"); |
|
1876 TInt formattedLen = aSelectColumn.Length() + aConditionColumn.Length(); |
|
1877 HBufC *stmtStr = FormatStatementLC(KSelectDependencies(), formattedLen, &aSelectColumn, &aConditionColumn); |
|
1878 |
|
1879 CStatement *stmt = iDbHandle->PrepareStatementLC(*stmtStr); |
|
1880 TUint32 conditionValueHash = HashCaseSensitiveL(aConditionValue); |
|
1881 stmt->BindIntL(1, conditionValueHash); |
|
1882 |
|
1883 while(stmt->ProcessNextRowL()) |
|
1884 { |
|
1885 TPtrC selectedGlobalId(stmt->StrColumnL(0)); |
|
1886 CGlobalComponentId *globalId = ParseGlobalComponendIdLC(selectedGlobalId); |
|
1887 |
|
1888 TPtrC versionFrom; |
|
1889 ReadNullableStringFromStatementL(*stmt, versionFrom, 1); |
|
1890 TPtrC versionTo; |
|
1891 ReadNullableStringFromStatementL(*stmt, versionTo, 2); |
|
1892 |
|
1893 CVersionedComponentId *verCompId = CVersionedComponentId::NewLC(*globalId, &versionFrom, &versionTo); |
|
1894 aVerCompIdList.AppendL(verCompId); |
|
1895 |
|
1896 CleanupStack::Pop(verCompId); // Ownership passed to the array |
|
1897 CleanupStack::PopAndDestroy(globalId); |
|
1898 } |
|
1899 |
|
1900 CleanupStack::PopAndDestroy(2, stmtStr); // stmtStr, stmt |
|
1901 } |
|
1902 |
|
1903 void CScrRequestImpl::GetSupplierComponentsSizeL(const RMessage2& aMessage) const |
|
1904 { |
|
1905 HBufC *dependantGlobalId = ReadAndGetGlobalIdLC(aMessage, 0); |
|
1906 |
|
1907 _LIT(KSelectColumn, "SupplierGlobalId"); |
|
1908 _LIT(KConditionColumn, "DependantGlobalIdHash"); |
|
1909 iVerCompIdList.ResetAndDestroy(); |
|
1910 |
|
1911 GetGeneralDependencyListL(KSelectColumn(), KConditionColumn(), *dependantGlobalId, iVerCompIdList); |
|
1912 CleanupStack::PopAndDestroy(dependantGlobalId); |
|
1913 WriteArraySizeL(aMessage, 1, iVerCompIdList); |
|
1914 } |
|
1915 |
|
1916 void CScrRequestImpl::GetSupplierComponentsDataL(const RMessage2& aMessage) const |
|
1917 { |
|
1918 WriteArrayDataL(aMessage, 0, iVerCompIdList); |
|
1919 } |
|
1920 |
|
1921 void CScrRequestImpl::GetDependantComponentsSizeL(const RMessage2& aMessage) const |
|
1922 { |
|
1923 |
|
1924 HBufC *supplierGlobalId = ReadAndGetGlobalIdLC(aMessage, 0); |
|
1925 |
|
1926 _LIT(KSelectColumn, "DependantGlobalId"); |
|
1927 _LIT(KConditionColumn, "SupplierGlobalIdHash"); |
|
1928 iVerCompIdList.ResetAndDestroy(); |
|
1929 |
|
1930 GetGeneralDependencyListL(KSelectColumn(), KConditionColumn(), *supplierGlobalId, iVerCompIdList); |
|
1931 CleanupStack::PopAndDestroy(supplierGlobalId); |
|
1932 WriteArraySizeL(aMessage, 1, iVerCompIdList); |
|
1933 } |
|
1934 |
|
1935 void CScrRequestImpl::GetDependantComponentsDataL(const RMessage2& aMessage) const |
|
1936 { |
|
1937 DEBUG_PRINTF(_L8("Returning Dependant Components Data.")); |
|
1938 WriteArrayDataL(aMessage, 0, iVerCompIdList); |
|
1939 } |
|
1940 |
|
1941 void CScrRequestImpl::GetIsMediaPresentL(const RMessage2& aMessage) const |
|
1942 { |
|
1943 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1944 DEBUG_PRINTF2(_L8("Retrieving media presence of component(%d)."), componentId); |
|
1945 |
|
1946 TBool result = CheckForMediaPresenceL(componentId); |
|
1947 |
|
1948 TPckg<TBool> resultPkg(result); |
|
1949 aMessage.WriteL(1, resultPkg); |
|
1950 } |
|
1951 |
|
1952 TBool CScrRequestImpl::CheckForMediaPresenceL(TComponentId aComponentId) const |
|
1953 { |
|
1954 DEBUG_PRINTF(_L8("Check For Media Presence.")); |
|
1955 TInt componentDrivesBitmask = GetInstalledDrivesBitmaskL(aComponentId); |
|
1956 |
|
1957 TDriveList presentDriveSet; |
|
1958 User::LeaveIfError(iFs.DriveList(presentDriveSet)); |
|
1959 |
|
1960 // Check for each drive whether it is present in the system |
|
1961 for (TInt drive=0; componentDrivesBitmask; componentDrivesBitmask >>= 1, ++drive) |
|
1962 { |
|
1963 if ((componentDrivesBitmask & 0x1) && (presentDriveSet.Length() <= drive || !presentDriveSet[drive])) |
|
1964 { |
|
1965 DEBUG_PRINTF3(_L8("Component %d registers a file at drive %c which is not present. Returning EFalse for IsMediaPresent)."), aComponentId, drive + 'a'); |
|
1966 return EFalse; |
|
1967 } |
|
1968 } |
|
1969 |
|
1970 return ETrue; |
|
1971 } |
|
1972 |
|
1973 void CScrRequestImpl::SetScomoStateL(const RMessage2& aMessage) |
|
1974 { |
|
1975 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
1976 TScomoState state = static_cast<TScomoState>(aMessage.Int1()); |
|
1977 DEBUG_PRINTF3(_L8("Updating the scomo state of component(%d). New value=%d."), componentId, state); |
|
1978 |
|
1979 _LIT(KUpdateScomoState, "UPDATE Components SET ScomoState=? WHERE ComponentId=?;"); |
|
1980 TInt numberOfValues = 2; |
|
1981 ExecuteStatementL(KUpdateScomoState, numberOfValues, EValueInteger, state, EValueInteger, componentId); |
|
1982 } |
|
1983 |
|
1984 void CScrRequestImpl::GetPluginUidWithMimeTypeL(const RMessage2& aMessage) const |
|
1985 { |
|
1986 DEBUG_PRINTF(_L8("Returning plugin for MIME type.")); |
|
1987 HBufC *mimeType = ReadDescLC(aMessage, 0); |
|
1988 |
|
1989 _LIT(KSelectPluginsWithMimeType, "SELECT SifPluginUid FROM SoftwareTypes WHERE SoftwareTypeId IN (SELECT SoftwareTypeId FROM MimeTypes WHERE MimeType=?);"); |
|
1990 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectPluginsWithMimeType); |
|
1991 stmt->BindStrL(1, *mimeType); |
|
1992 if(!stmt->ProcessNextRowL()) |
|
1993 { |
|
1994 DEBUG_PRINTF2(_L("Sif Plugin Uid couldn't be found for Mime Type (%S)!"), mimeType); |
|
1995 User::Leave(KErrSifUnsupportedSoftwareType); |
|
1996 } |
|
1997 TUint32 uid = stmt->IntColumnL(0); |
|
1998 CleanupStack::PopAndDestroy(2, mimeType); // mimeType, stmt |
|
1999 |
|
2000 TPckg<TUint32> uidDes(uid); |
|
2001 aMessage.WriteL(1, uidDes); |
|
2002 } |
|
2003 |
|
2004 TBool CScrRequestImpl::GetSifPluginUidIInternalL(TInt aSoftwareTypeId, TInt& aValue) const |
|
2005 { |
|
2006 DEBUG_PRINTF(_L8("Returning Sif Plugin UidI Internal.")); |
|
2007 TBool found = EFalse; |
|
2008 |
|
2009 _LIT(KSelectSifPluginUid, "SELECT SifPluginUid FROM SoftwareTypes WHERE SoftwareTypeId=?;"); |
|
2010 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectSifPluginUid); |
|
2011 stmt->BindIntL(1, aSoftwareTypeId); |
|
2012 |
|
2013 if(stmt->ProcessNextRowL()) |
|
2014 { |
|
2015 aValue = stmt->IntColumnL(0); |
|
2016 found = ETrue; |
|
2017 } |
|
2018 CleanupStack::PopAndDestroy(stmt); |
|
2019 return found; |
|
2020 } |
|
2021 |
|
2022 TBool CScrRequestImpl::GetSidsForSoftwareTypeIdL(TInt aSoftwareTypeId, RArray<TSecureId>& aSids) const |
|
2023 { |
|
2024 TBool found = EFalse; |
|
2025 |
|
2026 _LIT(KSelectSecureIds, "SELECT SecureId FROM CustomAccessList WHERE SoftwareTypeId=?;"); |
|
2027 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectSecureIds); |
|
2028 stmt->BindIntL(1, aSoftwareTypeId); |
|
2029 |
|
2030 aSids.Reset(); |
|
2031 while(stmt->ProcessNextRowL()) |
|
2032 { |
|
2033 aSids.AppendL(stmt->IntColumnL(0)); |
|
2034 found = ETrue; |
|
2035 } |
|
2036 |
|
2037 CleanupStack::PopAndDestroy(stmt); |
|
2038 return found; |
|
2039 } |
|
2040 |
|
2041 TBool CScrRequestImpl::GetInstallerOrExecutionEnvSidsForComponentL(TComponentId aComponentId, RArray<TSecureId>& aSids) const |
|
2042 { |
|
2043 // Get the software type id for the component |
|
2044 TInt swTypeId = GetSoftwareTypeForComponentL(aComponentId); |
|
2045 // Retrieve the Sids for the type id |
|
2046 return GetSidsForSoftwareTypeIdL(swTypeId, aSids); |
|
2047 } |
|
2048 |
|
2049 TBool CScrRequestImpl::IsInstallerOrExecutionEnvSidL(TSecureId& aSid) const |
|
2050 { |
|
2051 _LIT(KSelectStatement, "SELECT SecureId FROM CustomAccessList WHERE SecureId=? AND AccessMode=?;"); |
|
2052 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectStatement); |
|
2053 stmt->BindIntL(1, aSid); |
|
2054 stmt->BindIntL(2, (TInt)ETransactionalSid); |
|
2055 TBool res = ETrue; |
|
2056 if(!stmt->ProcessNextRowL()) |
|
2057 { |
|
2058 DEBUG_PRINTF2(_L("%d is not an installer or execution environment SID"), TUint32(aSid)); |
|
2059 res = EFalse; |
|
2060 } |
|
2061 CleanupStack::PopAndDestroy(stmt); |
|
2062 return res; |
|
2063 } |
|
2064 |
|
2065 void CScrRequestImpl::GetPluginUidWithComponentIdL(const RMessage2& aMessage) const |
|
2066 { |
|
2067 DEBUG_PRINTF(_L8("Returning Plugin Uid With ComponentId.")); |
|
2068 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
2069 DEBUG_PRINTF2(_L8("Returning the plugin of component(%d)."), componentId); |
|
2070 |
|
2071 // Get the software type id for the component |
|
2072 TInt swTypeId = GetSoftwareTypeForComponentL(componentId); |
|
2073 |
|
2074 TInt uid (0); |
|
2075 TBool found = GetSifPluginUidIInternalL(swTypeId, uid); |
|
2076 __ASSERT_ALWAYS(found, User::Leave(KErrNotFound)); |
|
2077 |
|
2078 TPckg<TUint32> uidDes(uid); |
|
2079 aMessage.WriteL(1, uidDes); |
|
2080 } |
|
2081 |
|
2082 // This function returns whether the SID looked up has been found in the software types table. |
|
2083 TBool CScrRequestImpl::GetSidsForSoftwareTypeL(const HBufC* aSoftwareTypeName, RArray<TSecureId>& aSids) const |
|
2084 { |
|
2085 DEBUG_PRINTF2(_L("Returning SIDs for software type(%S)."), aSoftwareTypeName); |
|
2086 |
|
2087 TUint32 swTypeId = HashCaseSensitiveL(*aSoftwareTypeName); |
|
2088 return GetSidsForSoftwareTypeIdL(swTypeId, aSids); |
|
2089 } |
|
2090 |
|
2091 TBool CScrRequestImpl::CheckIfAppUidExistsL(const TUid aAppUid) const |
|
2092 { |
|
2093 DEBUG_PRINTF(_L8("Check if the given application UID exists.")); |
|
2094 TUid retrievedAppUid; |
|
2095 _LIT(KSelectColumn, "AppUid"); |
|
2096 _LIT(KTable, "AppRegistrationInfo"); |
|
2097 _LIT(KConditionColumn, "AppUid"); |
|
2098 if(GetIntforConditionL(KSelectColumn, KTable, KConditionColumn, aAppUid.iUid, (TInt&)retrievedAppUid.iUid)) |
|
2099 { |
|
2100 return ETrue; |
|
2101 } |
|
2102 return EFalse ; |
|
2103 } |
|
2104 |
|
2105 void CScrRequestImpl::SetLocaleForRegInfoForApplicationSubsessionContextL(const RMessage2& aMessage, CRegInfoForApplicationSubsessionContext *aSubsessionContext) |
|
2106 { |
|
2107 TLanguage appLocale= (TLanguage)aMessage.Int1(); |
|
2108 TUid appUid; |
|
2109 appUid.iUid=aMessage.Int0(); |
|
2110 if(!GetNearestAppLanguageL(appLocale,appUid, aSubsessionContext->iAppLanguageForCurrentLocale)) |
|
2111 { |
|
2112 if (KUnspecifiedLocale!=appLocale) |
|
2113 { |
|
2114 DEBUG_PRINTF2(_L8("Given Locale %d is not supported by application"),appLocale); |
|
2115 User::Leave(KErrNotFound); |
|
2116 } |
|
2117 } |
|
2118 } |
|
2119 |
|
2120 void CScrRequestImpl::GetServiceUidSizeL(const RMessage2& aMessage,TUid aAppUid, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
2121 { |
|
2122 TUid uid; |
|
2123 _LIT(KSelectServiceUidWithAppUid, "SELECT Uid FROM ServiceInfo WHERE AppUid =?;"); |
|
2124 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectServiceUidWithAppUid); |
|
2125 stmt->BindIntL(1, aAppUid.iUid); |
|
2126 aSubsessionContext->iServiceUidList.Close(); |
|
2127 while(stmt->ProcessNextRowL()) |
|
2128 { |
|
2129 uid.iUid = stmt->IntColumnL(0); |
|
2130 aSubsessionContext->iServiceUidList.Append(uid); |
|
2131 } |
|
2132 if(aSubsessionContext->iServiceUidList.Count() == 0) |
|
2133 { |
|
2134 DEBUG_PRINTF2(_L8("No service ids correspond to the given AppUid,%d"),aAppUid); |
|
2135 } |
|
2136 CleanupStack::PopAndDestroy(stmt); |
|
2137 WriteArraySizeL(aMessage, 1, aSubsessionContext->iServiceUidList); |
|
2138 } |
|
2139 |
|
2140 void CScrRequestImpl::GetServiceUidDataL(const RMessage2& aMessage, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
2141 { |
|
2142 WriteArrayDataL(aMessage, 0, aSubsessionContext->iServiceUidList); |
|
2143 aSubsessionContext->iServiceUidList.Close(); |
|
2144 } |
|
2145 |
|
2146 void CScrRequestImpl::GetApplicationLanguageL(const RMessage2& aMessage, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
2147 { |
|
2148 DEBUG_PRINTF(_L8("Returning the Application Language .")); |
|
2149 TPckg<TLanguage> applicationLanguage (aSubsessionContext->iAppLanguageForCurrentLocale); |
|
2150 aMessage.WriteL(0, applicationLanguage); |
|
2151 } |
|
2152 |
|
2153 void CScrRequestImpl::GetDefaultScreenNumberL(const RMessage2& aMessage,TUid aAppUid) const |
|
2154 { |
|
2155 DEBUG_PRINTF(_L8("Returning the default screen number.")); |
|
2156 |
|
2157 TInt screenNumber=0; |
|
2158 _LIT(KSelectColumn, "DefaultScreenNumber"); |
|
2159 _LIT(KTable, "AppRegistrationInfo"); |
|
2160 _LIT(KConditionColumn, "AppUid"); |
|
2161 |
|
2162 GetIntforConditionL(KSelectColumn(),KTable(),KConditionColumn(),aAppUid.iUid, screenNumber); |
|
2163 { |
|
2164 TPckg<TInt> screenNumberDes(screenNumber); |
|
2165 aMessage.WriteL(0, screenNumberDes); |
|
2166 } |
|
2167 } |
|
2168 |
|
2169 void CScrRequestImpl::GetNumberOfOwnDefinedIconsL(const RMessage2& aMessage,TUid aAppUid , CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
2170 { |
|
2171 DEBUG_PRINTF(_L8("Returning the no of own defined Icons count ")); |
|
2172 TInt numberOfIcons; |
|
2173 _LIT(KSelectNoOfIcones, "SELECT NumberOfIcons FROM CaptionAndIconInfo WHERE CaptionAndIconId IN (SELECT CaptionAndIconId FROM LocalizableAppInfo WHERE AppUid= ? AND Locale = ?);"); |
|
2174 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectNoOfIcones); |
|
2175 stmt->BindIntL(1, aAppUid.iUid); |
|
2176 stmt->BindIntL(2, aSubsessionContext->iAppLanguageForCurrentLocale); |
|
2177 if(stmt->ProcessNextRowL()) |
|
2178 { |
|
2179 numberOfIcons = stmt->IntColumnL(0); |
|
2180 TPckg<TInt> numberOfIconsDes(numberOfIcons); |
|
2181 aMessage.WriteL(0, numberOfIconsDes); |
|
2182 } |
|
2183 CleanupStack::PopAndDestroy(stmt); |
|
2184 } |
|
2185 |
|
2186 void CScrRequestImpl::GetAppForDataTypeAndServiceL(const RMessage2& aMessage) const |
|
2187 { |
|
2188 DEBUG_PRINTF(_L8("Returns the App Uid for a given Service Uid that handles the specified datatype with the highest priority.")); |
|
2189 HBufC *dataType = ReadDescLC(aMessage,0); |
|
2190 TUid inputServiceUid = TUid::Uid(aMessage.Int1()); |
|
2191 |
|
2192 _LIT(KSelectAppUidsForGivenUidAndDataType, "SELECT AppUid FROM (ServiceInfo JOIN DataType ON ServiceInfo.ServiceId = DataType.ServiceId) WHERE Uid=? AND Type=? ORDER BY Priority DESC;"); |
|
2193 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppUidsForGivenUidAndDataType); |
|
2194 stmt->BindIntL(1, inputServiceUid.iUid); |
|
2195 stmt->BindStrL(2, *dataType); |
|
2196 |
|
2197 if(stmt->ProcessNextRowL()) |
|
2198 { |
|
2199 TPckg<TInt> appUidDes(stmt->IntColumnL(0)); |
|
2200 aMessage.WriteL(2, appUidDes); |
|
2201 CleanupStack::PopAndDestroy(2, dataType); //stmt, dataType |
|
2202 } |
|
2203 else |
|
2204 { |
|
2205 DEBUG_PRINTF(_L("No AppUid for given datatype and Service Uid")); |
|
2206 CleanupStack::PopAndDestroy(2, dataType); //stmt, dataType |
|
2207 User::Leave(KErrNotFound); |
|
2208 } |
|
2209 } |
|
2210 |
|
2211 void CScrRequestImpl::GetAppForDataTypeL(const RMessage2& aMessage) const |
|
2212 { |
|
2213 DEBUG_PRINTF(_L8("Returning the app UID.")); |
|
2214 |
|
2215 TUid appUid = TUid::Null(); |
|
2216 HBufC *type = ReadDescLC(aMessage, 0); |
|
2217 TInt serviceId = GetServiceIdForDataTypeL(*type); |
|
2218 |
|
2219 if(serviceId == KErrNotFound) |
|
2220 { |
|
2221 DEBUG_PRINTF(_L("No Service Id for the given datatype")); |
|
2222 User::Leave(KErrNotFound); |
|
2223 } |
|
2224 |
|
2225 CleanupStack::PopAndDestroy(type); |
|
2226 if(!GetAppUidForServiceIdL(serviceId, appUid)) |
|
2227 { |
|
2228 DEBUG_PRINTF(_L("No AppUid for given datatype")); |
|
2229 } |
|
2230 TPckg<TUid> appUidDes(appUid); |
|
2231 aMessage.WriteL(1, appUidDes); |
|
2232 } |
|
2233 |
|
2234 TInt CScrRequestImpl::GetServiceIdForDataTypeL(const TDesC& aType) const |
|
2235 { |
|
2236 DEBUG_PRINTF(_L8("Returning ServiceId For DataType.")); |
|
2237 TInt serviceId = 0; |
|
2238 _LIT(KSelectAppForDataTypeAndService, "SELECT ServiceId FROM DataType WHERE Type=? ORDER BY Priority DESC;"); |
|
2239 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectAppForDataTypeAndService); |
|
2240 stmt->BindStrL(1, aType); |
|
2241 |
|
2242 if(!stmt->ProcessNextRowL()) |
|
2243 { |
|
2244 DEBUG_PRINTF(_L("No Service for given datatype")); |
|
2245 } |
|
2246 else |
|
2247 { |
|
2248 serviceId = stmt->IntColumnL(0); |
|
2249 } |
|
2250 CleanupStack::PopAndDestroy(stmt); |
|
2251 return serviceId; |
|
2252 } |
|
2253 |
|
2254 TBool CScrRequestImpl::GetAppUidForServiceIdL(const TInt ServiceId, TUid& aAppUid) const |
|
2255 { |
|
2256 DEBUG_PRINTF(_L8("Returning App Uid for ServiceId.")); |
|
2257 _LIT(KSelectColumn, "AppUid"); |
|
2258 _LIT(KTable, "ServiceInfo"); |
|
2259 _LIT(KConditionColumn, "ServiceId"); |
|
2260 if(GetIntforConditionL(KSelectColumn(),KTable(),KConditionColumn(),ServiceId, (TInt&)aAppUid.iUid)) |
|
2261 { |
|
2262 return ETrue; |
|
2263 } |
|
2264 else |
|
2265 { |
|
2266 DEBUG_PRINTF(_L("No AppUid for given datatype")); |
|
2267 return EFalse; |
|
2268 } |
|
2269 } |
|
2270 |
|
2271 void CScrRequestImpl::GetNearestAppLanguageForOpaqueDataL(TLanguage aRequiredLocale, TUid aAppUid, TUid aServiceUid, TLanguage& aFinalAppLocale) const |
|
2272 { |
|
2273 DEBUG_PRINTF(_L8("Returning Nearest App Language For OpaqueData.")); |
|
2274 // Set the default language |
|
2275 aFinalAppLocale = TLanguage(0); |
|
2276 |
|
2277 if (aRequiredLocale == KUnspecifiedLocale) |
|
2278 { |
|
2279 aRequiredLocale = User::Language(); |
|
2280 } |
|
2281 |
|
2282 // Get the list of locales supported by the application |
|
2283 RArray<TInt> appLocales; |
|
2284 CleanupClosePushL(appLocales); |
|
2285 GetLocalesForAppIdL(appLocales, aAppUid); |
|
2286 |
|
2287 // Return the default language if the app doesn't have localized info |
|
2288 if (!appLocales.Count()) |
|
2289 { |
|
2290 CleanupStack::PopAndDestroy(&appLocales); |
|
2291 return; |
|
2292 } |
|
2293 |
|
2294 // Check if current language is supported by application |
|
2295 if (KErrNotFound != appLocales.Find((TInt)aRequiredLocale)) |
|
2296 { |
|
2297 aFinalAppLocale = aRequiredLocale; |
|
2298 } |
|
2299 else // Get the nearest languages corresponding to the required language |
|
2300 { |
|
2301 TLanguagePath equivalentLanguages; |
|
2302 BaflUtils::GetEquivalentLanguageList(aRequiredLocale, equivalentLanguages); |
|
2303 |
|
2304 // Identify the application locale corresponding to the nearest required locale |
|
2305 TInt index = 0; |
|
2306 while (1) |
|
2307 { |
|
2308 if (equivalentLanguages[index] == ELangNone) |
|
2309 { |
|
2310 break; |
|
2311 } |
|
2312 |
|
2313 if (appLocales.FindInOrder((TInt)equivalentLanguages[index]) != KErrNotFound) |
|
2314 { |
|
2315 aFinalAppLocale = equivalentLanguages[index]; |
|
2316 break; |
|
2317 } |
|
2318 |
|
2319 index++; |
|
2320 } |
|
2321 } |
|
2322 |
|
2323 // Check the opaque data exists in the selected language |
|
2324 if (aFinalAppLocale != TLanguage(0)) |
|
2325 { |
|
2326 _LIT(KOpaqueData, "SELECT StrValue FROM AppProperties where Name = ? AND ServiceUid = ? AND AppUid = ? AND Locale = ?"); |
|
2327 CStatement *stmt = iDbHandle->PrepareStatementLC(KOpaqueData); |
|
2328 stmt->BindStrL(1, _L("OpaqueData")); |
|
2329 stmt->BindIntL(2, aServiceUid.iUid); |
|
2330 stmt->BindIntL(3, aAppUid.iUid); |
|
2331 stmt->BindIntL(4, (TInt)aFinalAppLocale); |
|
2332 |
|
2333 if (!stmt->ProcessNextRowL()) |
|
2334 { |
|
2335 // No opaque data for given locale, hence set to the default locale |
|
2336 aFinalAppLocale = TLanguage(0); |
|
2337 } |
|
2338 CleanupStack::PopAndDestroy(stmt); |
|
2339 } |
|
2340 |
|
2341 CleanupStack::PopAndDestroy(&appLocales); |
|
2342 } |
|
2343 |
|
2344 TBool CScrRequestImpl::GetNearestAppLanguageL(TLanguage aRequiredLocale, TUid aAppUid, TLanguage& aFinalAppLocale) const |
|
2345 { |
|
2346 DEBUG_PRINTF(_L8("Returning Nearest App Language.")); |
|
2347 TLanguagePath equivalentLanguages; |
|
2348 TInt index = 0; |
|
2349 RArray<TInt> appLocales; |
|
2350 TBool isLocalizedInfoPresent = EFalse; |
|
2351 aFinalAppLocale = KUnspecifiedLocale; |
|
2352 |
|
2353 //If required language is not specified, take the current user language. |
|
2354 if (aRequiredLocale == KUnspecifiedLocale) |
|
2355 { |
|
2356 aRequiredLocale = User::Language(); |
|
2357 } |
|
2358 |
|
2359 //Get the app language list. |
|
2360 CleanupClosePushL(appLocales); |
|
2361 GetLocalesForAppIdL(appLocales,aAppUid); |
|
2362 |
|
2363 //Check if current language is supported by application |
|
2364 if (KErrNotFound != appLocales.Find((TInt)aRequiredLocale)) |
|
2365 { |
|
2366 aFinalAppLocale = aRequiredLocale; |
|
2367 isLocalizedInfoPresent = ETrue; |
|
2368 CleanupStack::PopAndDestroy(&appLocales); |
|
2369 return isLocalizedInfoPresent; |
|
2370 } |
|
2371 |
|
2372 //Get the nearest languages corresponding to the required language. |
|
2373 BaflUtils::GetEquivalentLanguageList(aRequiredLocale, equivalentLanguages); |
|
2374 |
|
2375 //Identify the app language corresponding to the nearest required language. |
|
2376 if(0 != appLocales.Count()) |
|
2377 { |
|
2378 while(1) |
|
2379 { |
|
2380 if(equivalentLanguages[index] == ELangNone) |
|
2381 { |
|
2382 break; |
|
2383 } |
|
2384 |
|
2385 if(appLocales.FindInOrder((TInt)equivalentLanguages[index]) != KErrNotFound) |
|
2386 { |
|
2387 aFinalAppLocale = equivalentLanguages[index]; |
|
2388 isLocalizedInfoPresent = ETrue; |
|
2389 break; |
|
2390 } |
|
2391 |
|
2392 index++; |
|
2393 } |
|
2394 |
|
2395 // If a matching language is not found in the list of equivalent languages, |
|
2396 // we check if a default locale (KNonLocalized) is present. |
|
2397 if(!isLocalizedInfoPresent && appLocales[0] == (TInt)KNonLocalized) |
|
2398 { |
|
2399 isLocalizedInfoPresent = ETrue; |
|
2400 aFinalAppLocale = KNonLocalized; |
|
2401 } |
|
2402 } |
|
2403 |
|
2404 CleanupStack::PopAndDestroy(&appLocales); |
|
2405 return isLocalizedInfoPresent; |
|
2406 } |
|
2407 |
|
2408 TBool CScrRequestImpl::GetIntforConditionL(const TDesC& aSelectColumn,const TDesC& aTableInfo,const TDesC& aConditionColumn,TInt aConditionValue,TInt& aRetrievedValue) const |
|
2409 { |
|
2410 TBool isIntValFound = 0; |
|
2411 _LIT(KSelectDependencies, "SELECT %S FROM %S WHERE %S=?;"); |
|
2412 TInt formattedLen = aSelectColumn.Length() + aTableInfo.Length()+ aConditionColumn.Length(); |
|
2413 HBufC *stmtStr = FormatStatementLC(KSelectDependencies(), formattedLen, &aSelectColumn, &aTableInfo,&aConditionColumn); |
|
2414 |
|
2415 CStatement* stmt = iDbHandle->PrepareStatementLC(*stmtStr); |
|
2416 stmt->BindIntL(1, aConditionValue); |
|
2417 if(!stmt->ProcessNextRowL()) |
|
2418 { |
|
2419 DEBUG_PRINTF3(_L("%S with value %d not found!"), &aSelectColumn, aConditionValue); |
|
2420 } |
|
2421 else |
|
2422 { |
|
2423 aRetrievedValue = stmt->IntColumnL(0); |
|
2424 isIntValFound = 1; |
|
2425 } |
|
2426 CleanupStack::PopAndDestroy(2,stmtStr); |
|
2427 |
|
2428 return isIntValFound; |
|
2429 } |
|
2430 |
|
2431 void IntersectSortedArraysL(RArray<TComponentId>& aLhs, RArray<TComponentId> aRhs) |
|
2432 { |
|
2433 RArray<TComponentId> tmp; |
|
2434 CleanupClosePushL(tmp); |
|
2435 TInt idxLhs(0); |
|
2436 TInt idxRhs(0); |
|
2437 TInt countLhs = aLhs.Count(); |
|
2438 TInt countRhs = aRhs.Count(); |
|
2439 |
|
2440 while(idxLhs < countLhs && idxRhs < countRhs) |
|
2441 { |
|
2442 if(aLhs[idxLhs] < aRhs[idxRhs]) |
|
2443 ++idxLhs; |
|
2444 else if(aLhs[idxLhs] > aRhs[idxRhs]) |
|
2445 ++idxRhs; |
|
2446 else |
|
2447 { |
|
2448 tmp.AppendL(aRhs[idxRhs]); |
|
2449 ++idxRhs; |
|
2450 ++idxLhs; |
|
2451 } |
|
2452 } |
|
2453 |
|
2454 aLhs.Reset(); |
|
2455 CopyFixedLengthArrayL(aLhs, tmp); |
|
2456 CleanupStack::PopAndDestroy(&tmp); |
|
2457 } |
|
2458 |
|
2459 void CScrRequestImpl::GetOperatorStringL(CComponentFilter::TDbOperator aOperator, HBufC*& aOperatorString) const |
|
2460 { |
|
2461 _LIT(KEqualOperator, "="); |
|
2462 _LIT(KLikeOperator, "LIKE"); |
|
2463 |
|
2464 switch(aOperator) |
|
2465 { |
|
2466 case CComponentFilter::EEqual: |
|
2467 aOperatorString = KEqualOperator().AllocL(); |
|
2468 break; |
|
2469 |
|
2470 case CComponentFilter::ELike: |
|
2471 aOperatorString = KLikeOperator().AllocL(); |
|
2472 break; |
|
2473 |
|
2474 default: |
|
2475 User::Leave(KErrArgument); |
|
2476 |
|
2477 } |
|
2478 } |
|
2479 |
|
2480 void CScrRequestImpl::GetComponentIdsHavingThePropertiesL(RArray<TComponentId>& aComponentIds, RPointerArray<CPropertyEntry>& aProperties, |
|
2481 RArray<CComponentFilter::TPropertyOperator>& aPropertyOperatorList, TBool aDoIntersect) const |
|
2482 { |
|
2483 // GROUP BY is added at the end to avoid fetching twice components which have the same localizable values for different locales |
|
2484 |
|
2485 _LIT(KFindComponentsFromProperties, "SELECT ComponentId FROM ComponentProperties WHERE NAME %S ? AND %S GROUP BY ComponentId;"); |
|
2486 |
|
2487 _LIT(KPropertyIntValue, "IntValue %S ?"); |
|
2488 _LIT(KPropertyStrValue, "StrValue %S ?"); |
|
2489 _LIT(KPropertyLocalizedValue, "StrValue %S ? AND Locale = ?"); |
|
2490 |
|
2491 TInt propCount = aProperties.Count(); |
|
2492 |
|
2493 RArray<TComponentId> propCompIds; |
|
2494 CleanupClosePushL(propCompIds); |
|
2495 |
|
2496 for(TInt i=0; i<propCount; ++i) |
|
2497 { |
|
2498 //Retrieve the operators to be used to form this query. |
|
2499 CComponentFilter::TPropertyOperator propOperator = aPropertyOperatorList[i]; |
|
2500 |
|
2501 // Get the name operator. |
|
2502 HBufC* nameOperator(0); |
|
2503 GetOperatorStringL(aPropertyOperatorList[i].NameOperator(), nameOperator); |
|
2504 CleanupStack::PushL(nameOperator); |
|
2505 |
|
2506 // Get the value operator. |
|
2507 HBufC* valueOperator(0); |
|
2508 GetOperatorStringL(aPropertyOperatorList[i].ValueOperator(), valueOperator); |
|
2509 CleanupStack::PushL(valueOperator); |
|
2510 |
|
2511 // Create the value string based on the property type. |
|
2512 HBufC* valueString(0); |
|
2513 switch(aProperties[i]->PropertyType()) |
|
2514 { |
|
2515 case CPropertyEntry::EIntProperty: |
|
2516 { |
|
2517 valueString = FormatStatementLC(KPropertyIntValue, valueOperator->Length(), valueOperator); |
|
2518 } |
|
2519 |
|
2520 break; |
|
2521 |
|
2522 case CPropertyEntry::EBinaryProperty: |
|
2523 { |
|
2524 valueString = FormatStatementLC(KPropertyStrValue, valueOperator->Length(), valueOperator); |
|
2525 } |
|
2526 |
|
2527 break; |
|
2528 case CPropertyEntry::ELocalizedProperty: |
|
2529 { |
|
2530 CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aProperties[i]); |
|
2531 if (localizedProp->LocaleL() == KUnspecifiedLocale) // If the locale was not specified, then we match across all locales |
|
2532 { |
|
2533 valueString = FormatStatementLC(KPropertyStrValue, valueOperator->Length(), valueOperator); |
|
2534 } |
|
2535 else |
|
2536 { |
|
2537 valueString = FormatStatementLC(KPropertyLocalizedValue, valueOperator->Length(), valueOperator); |
|
2538 } |
|
2539 } |
|
2540 break; |
|
2541 default: |
|
2542 DEBUG_PRINTF(_L8("The property type couldn't be recognized.")); |
|
2543 User::Leave(KErrAbort); |
|
2544 } |
|
2545 |
|
2546 // Prepare full statement using the name operator and the value string. |
|
2547 HBufC *statementStr = FormatStatementLC(KFindComponentsFromProperties, nameOperator->Length()+ valueString->Length(), |
|
2548 nameOperator, valueString); |
|
2549 |
|
2550 // Create Sql statement. |
|
2551 CStatement *stmt = iDbHandle->PrepareStatementLC(*statementStr); |
|
2552 stmt->BindStrL(1, aProperties[i]->PropertyName()); |
|
2553 |
|
2554 switch(aProperties[i]->PropertyType()) |
|
2555 { |
|
2556 case CPropertyEntry::EIntProperty: |
|
2557 { |
|
2558 CIntPropertyEntry *intProp = static_cast<CIntPropertyEntry *>(aProperties[i]); |
|
2559 stmt->BindInt64L(2, intProp->Int64Value()); |
|
2560 break; |
|
2561 } |
|
2562 case CPropertyEntry::EBinaryProperty: |
|
2563 { |
|
2564 CBinaryPropertyEntry *binaryProp = static_cast<CBinaryPropertyEntry *>(aProperties[i]); |
|
2565 stmt->BindBinaryL(2, binaryProp->BinaryValue()); |
|
2566 break; |
|
2567 } |
|
2568 case CPropertyEntry::ELocalizedProperty: |
|
2569 { |
|
2570 CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aProperties[i]); |
|
2571 stmt->BindStrL(2, localizedProp->StrValue()); |
|
2572 if (localizedProp->LocaleL() != KUnspecifiedLocale) |
|
2573 stmt->BindIntL(3, localizedProp->LocaleL()); |
|
2574 break; |
|
2575 } |
|
2576 default: |
|
2577 DEBUG_PRINTF(_L8("The property type couldn't be recognized.")); |
|
2578 User::Leave(KErrAbort); |
|
2579 } |
|
2580 |
|
2581 while(stmt->ProcessNextRowL()) |
|
2582 { |
|
2583 User::LeaveIfError(propCompIds.InsertInOrder(stmt->IntColumnL(0))); |
|
2584 } |
|
2585 |
|
2586 CleanupStack::PopAndDestroy(5, nameOperator); |
|
2587 |
|
2588 if (aDoIntersect) |
|
2589 { |
|
2590 IntersectSortedArraysL(aComponentIds, propCompIds); |
|
2591 } |
|
2592 else |
|
2593 { |
|
2594 CopyFixedLengthArrayL(aComponentIds, propCompIds); |
|
2595 aDoIntersect = ETrue; // If many properties are present in the filter, we need to intersect the component Ids on further iterations |
|
2596 } |
|
2597 |
|
2598 propCompIds.Reset(); |
|
2599 } |
|
2600 CleanupStack::PopAndDestroy(&propCompIds); |
|
2601 } |
|
2602 |
|
2603 |
|
2604 void ReallocStatementIfNeededL(RBuf& aStatementStr, TInt aAddedLength) |
|
2605 { |
|
2606 TInt freeSpace = aStatementStr.MaxLength() - aStatementStr.Length(); |
|
2607 TInt extraSpace = aAddedLength - freeSpace; |
|
2608 if (extraSpace > 0) |
|
2609 { |
|
2610 aStatementStr.ReAllocL(aStatementStr.MaxLength() + extraSpace); |
|
2611 } |
|
2612 } |
|
2613 |
|
2614 void AppendConditionToStatementL(RBuf& aStatementStr, const TDesC& aConditionStr, TBool& aIsFirstCondition) |
|
2615 { |
|
2616 TInt addedLength = 2 + aConditionStr.Length(); // 2 chars used by spaces |
|
2617 |
|
2618 _LIT(KConditionAnd, " AND"); |
|
2619 _LIT(KConditionWhere, " WHERE"); |
|
2620 |
|
2621 if(aIsFirstCondition) |
|
2622 { |
|
2623 addedLength += KConditionWhere().Length(); |
|
2624 } |
|
2625 else |
|
2626 { |
|
2627 addedLength += KConditionAnd().Length(); |
|
2628 } |
|
2629 |
|
2630 ReallocStatementIfNeededL(aStatementStr, addedLength); |
|
2631 |
|
2632 if(aIsFirstCondition) |
|
2633 { |
|
2634 aStatementStr.Append(KConditionWhere); |
|
2635 aIsFirstCondition = EFalse; |
|
2636 } |
|
2637 else |
|
2638 { |
|
2639 aStatementStr.Append(KConditionAnd); |
|
2640 } |
|
2641 aStatementStr.Append(aConditionStr); |
|
2642 } |
|
2643 |
|
2644 CStatement* CScrRequestImpl::CreateStatementObjectForComponentLocalizablesLC(const TDesC& aName, const TDesC& aVendor, TUint aSetFlag, TComponentId aComponentId /* = 0*/ ) const |
|
2645 { |
|
2646 _LIT(KSelectComponentLocalizables, "SELECT ComponentId,Name,Vendor FROM ComponentLocalizables"); |
|
2647 RBuf stmtStr; |
|
2648 stmtStr.CreateL(100); // 100 should be enough for this statement |
|
2649 stmtStr.CleanupClosePushL(); |
|
2650 stmtStr.Copy(KSelectComponentLocalizables); |
|
2651 TBool isFirstCondition = ETrue; |
|
2652 |
|
2653 if(aComponentId > 0) |
|
2654 { |
|
2655 _LIT(KConditionComponentId, " ComponentId=?"); |
|
2656 AppendConditionToStatementL(stmtStr, KConditionComponentId, isFirstCondition); |
|
2657 } |
|
2658 |
|
2659 if (aSetFlag & CComponentFilter::EName) |
|
2660 { |
|
2661 _LIT(KConditionName, " Name=?"); |
|
2662 AppendConditionToStatementL(stmtStr, KConditionName, isFirstCondition); |
|
2663 } |
|
2664 |
|
2665 if (aSetFlag & CComponentFilter::EVendor) |
|
2666 { |
|
2667 _LIT(KConditionVendor, " Vendor=?"); |
|
2668 AppendConditionToStatementL(stmtStr, KConditionVendor, isFirstCondition); |
|
2669 } |
|
2670 // Take care not to return the same component id twice in case we have the same name or vendor for two different locales |
|
2671 _LIT(KComponentIdGroupBy, " GROUP BY ComponentId;"); |
|
2672 ReallocStatementIfNeededL(stmtStr, KComponentIdGroupBy().Length() + 1); // one space for the NULL char |
|
2673 stmtStr.Append(KComponentIdGroupBy()); |
|
2674 // SQLite requires the statement string to end with NULL char. |
|
2675 stmtStr.Append('\0'); |
|
2676 |
|
2677 CStatement *stmt = iDbHandle->PrepareStatementLC(stmtStr); |
|
2678 |
|
2679 TInt bindIdx = 1; |
|
2680 if(aComponentId > 0) |
|
2681 { |
|
2682 stmt->BindIntL(bindIdx++, aComponentId); |
|
2683 } |
|
2684 if (aSetFlag & CComponentFilter::EName) |
|
2685 { |
|
2686 stmt->BindStrL(bindIdx++, aName); |
|
2687 } |
|
2688 if (aSetFlag & CComponentFilter::EVendor) |
|
2689 { |
|
2690 stmt->BindStrL(bindIdx, aVendor); |
|
2691 } |
|
2692 CleanupStack::Pop(stmt); |
|
2693 CleanupStack::PopAndDestroy(&stmtStr); |
|
2694 CleanupStack::PushL(stmt); |
|
2695 return stmt; |
|
2696 } |
|
2697 |
|
2698 void CScrRequestImpl::GetComponentsHavingNameVendorL(RArray<TComponentId>& aComponentIds, const TDesC& aName, const TDesC& aVendor, TUint16 aSetFlag, TBool aDoIntersect) const |
|
2699 { |
|
2700 CStatement *stmt = CreateStatementObjectForComponentLocalizablesLC(aName, aVendor, aSetFlag); |
|
2701 |
|
2702 RArray<TComponentId> foundCompIds; |
|
2703 CleanupClosePushL(foundCompIds); |
|
2704 |
|
2705 while(stmt->ProcessNextRowL()) |
|
2706 { |
|
2707 User::LeaveIfError(foundCompIds.InsertInOrder(stmt->IntColumnL(0))); |
|
2708 } |
|
2709 |
|
2710 if (aDoIntersect) |
|
2711 IntersectSortedArraysL(aComponentIds, foundCompIds); |
|
2712 else |
|
2713 CopyFixedLengthArrayL(aComponentIds, foundCompIds); |
|
2714 |
|
2715 CleanupStack::PopAndDestroy(2, stmt); // stmt, foundCompIds |
|
2716 } |
|
2717 |
|
2718 CComponentFilter* CScrRequestImpl::ReadComponentFilterL(const RMessage2& aMessage) const |
|
2719 { |
|
2720 CComponentFilter *filter = ReadObjectFromMessageLC<CComponentFilter>(aMessage, 0); |
|
2721 CleanupStack::Pop(filter); |
|
2722 return filter; |
|
2723 } |
|
2724 |
|
2725 void AppendFilterConditionToStatementL(TUint16 aSetFlag, TUint16 aConditionFlag, RBuf& aStatementStr, const TDesC& aConditionStr, TBool& aIsFirstCondition) |
|
2726 { |
|
2727 if(aSetFlag & aConditionFlag) |
|
2728 { |
|
2729 AppendConditionToStatementL(aStatementStr, aConditionStr, aIsFirstCondition); |
|
2730 } |
|
2731 } |
|
2732 |
|
2733 void BindIntegerFilterToStatementL(CStatement& aStatement, TUint16 aSetFlag, TUint16 aConditionFlag, TInt aValue, TInt& aStmtIdx) |
|
2734 { |
|
2735 if(aSetFlag & aConditionFlag) |
|
2736 { |
|
2737 aStatement.BindIntL(aStmtIdx++, aValue); |
|
2738 } |
|
2739 } |
|
2740 |
|
2741 CStatement* CScrRequestImpl::OpenComponentViewL(CComponentFilter& aFilter, RArray<TComponentId>& aComponentFilterSuperset, TBool& aFilterSupersetInUse) const |
|
2742 { |
|
2743 DEBUG_PRINTF(_L8("Opening Component View.")); |
|
2744 aComponentFilterSuperset.Reset(); |
|
2745 aFilterSupersetInUse = EFalse; |
|
2746 |
|
2747 TBool doIntersect = EFalse; // We should intersect component ids iff one of the previous filters on component ids was invoked |
|
2748 if(aFilter.iSetFlag & CComponentFilter::EFile) |
|
2749 { |
|
2750 GetFileComponentsL(*aFilter.iFile, aComponentFilterSuperset); |
|
2751 // The component Ids which own the given file is copied into componentIds array. |
|
2752 doIntersect = ETrue; |
|
2753 aFilterSupersetInUse = ETrue; |
|
2754 } |
|
2755 |
|
2756 if(aFilter.iSetFlag & CComponentFilter::EProperty) |
|
2757 { |
|
2758 GetComponentIdsHavingThePropertiesL(aComponentFilterSuperset, aFilter.iPropertyList, aFilter.iPropertyOperatorList, doIntersect); |
|
2759 // Inside the function, componentIds array is intersected with the components Ids which have the given properties. |
|
2760 doIntersect = ETrue; |
|
2761 aFilterSupersetInUse = ETrue; |
|
2762 } |
|
2763 |
|
2764 if(aFilter.iSetFlag & (CComponentFilter::EName | CComponentFilter::EVendor)) |
|
2765 { |
|
2766 GetComponentsHavingNameVendorL(aComponentFilterSuperset, *aFilter.iName, *aFilter.iVendor, aFilter.iSetFlag, doIntersect); |
|
2767 // Inside the function, componentIds array is intersected with the components Ids which have the given name/vendor. |
|
2768 aFilterSupersetInUse = ETrue; |
|
2769 } |
|
2770 |
|
2771 _LIT(KSelectComponents, "SELECT ComponentId,SoftwareTypeId,SoftwareTypeName,Removable,Size,ScomoState,DRMProtected,Hidden,KnownRevoked,OriginVerified,GlobalId,InstalledDrives,Version,InstallTime FROM Components"); |
|
2772 |
|
2773 RBuf statementStr; |
|
2774 statementStr.CreateL(KSelectComponents().Length()+ 50); // A reasonable starting buffer length |
|
2775 statementStr.CleanupClosePushL(); |
|
2776 statementStr.Copy(KSelectComponents); |
|
2777 |
|
2778 TBool isFirstCondition = ETrue; |
|
2779 |
|
2780 _LIT(KConditionSoftwareType, " SoftwareTypeId=?"); // as only unique sw type name can be defined in the filter. |
|
2781 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::ESoftwareType, statementStr, KConditionSoftwareType, isFirstCondition); |
|
2782 |
|
2783 _LIT(KConditionRemovable, " Removable=?"); |
|
2784 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::ERemovable, statementStr, KConditionRemovable, isFirstCondition); |
|
2785 |
|
2786 _LIT(KConditionScomoState, " ScomoState=?"); |
|
2787 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EScomoState, statementStr, KConditionScomoState, isFirstCondition); |
|
2788 |
|
2789 _LIT(KConditionInstalledDrives, " InstalledDrives&?"); // & -> bitwise AND operator |
|
2790 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EInstalledDrive, statementStr, KConditionInstalledDrives, isFirstCondition); |
|
2791 |
|
2792 _LIT(KConditionDrmProtected, " DRMProtected=?"); |
|
2793 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EDrmProtected, statementStr, KConditionDrmProtected, isFirstCondition); |
|
2794 |
|
2795 _LIT(KConditionHidden, " Hidden=?"); |
|
2796 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EHidden, statementStr, KConditionHidden, isFirstCondition); |
|
2797 |
|
2798 _LIT(KConditionKnownRevoked, " KnownRevoked=?"); |
|
2799 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EKnownRevoked, statementStr, KConditionKnownRevoked, isFirstCondition); |
|
2800 |
|
2801 _LIT(KConditionOriginVerified, " OriginVerified=?"); |
|
2802 AppendFilterConditionToStatementL(aFilter.iSetFlag, CComponentFilter::EOriginVerified, statementStr, KConditionOriginVerified, isFirstCondition); |
|
2803 |
|
2804 statementStr.Append(';'); |
|
2805 // SQLite requires the statement string to end with NULL char. |
|
2806 statementStr.Append('\0'); |
|
2807 |
|
2808 CStatement *stmt = iDbHandle->PrepareStatementLC(statementStr); |
|
2809 TInt stmtIdx = 1; |
|
2810 |
|
2811 if(aFilter.iSetFlag & CComponentFilter::ESoftwareType) |
|
2812 { |
|
2813 TUint32 swTypeId = HashCaseSensitiveL(*aFilter.iSwType); |
|
2814 stmt->BindIntL(stmtIdx++, swTypeId); |
|
2815 } |
|
2816 |
|
2817 if(aFilter.iSetFlag & CComponentFilter::EInstalledDrive) |
|
2818 { |
|
2819 if (aFilter.iInstalledDrives.Length() != KMaxDrives) |
|
2820 { |
|
2821 DEBUG_PRINTF2(_L("Incorrect size of drive list supplied in filter, the string supplied was %S"), &aFilter.iInstalledDrives); |
|
2822 User::Leave(KErrArgument); |
|
2823 } |
|
2824 TInt installedDrivesBitmask = InstalledDrivesToBitmaskL(aFilter.iInstalledDrives); |
|
2825 stmt->BindIntL(stmtIdx++, installedDrivesBitmask); |
|
2826 } |
|
2827 |
|
2828 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::ERemovable, aFilter.iRemovable, stmtIdx); |
|
2829 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::EScomoState, aFilter.iScomoState, stmtIdx); |
|
2830 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::EDrmProtected, aFilter.iDrmProtected, stmtIdx); |
|
2831 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::EHidden, aFilter.iHidden, stmtIdx); |
|
2832 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::EKnownRevoked, aFilter.iKnownRevoked, stmtIdx); |
|
2833 BindIntegerFilterToStatementL(*stmt, aFilter.iSetFlag, CComponentFilter::EOriginVerified, aFilter.iOriginVerified, stmtIdx); |
|
2834 |
|
2835 CleanupStack::Pop(stmt); |
|
2836 CleanupStack::PopAndDestroy(&statementStr); |
|
2837 return stmt; |
|
2838 } |
|
2839 |
|
2840 void CScrRequestImpl::AddComponentEntryLocalizablesL(TComponentId aComponentId, CComponentEntry& aEntry, TLanguage aLocale, const CComponentFilter& aFilter) const |
|
2841 { |
|
2842 DEBUG_PRINTF(_L8("Adding Component Entry Localizables.")); |
|
2843 if(aFilter.iSetFlag & (CComponentFilter::EName | CComponentFilter::EVendor)) |
|
2844 { // If a name or vendor is specified in the filter, the locale is ignored |
|
2845 // and the provided names are retrieved from the ComponentLocalizables table. |
|
2846 CStatement *stmt = CreateStatementObjectForComponentLocalizablesLC(*aFilter.iName, *aFilter.iVendor, aFilter.iSetFlag, aComponentId); |
|
2847 TBool res = stmt->ProcessNextRowL(); |
|
2848 // If the name and the vendor are not found, leave with KErrNotFound. |
|
2849 __ASSERT_ALWAYS(res, User::Leave(KErrNotFound)); |
|
2850 DeleteObjectZ(aEntry.iName); |
|
2851 aEntry.iName = stmt->StrColumnL(1).AllocL(); // Ownership is transferred to the entry object |
|
2852 DeleteObjectZ(aEntry.iVendor); |
|
2853 aEntry.iVendor = stmt->StrColumnL(2).AllocL(); // Ownership is transferred to the entry object |
|
2854 CleanupStack::PopAndDestroy(stmt); |
|
2855 } |
|
2856 else |
|
2857 {// if name and/or vendor are not defined in the filter, try to find them by using the nearest language algorithm. |
|
2858 AddComponentEntryLocalizablesL(aComponentId, aEntry, aLocale); |
|
2859 } |
|
2860 } |
|
2861 |
|
2862 |
|
2863 TBool CScrRequestImpl::IsSoftwareTypeExistingL(TInt aSoftwareTypeId) const |
|
2864 { |
|
2865 DEBUG_PRINTF(_L8("verify Software Type Exists.")); |
|
2866 TBool result = EFalse; |
|
2867 _LIT(KComponentSoftwareType, "SELECT SoftwareTypeId FROM SoftwareTypes WHERE SoftwareTypeId=?;"); |
|
2868 |
|
2869 CStatement *stmt = iDbHandle->PrepareStatementLC(KComponentSoftwareType); |
|
2870 stmt->BindIntL(1, aSoftwareTypeId); |
|
2871 |
|
2872 if(stmt->ProcessNextRowL()) |
|
2873 { // The software type exists. |
|
2874 result = ETrue; |
|
2875 } |
|
2876 CleanupStack::PopAndDestroy(stmt); |
|
2877 return result; |
|
2878 } |
|
2879 |
|
2880 void CScrRequestImpl::SubsessionAddLocalizableSoftwareTypeNameL(CStatement& aStmt, CComponentEntry& aEntry, TLanguage aLocale, CCompViewSubsessionContext* aSubsessionContext) const |
|
2881 { |
|
2882 TInt softwareTypeId = aStmt.IntColumnL(1); |
|
2883 // Check if we've already cached this software type name - caching is important here as fetching the same software type name for all components in the sub-session is expensive |
|
2884 if (softwareTypeId == aSubsessionContext->iLastSoftwareTypeId) |
|
2885 { |
|
2886 DeleteObjectZ(aEntry.iSwType); |
|
2887 aEntry.iSwType = aSubsessionContext->iLastSoftwareTypeName->AllocL(); |
|
2888 } |
|
2889 else |
|
2890 { |
|
2891 AddSoftwareTypeNameToComponentEntryL(aStmt, aEntry, aLocale); |
|
2892 // Save the last results - if the next component in the filter has the same software type id, we won't have to recalculate the name |
|
2893 aSubsessionContext->iLastSoftwareTypeId = softwareTypeId; |
|
2894 DeleteObjectZ(aSubsessionContext->iLastSoftwareTypeName); |
|
2895 aSubsessionContext->iLastSoftwareTypeName = aEntry.iSwType->AllocL(); |
|
2896 } |
|
2897 } |
|
2898 |
|
2899 CComponentEntry* CScrRequestImpl::GetNextComponentEntryL(CStatement& aStmt, CComponentFilter& aFilter, TLanguage aLocale, CCompViewSubsessionContext* aSubsessionContext) const |
|
2900 { |
|
2901 // Since the query does not account for filter's name, vendor, property and file conditions, |
|
2902 // we intersect the resut of the query with components which answer these conditions, i.e. iComponentFilterSuperset |
|
2903 while (1) |
|
2904 { |
|
2905 if(!aStmt.ProcessNextRowL()) |
|
2906 { |
|
2907 return NULL; |
|
2908 } |
|
2909 TComponentId queryComponentId = aStmt.IntColumnL(0); |
|
2910 if (!aSubsessionContext->iFilterSupersetInUse || aSubsessionContext->iComponentFilterSuperset.FindInOrder(queryComponentId) >= 0) |
|
2911 break; // The component id exists in both parts of the filter - return it. |
|
2912 } |
|
2913 |
|
2914 CComponentEntry *component = CreateComponentEntryFromStatementHandleL(aStmt); |
|
2915 CleanupStack::PushL(component); |
|
2916 AddComponentEntryLocalizablesL(component->ComponentId(), *component, aLocale, aFilter); |
|
2917 SubsessionAddLocalizableSoftwareTypeNameL(aStmt, *component, aLocale, aSubsessionContext); |
|
2918 CleanupStack::Pop(component); |
|
2919 return component; |
|
2920 } |
|
2921 |
|
2922 void CScrRequestImpl::NextComponentSizeL(const RMessage2& aMessage, CStatement* aStmt, CComponentFilter* aFilter, CComponentEntry*& aEntry, CCompViewSubsessionContext* aSubsessionContext) const |
|
2923 { |
|
2924 __ASSERT_ALWAYS(aStmt && aFilter, PanicClient(aMessage, KScrIllegalCallSequence)); |
|
2925 |
|
2926 TLanguage locale = TLanguage(aMessage.Int0()); |
|
2927 |
|
2928 DeleteObjectZ(aEntry); |
|
2929 |
|
2930 TInt err(0); |
|
2931 do { |
|
2932 TRAP(err, aEntry = GetNextComponentEntryL(*aStmt, *aFilter, locale, aSubsessionContext)); |
|
2933 }while(err == KErrNotFound); |
|
2934 |
|
2935 if(KErrNone != err) |
|
2936 { |
|
2937 User::Leave(err); |
|
2938 } |
|
2939 |
|
2940 TInt sizeSlot = 1; |
|
2941 if(!aEntry) |
|
2942 { |
|
2943 DEBUG_PRINTF(_L8("Reached the end of the view.")); |
|
2944 WriteIntValueL(aMessage, sizeSlot, 0); |
|
2945 return; |
|
2946 } |
|
2947 WriteObjectSizeL(aMessage, sizeSlot, aEntry); |
|
2948 } |
|
2949 |
|
2950 void CScrRequestImpl::NextComponentDataL(const RMessage2& aMessage, CComponentEntry*& aEntry) const |
|
2951 { |
|
2952 DEBUG_PRINTF(_L8("Returning the component entry data.")); |
|
2953 WriteObjectDataL(aMessage, 0, aEntry); |
|
2954 DeleteObjectZ(aEntry); // Delete the object to prevent it to be resent. |
|
2955 } |
|
2956 |
|
2957 void CScrRequestImpl::NextComponentSetSizeL(const RMessage2& aMessage, CStatement* aStmt, CComponentFilter* aFilter, RPointerArray<CComponentEntry>& aEntryList, CCompViewSubsessionContext* aSubsessionContext) const |
|
2958 { |
|
2959 DEBUG_PRINTF(_L8("Returning the size of the next component entry set.")); |
|
2960 __ASSERT_ALWAYS(aStmt && aFilter, PanicClient(aMessage, KScrIllegalCallSequence)); |
|
2961 |
|
2962 TInt maxArraySize = aMessage.Int0(); |
|
2963 TLanguage locale = TLanguage(aMessage.Int1()); |
|
2964 |
|
2965 aEntryList.ResetAndDestroy(); |
|
2966 CComponentEntry *entry(0); |
|
2967 TInt err(0); |
|
2968 for(TInt i=0; i<maxArraySize; ++i) |
|
2969 { |
|
2970 do { |
|
2971 TRAP(err, entry = GetNextComponentEntryL(*aStmt, *aFilter, locale, aSubsessionContext)); |
|
2972 }while(err == KErrNotFound); |
|
2973 |
|
2974 if(KErrNone != err) |
|
2975 { |
|
2976 User::Leave(err); |
|
2977 } |
|
2978 |
|
2979 if(!entry) |
|
2980 { |
|
2981 break; |
|
2982 } |
|
2983 CleanupStack::PushL(entry); |
|
2984 aEntryList.AppendL(entry); |
|
2985 CleanupStack::Pop(entry); // Ownership is transferred |
|
2986 } |
|
2987 WriteArraySizeL(aMessage, 2, aEntryList); |
|
2988 } |
|
2989 |
|
2990 |
|
2991 void CScrRequestImpl::NextComponentSetDataL(const RMessage2& aMessage, RPointerArray<CComponentEntry>& aEntryList) const |
|
2992 { |
|
2993 DEBUG_PRINTF(_L8("Returning the next component entry set.")); |
|
2994 WriteArrayDataL(aMessage, 0, aEntryList); |
|
2995 } |
|
2996 |
|
2997 void CScrRequestImpl::GetComponentIdListSizeL(const RMessage2& aMessage) const |
|
2998 { |
|
2999 DEBUG_PRINTF(_L8("Returning the required size to copy all components IDs from the components view.")); |
|
3000 // Get filter from the client |
|
3001 CComponentFilter *filter = ReadComponentFilterL(aMessage); |
|
3002 CleanupStack::PushL(filter); |
|
3003 |
|
3004 RArray<TComponentId> componentFilterSuperset; |
|
3005 CleanupClosePushL(componentFilterSuperset); |
|
3006 TBool filterSupersetInUse; |
|
3007 // Create a statement based on the filter |
|
3008 CStatement *stmt = OpenComponentViewL(*filter, componentFilterSuperset, filterSupersetInUse); |
|
3009 CleanupStack::PushL(stmt); |
|
3010 iComponentIdList.Reset(); |
|
3011 // Fetch all components from the row set and put them into the component list |
|
3012 while(stmt->ProcessNextRowL()) |
|
3013 { |
|
3014 TComponentId componentId = stmt->IntColumnL(0); |
|
3015 if (filterSupersetInUse && componentFilterSuperset.FindInOrder(componentId) < 0) |
|
3016 continue; // The component id does not match the name/vendor/file/property filter - do not add it to the result |
|
3017 iComponentIdList.InsertInOrder(componentId); |
|
3018 } |
|
3019 // Release allocated memories |
|
3020 CleanupStack::PopAndDestroy(3, filter); // stmt, componentFilterSuperset, filter |
|
3021 WriteArraySizeL(aMessage, 1, iComponentIdList); |
|
3022 } |
|
3023 |
|
3024 void CScrRequestImpl::GetComponentIdListDataL(const RMessage2& aMessage) const |
|
3025 { |
|
3026 DEBUG_PRINTF(_L8("Returning all components IDs from the components view.")); |
|
3027 WriteArrayDataL(aMessage, 0, iComponentIdList); |
|
3028 } |
|
3029 |
|
3030 CStatement* CScrRequestImpl::OpenFileListStatementL(TComponentId aComponentId) const |
|
3031 { |
|
3032 _LIT(KSelectFilesOfComponent, "SELECT Location FROM ComponentsFiles WHERE ComponentId=?;"); |
|
3033 |
|
3034 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectFilesOfComponent); |
|
3035 stmt->BindIntL(1, aComponentId); |
|
3036 CleanupStack::Pop(stmt); // Ownership is transferred to the caller |
|
3037 |
|
3038 return stmt; |
|
3039 } |
|
3040 |
|
3041 CStatement* CScrRequestImpl::OpenFileListL(const RMessage2& aMessage) const |
|
3042 { |
|
3043 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
3044 DEBUG_PRINTF2(_L8("Creating the requested file list for component(%d)."), componentId); |
|
3045 return OpenFileListStatementL(componentId); |
|
3046 } |
|
3047 |
|
3048 HBufC* CScrRequestImpl::GetNextFilePathL(CStatement& aStmt) const |
|
3049 { |
|
3050 if(!aStmt.ProcessNextRowL()) |
|
3051 { |
|
3052 return NULL; |
|
3053 } |
|
3054 return aStmt.StrColumnL(0).AllocL(); |
|
3055 } |
|
3056 |
|
3057 void CScrRequestImpl::NextFileSizeL(const RMessage2& aMessage, CStatement* aStmt, HBufC*& aFilePath) const |
|
3058 { |
|
3059 __ASSERT_ALWAYS(aStmt, PanicClient(aMessage, KScrIllegalCallSequence)); |
|
3060 DeleteObjectZ(aFilePath); |
|
3061 aFilePath = GetNextFilePathL(*aStmt); |
|
3062 WriteObjectSizeL(aMessage, 0, aFilePath); |
|
3063 } |
|
3064 |
|
3065 void CScrRequestImpl::NextFileDataL(const RMessage2& aMessage, HBufC*& aFilePath) const |
|
3066 { |
|
3067 WriteObjectDataL(aMessage, 0, aFilePath); |
|
3068 DeleteObjectZ(aFilePath); // Delete the file path to prevent it to be resent. |
|
3069 } |
|
3070 |
|
3071 void CScrRequestImpl::NextFileSetSizeL(const RMessage2& aMessage, CStatement* aStmt, RPointerArray<HBufC>& aFileList) const |
|
3072 { |
|
3073 __ASSERT_ALWAYS(aStmt, PanicClient(aMessage, KScrIllegalCallSequence)); |
|
3074 TInt maxArraySize = aMessage.Int0(); |
|
3075 aFileList.ResetAndDestroy(); |
|
3076 for(TInt i=0; i<maxArraySize; ++i) |
|
3077 { |
|
3078 HBufC *filePath = GetNextFilePathL(*aStmt); |
|
3079 if(!filePath) |
|
3080 { |
|
3081 break; |
|
3082 } |
|
3083 CleanupStack::PushL(filePath); |
|
3084 aFileList.AppendL(filePath); |
|
3085 CleanupStack::Pop(filePath); // Ownership is transferred |
|
3086 } |
|
3087 WriteArraySizeL(aMessage, 1, aFileList); |
|
3088 } |
|
3089 |
|
3090 void CScrRequestImpl::NextFileSetDataL(const RMessage2& aMessage, RPointerArray<HBufC>& aFileList) const |
|
3091 { |
|
3092 DEBUG_PRINTF(_L8("Returning the next file path set.")); |
|
3093 WriteArrayDataL(aMessage, 0, aFileList); |
|
3094 } |
|
3095 |
|
3096 TComponentId CScrRequestImpl::GetComponentIdFromMsgL(const RMessage2& aMessage) |
|
3097 { |
|
3098 return aMessage.Int0(); |
|
3099 } |
|
3100 |
|
3101 HBufC* CScrRequestImpl::GetSoftwareTypeNameFromMsgLC(const RMessage2& aMessage) |
|
3102 { |
|
3103 switch (CScsServer::StripScsFunctionMask(aMessage.Function())) |
|
3104 { |
|
3105 case EAddComponent: |
|
3106 case EAddComponentDependency: |
|
3107 case EDeleteComponentDependency: |
|
3108 { |
|
3109 return ReadDescLC(aMessage, 0); |
|
3110 } |
|
3111 default: |
|
3112 __ASSERT_ALWAYS(0, User::Invariant()); |
|
3113 } |
|
3114 return NULL; |
|
3115 } |
|
3116 |
|
3117 HBufC* CScrRequestImpl::ReadFileNameFromMsgLC(const RMessage2& aMessage) |
|
3118 { |
|
3119 return ReadDescLC(aMessage, 1); |
|
3120 } |
|
3121 |
|
3122 void CScrRequestImpl::InitializeDbVersionL() |
|
3123 { |
|
3124 _LIT(KSelectStatement, "SELECT MajorVersion, MinorVersion, BuildNumber FROM ScrVersion;"); |
|
3125 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectStatement); |
|
3126 if(!stmt->ProcessNextRowL()) |
|
3127 { |
|
3128 DEBUG_PRINTF(_L("Could not find entries in the version table - internal problem")); |
|
3129 User::Leave(KErrCorrupt); |
|
3130 } |
|
3131 |
|
3132 iDbVersion.iMajor = stmt->IntColumnL(0); |
|
3133 iDbVersion.iMinor = stmt->IntColumnL(1); |
|
3134 iDbVersion.iBuild = stmt->IntColumnL(2); |
|
3135 CleanupStack::PopAndDestroy(stmt); |
|
3136 DEBUG_PRINTF4(_L8("Opened SCR database with major version %d, minor version %d, and build number %d."), iDbVersion.iMajor, |
|
3137 iDbVersion.iMinor, iDbVersion.iBuild); |
|
3138 } |
|
3139 |
|
3140 void CScrRequestImpl::VerifyDbVersionCompatibilityL() const |
|
3141 { |
|
3142 if (iDbVersion.iMajor != KDbInterfaceMajorVersion) |
|
3143 { |
|
3144 DEBUG_PRINTF3(_L8("The SCR DB is incompatible! Supported major version is %d, and the DB major version is %d"), KDbInterfaceMajorVersion, iDbVersion.iMajor); |
|
3145 User::Leave(KErrCorrupt); |
|
3146 } |
|
3147 |
|
3148 if (iDbVersion.iMinor > KDbInterfaceMinorVersion) |
|
3149 { |
|
3150 DEBUG_PRINTF3(_L8("The SCR DB supports newer features which are not available in this software version. The DB minor version is %d, while the supported minor version is %d"), iDbVersion.iMinor, KDbInterfaceMinorVersion); |
|
3151 return; |
|
3152 } |
|
3153 |
|
3154 if (iDbVersion.iMinor < KDbInterfaceMinorVersion) |
|
3155 { |
|
3156 DEBUG_PRINTF3(_L8("The SCR DB does not support some newer features available in this software version. The DB minor version is %d, while the supported minor version is %d"), iDbVersion.iMinor, KDbInterfaceMinorVersion); |
|
3157 return; |
|
3158 } |
|
3159 |
|
3160 DEBUG_PRINTF4(_L8("The SCR DB has matching version with the supported interface. Supported major version is %d, minor version %d and build number %d"), KDbInterfaceMajorVersion, KDbInterfaceMinorVersion, KDbInterfaceBuildNumber); |
|
3161 } |
|
3162 |
|
3163 void ExtractNumberFromHexStringL(TInt& aPosition, const TDesC8& aString, TUint32& aIntValue) |
|
3164 { |
|
3165 TLex8 l(aString.Mid(aPosition, KUidStringLen)); |
|
3166 l.Val(aIntValue, EHex); |
|
3167 aPosition += KUidStringLen; |
|
3168 } |
|
3169 |
|
3170 void ParseUidHexStringL(const TDesC8& aUidString, TUint32& aSifPluginUid, TUint32& aInstallerSid, TUint32& aExecutionLayerSid) |
|
3171 { |
|
3172 __ASSERT_ALWAYS(aUidString.Length() >= 3*KUidStringLen, User::Leave(KErrArgument)); |
|
3173 TInt pos (0); // The starting position of aUidString |
|
3174 ExtractNumberFromHexStringL(pos, aUidString, aSifPluginUid); |
|
3175 ExtractNumberFromHexStringL(pos, aUidString, aInstallerSid); |
|
3176 ExtractNumberFromHexStringL(pos, aUidString, aExecutionLayerSid); |
|
3177 } |
|
3178 |
|
3179 TBool CompareLocalizedSoftwareTypeName(const CLocalizedSoftwareTypeName& aLeft, const CLocalizedSoftwareTypeName& aRight) |
|
3180 { |
|
3181 TBool result = EFalse; |
|
3182 |
|
3183 TRAPD(err, result = (aLeft.Locale() == aRight.Locale() && !aLeft.NameL().CompareF(aRight.NameL()))); |
|
3184 if (err != KErrNone) |
|
3185 { |
|
3186 DEBUG_PRINTF2(_L("CompareLocalizedSoftwareTypeName has left with error %d"), err); |
|
3187 return EFalse; |
|
3188 } |
|
3189 else |
|
3190 { |
|
3191 return result; |
|
3192 } |
|
3193 } |
|
3194 |
|
3195 TBool CompareHBufDescs(const HBufC& aLeft, const HBufC& aRight) |
|
3196 { |
|
3197 return !aLeft.CompareF(aRight); |
|
3198 } |
|
3199 |
|
3200 TBool CScrRequestImpl::IsSoftwareTypeExistingL(TUint32 aSwTypeId, TUint32 aSifPluginUid, RArray<TCustomAccessInfo>& aSidArray, const RPointerArray<HBufC>& aMimeTypesArray, const RPointerArray<CLocalizedSoftwareTypeName>& aLocalizedNamesArray, const TDesC& aLauncherExecutable) |
|
3201 { |
|
3202 //Check if software type id exists |
|
3203 if(!IsSoftwareTypeExistingL(aSwTypeId)) |
|
3204 { |
|
3205 DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: Software Type Id (%d) doesn't exist in the SCR."), aSwTypeId); |
|
3206 return EFalse; |
|
3207 } |
|
3208 |
|
3209 //Check if sif plugin uid for the software type id is the same |
|
3210 TInt pluginUid(0); |
|
3211 if(!GetSifPluginUidIInternalL(aSwTypeId, pluginUid)) |
|
3212 { |
|
3213 DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't exist in the SCR for TypeId %d."), aSwTypeId); |
|
3214 return EFalse; |
|
3215 } |
|
3216 |
|
3217 if(aSifPluginUid != pluginUid) |
|
3218 { |
|
3219 DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't match with the one in the SCR."), pluginUid); |
|
3220 return EFalse; |
|
3221 } |
|
3222 |
|
3223 //Check if launcher executable for the software type id is the same |
|
3224 HBufC *launcherExe; |
|
3225 _LIT(KSelectLauncherExecutable, "SELECT LauncherExecutable FROM SoftwareTypes WHERE SoftwareTypeId=?;"); |
|
3226 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectLauncherExecutable); |
|
3227 stmt->BindIntL(1, aSwTypeId); |
|
3228 |
|
3229 if(stmt->ProcessNextRowL()) |
|
3230 { |
|
3231 launcherExe = stmt->StrColumnL(0).AllocLC(); |
|
3232 if(launcherExe->Compare(aLauncherExecutable) != 0) |
|
3233 { |
|
3234 DEBUG_PRINTF(_L8("IsSoftwareTypeExistingL: Launcher Executable doesn't match with the one in the SCR.")); |
|
3235 CleanupStack::PopAndDestroy(2, stmt); |
|
3236 return EFalse; |
|
3237 } |
|
3238 CleanupStack::PopAndDestroy(2, stmt); |
|
3239 } |
|
3240 else |
|
3241 { |
|
3242 DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: Launcher Executable doesn't exist in the SCR for TypeId %d."), aSwTypeId); |
|
3243 CleanupStack::PopAndDestroy(stmt); |
|
3244 return EFalse; |
|
3245 } |
|
3246 |
|
3247 //Check if associated installer sid's for the software type id is the same |
|
3248 |
|
3249 RArray<TSecureId> installerSids; |
|
3250 CleanupClosePushL(installerSids); |
|
3251 if(GetSidsForSoftwareTypeIdL(aSwTypeId, installerSids)) |
|
3252 { |
|
3253 for(TInt i=0; i<aSidArray.Count(); ++i) |
|
3254 { |
|
3255 if(KErrNotFound == installerSids.Find(aSidArray[i].SecureId())) |
|
3256 { |
|
3257 DEBUG_PRINTF(_L8("IsSoftwareTypeExistingL: One of the Sid doesn't match with the one in the SCR.")); |
|
3258 CleanupStack::PopAndDestroy(&installerSids); |
|
3259 return EFalse; |
|
3260 } |
|
3261 } |
|
3262 } |
|
3263 CleanupStack::PopAndDestroy(&installerSids); |
|
3264 |
|
3265 //Check if localized software type name for the software type id is the same |
|
3266 _LIT(KSelectSwTypeNames, "SELECT Locale,Name FROM SoftwareTypeNames WHERE SoftwareTypeId=? AND Locale!=?;"); |
|
3267 CStatement* stmtNames = iDbHandle->PrepareStatementLC(KSelectSwTypeNames); |
|
3268 stmtNames->BindIntL(1, aSwTypeId); |
|
3269 stmtNames->BindIntL(2, KNonLocalized); |
|
3270 TInt numOfFoundNames (0); |
|
3271 while(stmtNames->ProcessNextRowL()) |
|
3272 { |
|
3273 ++numOfFoundNames; |
|
3274 const TDesC& swTypeNameValue = stmtNames->StrColumnL(1); |
|
3275 CLocalizedSoftwareTypeName *swTypeName = CLocalizedSoftwareTypeName::NewLC(swTypeNameValue, TLanguage(stmtNames->IntColumnL(0))); |
|
3276 TInt ret = aLocalizedNamesArray.Find(swTypeName, TIdentityRelation<CLocalizedSoftwareTypeName>(CompareLocalizedSoftwareTypeName)); |
|
3277 CleanupStack::PopAndDestroy(swTypeName); |
|
3278 if(KErrNotFound == ret) |
|
3279 { |
|
3280 DEBUG_PRINTF2(_L("IsSoftwareTypeExistingL: %S doesn't exist in the provided sofwtare type names list."), &swTypeNameValue); |
|
3281 CleanupStack::PopAndDestroy(stmtNames); |
|
3282 return EFalse; |
|
3283 } |
|
3284 } |
|
3285 CleanupStack::PopAndDestroy(stmtNames); |
|
3286 if(numOfFoundNames != aLocalizedNamesArray.Count()) |
|
3287 { |
|
3288 DEBUG_PRINTF3(_L("IsSoftwareTypeExistingL: the number of provided software type names (%d) is different than the number of existing software type names (%d) in the SCR."), numOfFoundNames, aLocalizedNamesArray.Count()); |
|
3289 return EFalse; |
|
3290 } |
|
3291 |
|
3292 //Check if mime type for the software type id is the same |
|
3293 _LIT(KSelectMimeTypes, "SELECT MimeType FROM MimeTypes WHERE SoftwareTypeId=?;"); |
|
3294 CStatement* stmtMimes = iDbHandle->PrepareStatementLC(KSelectMimeTypes); |
|
3295 stmtMimes->BindIntL(1, aSwTypeId); |
|
3296 TInt numOfFoundMimes (0); |
|
3297 while(stmtMimes->ProcessNextRowL()) |
|
3298 { |
|
3299 ++numOfFoundMimes; |
|
3300 HBufC *mimeType = stmtMimes->StrColumnL(0).AllocLC(); |
|
3301 TInt ret = aMimeTypesArray.Find(mimeType, TIdentityRelation<HBufC>(CompareHBufDescs)); |
|
3302 if(KErrNotFound == ret) |
|
3303 { |
|
3304 DEBUG_PRINTF2(_L("IsSoftwareTypeExistingL: %S doesn't exist in the provided MIME types list."), mimeType); |
|
3305 CleanupStack::PopAndDestroy(2, stmtMimes); // stmtMimes, mimeType |
|
3306 return EFalse; |
|
3307 } |
|
3308 CleanupStack::PopAndDestroy(mimeType); |
|
3309 } |
|
3310 CleanupStack::PopAndDestroy(stmtMimes); |
|
3311 if(numOfFoundMimes != aMimeTypesArray.Count()) |
|
3312 { |
|
3313 DEBUG_PRINTF3(_L("IsSoftwareTypeExistingL: the number of provided MIME types (%d) is different than the number of existing MIME types (%d) in the SCR."), numOfFoundMimes, aMimeTypesArray.Count()); |
|
3314 return EFalse; |
|
3315 } |
|
3316 // All software type details are identical |
|
3317 DEBUG_PRINTF(_L8("IsSoftwareTypeExistingL: All software type details are identical. This is a software type update.")); |
|
3318 return ETrue; |
|
3319 } |
|
3320 |
|
3321 void CScrRequestImpl::AddSoftwareTypeL(const RMessage2& aMessage) |
|
3322 { |
|
3323 DEBUG_PRINTF(_L8("Adding a new software type.")); |
|
3324 // NB SoftwareTypeId is the hash of unique software type name. Since this name is unique, it is expected |
|
3325 // that there won't be any conflicts with software type ids. If an installer is uninstalled and then re-installed, |
|
3326 // the same software type id will be assigned for it as its unique name is not changed. The advantage is that |
|
3327 // the orphaned components will become non-orphaned again automatically when their installer is re-installed. |
|
3328 // Otherwise, we would have to find a complex solution to associate the software type id of orphaned components |
|
3329 // with the corresponding installer which had been re-installed. |
|
3330 // Another advantage of this approach is that it is not mandatory to query SoftwareTypes table in order to get |
|
3331 // the software type id of an installer. If the uniqe software type name of the installer is known, its hash |
|
3332 // is simply calculated to obtain its software type id. |
|
3333 |
|
3334 CSoftwareTypeRegInfo *regInfo = ReadObjectFromMessageLC<CSoftwareTypeRegInfo>(aMessage, 0); |
|
3335 |
|
3336 HBufC* uniqueSwTypeName = HBufC::NewLC(regInfo->UniqueSoftwareTypeName().Length()); |
|
3337 uniqueSwTypeName->Des().Copy(regInfo->UniqueSoftwareTypeName()); |
|
3338 |
|
3339 TUint32 swTypeId = HashCaseSensitiveL(regInfo->UniqueSoftwareTypeName()); |
|
3340 |
|
3341 TUint32 sifPluginUid (0); |
|
3342 sifPluginUid = regInfo->SifPluginUid().iUid; |
|
3343 |
|
3344 RArray<TCustomAccessInfo> sidArray; |
|
3345 sidArray = regInfo->CustomAccessList(); |
|
3346 |
|
3347 RPointerArray<HBufC> mimeTypesArray = regInfo->MimeTypes(); |
|
3348 |
|
3349 RPointerArray<CLocalizedSoftwareTypeName> localizedNamesArray = regInfo->LocalizedSoftwareTypeNames(); |
|
3350 |
|
3351 HBufC* launcherExecutable = HBufC::NewLC(regInfo->LauncherExecutable().Length()); |
|
3352 launcherExecutable->Des().Copy(regInfo->LauncherExecutable()); |
|
3353 |
|
3354 if (IsSoftwareTypeExistingL(swTypeId, sifPluginUid, sidArray, mimeTypesArray, localizedNamesArray, *launcherExecutable)) |
|
3355 { // If the software type exists, do nothing and return; |
|
3356 CleanupStack::PopAndDestroy(3, regInfo); // uniqueSwTypeName, launcherExecutable, regInfo |
|
3357 return; |
|
3358 } |
|
3359 |
|
3360 // First, insert the main record to SoftwareTypes table |
|
3361 _LIT(KInsertSwType, "INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid,LauncherExecutable) VALUES(?,?,?);"); |
|
3362 TInt numberOfValuesSwType = 3; |
|
3363 ExecuteStatementL(KInsertSwType(), numberOfValuesSwType, EValueInteger, swTypeId, EValueInteger, sifPluginUid, EValueString, launcherExecutable); |
|
3364 |
|
3365 _LIT(KInsertCustomAccess, "INSERT INTO CustomAccessList(SoftwareTypeId,SecureId,AccessMode) VALUES(?,?,?);"); |
|
3366 TInt numberOfValuesCustomAccess = 3; |
|
3367 for(TInt i=0; i<sidArray.Count(); ++i) |
|
3368 { |
|
3369 TUint32 sid = sidArray[i].SecureId(); |
|
3370 TAccessMode accessMode = sidArray[i].AccessMode(); |
|
3371 ExecuteStatementL(KInsertCustomAccess(), numberOfValuesCustomAccess, EValueInteger, swTypeId, EValueInteger, sid, EValueInteger, accessMode); |
|
3372 } |
|
3373 |
|
3374 // Then, insert MIME types of this software type into MimeTypes table |
|
3375 _LIT(KInsertMimeType, "INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);"); |
|
3376 TInt numberOfValuesMimeType = 2; |
|
3377 TInt countMimeTypes = mimeTypesArray.Count(); |
|
3378 for(TInt i=0; i<countMimeTypes; ++i) |
|
3379 { |
|
3380 ExecuteStatementL(KInsertMimeType(), numberOfValuesMimeType, EValueInteger, swTypeId, EValueString, mimeTypesArray[i]); |
|
3381 } |
|
3382 |
|
3383 // Finally, insert unique and localized names into SoftwareTypeNames table |
|
3384 _LIT(KInsertSwTypeName, "INSERT INTO SoftwareTypeNames(SoftwareTypeId,Locale,Name) VALUES(?,?,?);"); |
|
3385 TInt numberOfValuesSwTypeName = 3; |
|
3386 ExecuteStatementL(KInsertSwTypeName(), numberOfValuesSwTypeName, EValueInteger, swTypeId, EValueInteger, KNonLocalized, EValueString, uniqueSwTypeName); |
|
3387 |
|
3388 TInt countNames = localizedNamesArray.Count(); |
|
3389 for(TInt i=0; i<countNames; ++i) |
|
3390 { |
|
3391 TLanguage locale = localizedNamesArray[i]->Locale(); |
|
3392 const TDesC& name = localizedNamesArray[i]->NameL(); |
|
3393 ExecuteStatementL(KInsertSwTypeName(), numberOfValuesSwTypeName, EValueInteger, swTypeId, EValueInteger, locale, EValueString, &name); |
|
3394 } |
|
3395 CleanupStack::PopAndDestroy(3, regInfo); // uniqueSwTypeName, launcherExecutable, regInfo |
|
3396 } |
|
3397 |
|
3398 void CScrRequestImpl::DeleteSoftwareTypeL(const RMessage2& aMessage) |
|
3399 { |
|
3400 HBufC *uniqueSwTypeName = ReadDescLC(aMessage, 0); |
|
3401 DEBUG_PRINTF2(_L("Deleting Software type (%S)."), uniqueSwTypeName); |
|
3402 |
|
3403 TUint32 swTypeId = HashCaseSensitiveL(*uniqueSwTypeName); |
|
3404 CleanupStack::PopAndDestroy(uniqueSwTypeName); |
|
3405 |
|
3406 // First, delete software type names |
|
3407 _LIT(KDeleteSoftwareTypeNames, "DELETE FROM SoftwareTypeNames WHERE SoftwareTypeId=?;"); |
|
3408 TInt numberOfValues = 1; |
|
3409 ExecuteStatementL(KDeleteSoftwareTypeNames(), numberOfValues, EValueInteger, swTypeId); |
|
3410 |
|
3411 // Secondly, delete the actual software type record |
|
3412 _LIT(KDeleteSoftwareType, "DELETE FROM SoftwareTypes WHERE SoftwareTypeId=?;"); |
|
3413 ExecuteStatementL(KDeleteSoftwareType(), numberOfValues, EValueInteger, swTypeId); |
|
3414 |
|
3415 _LIT(KDeleteCustomAccess, "DELETE FROM CustomAccessList WHERE SoftwareTypeId=?;"); |
|
3416 ExecuteStatementL(KDeleteCustomAccess(), numberOfValues, EValueInteger, swTypeId); |
|
3417 |
|
3418 // Thirdly, get the list of MIME types belong to the deleted software type. |
|
3419 // This list will be returned to the client with another request (GetDeletedMimeTypesL) |
|
3420 _LIT(KSelectMimeTypes, "SELECT MimeType FROM MimeTypes WHERE SoftwareTypeId=?;"); |
|
3421 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectMimeTypes); |
|
3422 stmt->BindIntL(1, swTypeId); |
|
3423 |
|
3424 iDeletedMimeTypes.ResetAndDestroy(); |
|
3425 while(stmt->ProcessNextRowL()) |
|
3426 { |
|
3427 iDeletedMimeTypes.AppendL(stmt->StrColumnL(0).AllocL()); |
|
3428 } |
|
3429 CleanupStack::PopAndDestroy(stmt); |
|
3430 |
|
3431 // Finally, delete the MIME types belong to the deleted software type name |
|
3432 _LIT(KDeleteMimeTypes, "DELETE FROM MimeTypes WHERE SoftwareTypeId=?;"); |
|
3433 ExecuteStatementL(KDeleteMimeTypes(), numberOfValues, EValueInteger, swTypeId); |
|
3434 WriteArraySizeL(aMessage, 1, iDeletedMimeTypes); |
|
3435 } |
|
3436 |
|
3437 void CScrRequestImpl::GetDeletedMimeTypesL(const RMessage2& aMessage) const |
|
3438 { |
|
3439 WriteArrayDataL(aMessage, 0, iDeletedMimeTypes); |
|
3440 iDeletedMimeTypes.ResetAndDestroy(); |
|
3441 } |
|
3442 |
|
3443 TInt CScrRequestImpl::GetSoftwareTypeForComponentL(TComponentId aComponentId) const |
|
3444 { |
|
3445 _LIT(KSelectComponentSoftwareTypeId, "SELECT SoftwareTypeId FROM Components WHERE ComponentId=?;"); |
|
3446 |
|
3447 TInt swTypeId = 0; |
|
3448 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectComponentSoftwareTypeId); |
|
3449 stmt->BindIntL(1, aComponentId); |
|
3450 |
|
3451 if(!stmt->ProcessNextRowL()) |
|
3452 { |
|
3453 DEBUG_PRINTF2(_L("Component Id (%d) couldn't be found!"), aComponentId); |
|
3454 User::Leave(KErrNotFound); |
|
3455 } |
|
3456 |
|
3457 swTypeId = stmt->IntColumnL(0); |
|
3458 CleanupStack::PopAndDestroy(stmt); |
|
3459 |
|
3460 return swTypeId; |
|
3461 } |
|
3462 |
|
3463 TBool CScrRequestImpl::GetIsComponentOrphanedL(TComponentId aComponentId) const |
|
3464 { |
|
3465 // Get the software type for component |
|
3466 TUint32 swTypeId = GetSoftwareTypeForComponentL(aComponentId); |
|
3467 |
|
3468 // The component is orphaned iff the software type does not exist. |
|
3469 return !IsSoftwareTypeExistingL(swTypeId); |
|
3470 } |
|
3471 |
|
3472 void CScrRequestImpl::GetIsComponentOrphanedL(const RMessage2& aMessage) const |
|
3473 { |
|
3474 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
3475 TBool result = GetIsComponentOrphanedL(componentId); |
|
3476 DEBUG_PRINTF2(_L8("Retrieving whether the component(%d) is orphaned."), componentId); |
|
3477 |
|
3478 TPckg<TBool> resultPkg(result); |
|
3479 |
|
3480 aMessage.WriteL(1, resultPkg); |
|
3481 } |
|
3482 |
|
3483 void CheckAndCreateLogFileL(RFs& aFs, const TDesC& aFileName) |
|
3484 { |
|
3485 TEntry entry; |
|
3486 TInt err = aFs.Entry(aFileName, entry); |
|
3487 |
|
3488 if(KErrNone == err) |
|
3489 return; |
|
3490 |
|
3491 if (KErrPathNotFound == err) |
|
3492 { |
|
3493 User::LeaveIfError(aFs.MkDirAll(aFileName)); |
|
3494 } |
|
3495 else if(KErrNotFound != err) |
|
3496 { |
|
3497 DEBUG_PRINTF2(_L("The log file couldn't be opened. Error=%d."), err); |
|
3498 User::Leave(err); |
|
3499 } |
|
3500 |
|
3501 RFileWriteStream stream; |
|
3502 User::LeaveIfError(stream.Create(aFs, aFileName, EFileWrite | EFileShareAny | EFileStream)); |
|
3503 stream.PushL(); |
|
3504 stream.WriteInt32L(1); // The major version of the log file |
|
3505 stream.WriteInt32L(0); // The minor version of the log file |
|
3506 // Please note that the log file version is not used currently. It is implemented for a possible future need. |
|
3507 // If the version format is changed, then the end of FlushLogEntriesArrayL function where the final log count is written must be updated. |
|
3508 // FlushLogEntriesArrayL assumes that first 8 bytes store version information. |
|
3509 stream.WriteInt32L(0); // The number of log records in the log file |
|
3510 stream.CommitL(); |
|
3511 CleanupStack::PopAndDestroy(&stream); |
|
3512 } |
|
3513 |
|
3514 void CScrRequestImpl::FlushLogEntriesArrayL() |
|
3515 { |
|
3516 TInt logCount2bFlushed = iLogEntries.Count(); |
|
3517 if(!logCount2bFlushed) |
|
3518 return; // No record to write into the log file. |
|
3519 |
|
3520 // Get the log file name |
|
3521 HBufC *logFileName = UpdateFilePathDriveLC(KScrLogFileName, iFs.GetSystemDriveChar()); |
|
3522 // Check whether the log file exists. If not, create one. |
|
3523 CheckAndCreateLogFileL(iFs, *logFileName); |
|
3524 |
|
3525 RFileReadStream readStream; |
|
3526 User::LeaveIfError(readStream.Open(iFs, *logFileName, EFileRead|EFileShareExclusive|EFileStream)); |
|
3527 readStream.PushL(); |
|
3528 (void)readStream.ReadInt32L(); // skip the major version of the log file |
|
3529 (void)readStream.ReadInt32L(); // skip the minor version of the log file |
|
3530 TInt currentLogCount = readStream.ReadInt32L(); |
|
3531 |
|
3532 if(KMaxScrLogEntries <= currentLogCount + logCount2bFlushed) |
|
3533 { |
|
3534 //Create a temporary file and read the log file in that |
|
3535 //oldest entries will be removed in the temporary log file |
|
3536 HBufC *tempLogName = UpdateFilePathDriveLC(KScrTempLogFileName, iFs.GetSystemDriveChar()); |
|
3537 TInt err = iFs.Delete(*tempLogName); |
|
3538 __ASSERT_ALWAYS(err == KErrNotFound || err == KErrNone, User::Leave(err)); |
|
3539 CheckAndCreateLogFileL(iFs, *tempLogName); |
|
3540 |
|
3541 RFileWriteStream writeStream; |
|
3542 User::LeaveIfError(writeStream.Open(iFs, *tempLogName, EFileWrite | EFileStream)); |
|
3543 writeStream.PushL(); |
|
3544 writeStream.Sink()->SeekL(MStreamBuf::EWrite,EStreamEnd); // Skip the version info and log count |
|
3545 |
|
3546 TInt tmpLogCount (0); |
|
3547 CScrLogEntry *log = NULL; |
|
3548 |
|
3549 for (TInt i = logCount2bFlushed; i < currentLogCount; ++i, ++tmpLogCount) |
|
3550 { |
|
3551 log = CScrLogEntry::NewLC(readStream); |
|
3552 writeStream << *log; |
|
3553 CleanupStack::PopAndDestroy(log); |
|
3554 } // for |
|
3555 |
|
3556 currentLogCount = tmpLogCount; |
|
3557 writeStream.CommitL(); |
|
3558 CleanupStack::PopAndDestroy(&writeStream); |
|
3559 readStream.Release(); |
|
3560 |
|
3561 RStsSession stsSession; // transaction service |
|
3562 CleanupClosePushL(stsSession); |
|
3563 stsSession.CreateTransactionL(); |
|
3564 |
|
3565 stsSession.RemoveL(*logFileName); |
|
3566 stsSession.RegisterNewL(*logFileName); |
|
3567 stsSession.RegisterTemporaryL(*tempLogName); |
|
3568 |
|
3569 TInt renameErr = iFs.Rename(*tempLogName,*logFileName); |
|
3570 if (KErrNone == renameErr) |
|
3571 { |
|
3572 // commit file changes. |
|
3573 stsSession.CommitL(); |
|
3574 } |
|
3575 else |
|
3576 { |
|
3577 // rollback file changes and leave with the error code. |
|
3578 stsSession.RollBackL(); |
|
3579 DEBUG_PRINTF2(_L("The log file couldn't be renamed. Error=%d."), renameErr); |
|
3580 User::Leave(renameErr); |
|
3581 } |
|
3582 CleanupStack::PopAndDestroy(2, tempLogName); // tempLogName, stsSession |
|
3583 } // endif KMaxScrLogEntries <= |
|
3584 |
|
3585 CleanupStack::PopAndDestroy(&readStream); |
|
3586 |
|
3587 RFile file; |
|
3588 User::LeaveIfError(file.Open(iFs, *logFileName, EFileRead|EFileWrite| EFileShareExclusive| EFileStream)); |
|
3589 CleanupClosePushL(file); |
|
3590 TInt pos (0); |
|
3591 User::LeaveIfError(file.Seek(ESeekEnd, pos)); |
|
3592 RFileWriteStream stream(file, pos); |
|
3593 stream.PushL(); |
|
3594 |
|
3595 TInt startIdx = (logCount2bFlushed - KMaxScrLogEntries)>0 ? (logCount2bFlushed - KMaxScrLogEntries) : 0; |
|
3596 TInt logCountFlushed (0); |
|
3597 for(TInt i=startIdx; i<logCount2bFlushed; ++i, ++logCountFlushed) |
|
3598 { |
|
3599 iLogEntries[i]->ExternalizeL(stream); |
|
3600 } |
|
3601 iLogEntries.ResetAndDestroy(); |
|
3602 stream.CommitL(); |
|
3603 stream.Release(); |
|
3604 file.Close(); |
|
3605 |
|
3606 // Update the log count |
|
3607 User::LeaveIfError(stream.Open(iFs, *logFileName, EFileRead|EFileWrite|EFileShareExclusive|EFileStream)); |
|
3608 stream.Sink()->SeekL(MStreamBuf::EWrite,EStreamBeginning,8); // Skip the version info |
|
3609 stream.WriteInt32L(logCountFlushed + currentLogCount); |
|
3610 stream.CommitL(); |
|
3611 |
|
3612 CleanupStack::PopAndDestroy(3, logFileName); // logFileName, file, stream |
|
3613 } |
|
3614 |
|
3615 void CScrRequestImpl::GetLogFileHandleL(const RMessage2& aMessage) const |
|
3616 { |
|
3617 // Get the log file name |
|
3618 HBufC *logFileName = UpdateFilePathDriveLC(KScrLogFileName, iFs.GetSystemDriveChar()); |
|
3619 // Check whether the log file exists. If not, create one. |
|
3620 CheckAndCreateLogFileL(iFs, *logFileName); |
|
3621 |
|
3622 RFile file; |
|
3623 User::LeaveIfError(file.Open(iFs, *logFileName, EFileRead | EFileShareAny | EFileStream)); |
|
3624 CleanupClosePushL(file); |
|
3625 |
|
3626 // Store the RFile handle into the package buffer in slot 0 and complete the message with the RFs handle |
|
3627 User::LeaveIfError(file.TransferToClient(aMessage, 0)); |
|
3628 ASSERT(aMessage.IsNull()); // The message should have been completed |
|
3629 CleanupStack::PopAndDestroy(2, logFileName); // logFileName, file |
|
3630 } |
|
3631 |
|
3632 void CScrRequestImpl::GetIsComponentOnReadOnlyDriveL(const RMessage2& aMessage) const |
|
3633 { |
|
3634 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
3635 DEBUG_PRINTF2(_L8("Checking if the component(%d) is on read-only drive."), componentId); |
|
3636 |
|
3637 // Get the drives on which the component files' are registered |
|
3638 TInt driveBitmask = GetInstalledDrivesBitmaskL(componentId); |
|
3639 |
|
3640 TBool result = EFalse; |
|
3641 |
|
3642 for (TInt index = 0; index < KMaxDrives; ++index, driveBitmask >>= 1) |
|
3643 { |
|
3644 if ((driveBitmask & 0x1) && IsDriveReadOnlyL(index)) |
|
3645 { |
|
3646 DEBUG_PRINTF3(_L8("Component %d has registered a file at read-only drive %c ."), componentId, index + 'a'); |
|
3647 result = ETrue; |
|
3648 break; |
|
3649 } |
|
3650 } |
|
3651 |
|
3652 TPckg<TBool> resPkg(result); |
|
3653 aMessage.WriteL(1, resPkg); |
|
3654 } |
|
3655 |
|
3656 TBool CScrRequestImpl::IsDriveReadOnlyL(TInt driveIndex) const |
|
3657 { |
|
3658 TDriveInfo driveInfo; |
|
3659 User::LeaveIfError(iFs.Drive(driveInfo,driveIndex)); |
|
3660 |
|
3661 TBool result = EFalse; |
|
3662 if ((driveInfo.iDriveAtt&KDriveAttRom) || (driveInfo.iType==EMediaRom)) |
|
3663 result = ETrue; |
|
3664 |
|
3665 return result; |
|
3666 } |
|
3667 |
|
3668 void CScrRequestImpl::GetIsComponentPresentL(const RMessage2& aMessage) const |
|
3669 { |
|
3670 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
3671 TBool result = IsComponentPresentL(componentId); |
|
3672 |
|
3673 TPckg<TBool> isCompPresent(result); |
|
3674 aMessage.WriteL(1, isCompPresent); |
|
3675 } |
|
3676 |
|
3677 |
|
3678 TBool CScrRequestImpl::IsComponentPresentL(TComponentId componentId) const |
|
3679 { |
|
3680 DEBUG_PRINTF2(_L8("Checking if the component(%d) is available."), componentId); |
|
3681 |
|
3682 _LIT(KSelectCompPresent, "SELECT CompPresence FROM Components WHERE ComponentId=?;"); |
|
3683 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectCompPresent); |
|
3684 stmt->BindIntL(1, componentId); |
|
3685 if(!stmt->ProcessNextRowL()) |
|
3686 { |
|
3687 DEBUG_PRINTF2(_L8("Component (%d) couldn't be found in the SCR database."), componentId); |
|
3688 User::Leave(KErrNotFound); |
|
3689 } |
|
3690 TBool result = (stmt->IntColumnL(0) == 1); |
|
3691 CleanupStack::PopAndDestroy(stmt); |
|
3692 |
|
3693 // The default value for CompPresence is ETrue. So when we find that the SCR DB contains the |
|
3694 // default property value we check if the drives registered by the component are present. |
|
3695 if (result && !CheckForMediaPresenceL(componentId)) |
|
3696 { |
|
3697 result = EFalse; |
|
3698 } |
|
3699 return result; |
|
3700 } |
|
3701 |
|
3702 void CScrRequestImpl::SetIsComponentPresentL(const RMessage2& aMessage) |
|
3703 { |
|
3704 DEBUG_PRINTF(_L8("Setting the component as present.")); |
|
3705 _LIT(KColumnNameCompPresence, "CompPresence"); |
|
3706 ReadAndSetCommonComponentPropertyL(aMessage, KColumnNameCompPresence); |
|
3707 } |
|
3708 |
|
3709 void CScrRequestImpl::GetComponentSupportedLocalesListSizeL(const RMessage2& aMessage) const |
|
3710 { |
|
3711 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
3712 DEBUG_PRINTF2(_L8("Returning the required size to copy all matching supported language IDs for component =(%d)"), componentId); |
|
3713 |
|
3714 _LIT(KSelectMatchingSupportedLocales, "SELECT Locale FROM ComponentLocalizables WHERE ComponentId=?;"); |
|
3715 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectMatchingSupportedLocales); |
|
3716 stmt->BindIntL(1, componentId); |
|
3717 iMatchingSupportedLanguageList.Close(); |
|
3718 while(stmt->ProcessNextRowL()) |
|
3719 { |
|
3720 TLanguage languageId = (TLanguage)stmt->IntColumnL(0); |
|
3721 iMatchingSupportedLanguageList.Insert(languageId,iMatchingSupportedLanguageList.Count()); |
|
3722 } |
|
3723 if (iMatchingSupportedLanguageList.Count() == 1) |
|
3724 { |
|
3725 iMatchingSupportedLanguageList.Close(); |
|
3726 } |
|
3727 |
|
3728 // Release allocated memories |
|
3729 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
3730 WriteArraySizeL(aMessage, 1, iMatchingSupportedLanguageList); |
|
3731 |
|
3732 } |
|
3733 |
|
3734 void CScrRequestImpl::GetComponentSupportedLocalesListDataL(const RMessage2& aMessage) const |
|
3735 { |
|
3736 DEBUG_PRINTF(_L8("Getting the Data of matching supported languages")); |
|
3737 WriteArrayDataL(aMessage, 0, iMatchingSupportedLanguageList); |
|
3738 iMatchingSupportedLanguageList.Close(); |
|
3739 } |
|
3740 |
|
3741 TBool CScrRequestImpl::DoesAppWithScreenModeExistL(TUid aAppUid, TInt aScreenMode, TLanguage aLocale) const |
|
3742 { |
|
3743 _LIT(KSelectAppUidFromLocalizableAppInfo,"SELECT COUNT(*)FROM (LocalizableAppInfo JOIN ViewData ON LocalizableAppInfo.LocalAppInfoId = ViewData.LocalAppInfoId) WHERE AppUid = ? AND ScreenMode = ? AND Locale = ?;"); |
|
3744 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppUidFromLocalizableAppInfo); |
|
3745 stmt->BindIntL(1, aAppUid.iUid); |
|
3746 stmt->BindIntL(2, aScreenMode); |
|
3747 stmt->BindIntL(3, aLocale); |
|
3748 stmt->ProcessNextRowL(); |
|
3749 TInt count = stmt->IntColumnL(0); |
|
3750 CleanupStack::PopAndDestroy(stmt); |
|
3751 if(count!=0) |
|
3752 return ETrue; |
|
3753 else |
|
3754 return EFalse; |
|
3755 } |
|
3756 |
|
3757 void CScrRequestImpl::GetAppUidsL(CAppInfoViewSubsessionContext* aSubsessionContext, TBool aScreenModePresent) const |
|
3758 { |
|
3759 DEBUG_PRINTF(_L8("Returning the App Uid.")); |
|
3760 CStatement* stmt; |
|
3761 _LIT(KAllAppIds,"SELECT AppUid from AppRegistrationInfo"); |
|
3762 stmt = iDbHandle->PrepareStatementLC(KAllAppIds); |
|
3763 aSubsessionContext->iApps.Close(); |
|
3764 while(stmt->ProcessNextRowL()) |
|
3765 { |
|
3766 TAppUidWithLocaleInfo appUidWithLocaleInfo; |
|
3767 appUidWithLocaleInfo.iAppUid = TUid::Uid(stmt->IntColumnL(0)); |
|
3768 appUidWithLocaleInfo.iLocale = KUnspecifiedLocale; |
|
3769 GetNearestAppLanguageL(aSubsessionContext->iLocale, appUidWithLocaleInfo.iAppUid, appUidWithLocaleInfo.iLocale); |
|
3770 if(aScreenModePresent) |
|
3771 { |
|
3772 if(DoesAppWithScreenModeExistL(appUidWithLocaleInfo.iAppUid, aSubsessionContext->iScreenMode, appUidWithLocaleInfo.iLocale)) |
|
3773 { |
|
3774 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3775 } |
|
3776 } |
|
3777 |
|
3778 else |
|
3779 { |
|
3780 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3781 } |
|
3782 } |
|
3783 CleanupStack::PopAndDestroy(stmt); |
|
3784 } |
|
3785 |
|
3786 void CScrRequestImpl::GetEmbeddableAppUidsL(CAppInfoViewSubsessionContext* aSubsessionContext, TBool aScreenModePresent) const |
|
3787 { |
|
3788 DEBUG_PRINTF(_L8("Returning the Embeddable App Uids.")); |
|
3789 CStatement *stmt1; |
|
3790 _LIT (KGetAppIdWithEmbeddability, "SELECT DISTINCT AppUid from AppRegistrationInfo where Embeddable IN(1,2)"); |
|
3791 stmt1 = iDbHandle->PrepareStatementLC(KGetAppIdWithEmbeddability); |
|
3792 aSubsessionContext->iApps.Close(); |
|
3793 while(stmt1->ProcessNextRowL()) |
|
3794 { |
|
3795 TAppUidWithLocaleInfo appUidWithLocaleInfo; |
|
3796 appUidWithLocaleInfo.iAppUid = TUid::Uid(stmt1->IntColumnL(0)); |
|
3797 appUidWithLocaleInfo.iLocale = KUnspecifiedLocale; |
|
3798 GetNearestAppLanguageL(aSubsessionContext->iLocale, appUidWithLocaleInfo.iAppUid, appUidWithLocaleInfo.iLocale); |
|
3799 if(aScreenModePresent) |
|
3800 { |
|
3801 if(DoesAppWithScreenModeExistL(appUidWithLocaleInfo.iAppUid, aSubsessionContext->iScreenMode, appUidWithLocaleInfo.iLocale)) |
|
3802 { |
|
3803 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3804 } |
|
3805 } |
|
3806 else |
|
3807 { |
|
3808 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3809 } |
|
3810 } |
|
3811 CleanupStack::PopAndDestroy(stmt1); |
|
3812 } |
|
3813 |
|
3814 |
|
3815 void CScrRequestImpl::GetServerAppUidsL(CAppInfoViewSubsessionContext* aSubsessionContext, TUid aServiceUid, TBool aScreenModePresent) const |
|
3816 { |
|
3817 CStatement *stmt1; |
|
3818 _LIT(KSelectAppUidForServiceId,"SELECT DISTINCT AppUid from ServiceInfo where Uid = ?"); |
|
3819 stmt1 = iDbHandle->PrepareStatementLC(KSelectAppUidForServiceId); |
|
3820 stmt1->BindIntL(1, aServiceUid.iUid); |
|
3821 aSubsessionContext->iApps.Close(); |
|
3822 while(stmt1->ProcessNextRowL()) |
|
3823 { |
|
3824 TAppUidWithLocaleInfo appUidWithLocaleInfo; |
|
3825 appUidWithLocaleInfo.iAppUid = TUid::Uid(stmt1->IntColumnL(0)); |
|
3826 appUidWithLocaleInfo.iLocale = KUnspecifiedLocale; |
|
3827 GetNearestAppLanguageL(aSubsessionContext->iLocale, appUidWithLocaleInfo.iAppUid, appUidWithLocaleInfo.iLocale); |
|
3828 if(aScreenModePresent) |
|
3829 { |
|
3830 if(DoesAppWithScreenModeExistL(appUidWithLocaleInfo.iAppUid, aSubsessionContext->iScreenMode, appUidWithLocaleInfo.iLocale)) |
|
3831 { |
|
3832 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3833 } |
|
3834 } |
|
3835 else |
|
3836 { |
|
3837 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3838 } |
|
3839 } |
|
3840 CleanupStack::PopAndDestroy(stmt1); |
|
3841 } |
|
3842 |
|
3843 void CScrRequestImpl::GetAppUidsWithEmbeddabilityFilterL(CAppInfoViewSubsessionContext* aSubsessionContext, TEmbeddableFilter& aFilter, TBool aScreenModePresent) const |
|
3844 { |
|
3845 CStatement *stmt1; |
|
3846 TApplicationCharacteristics::TAppEmbeddability embeddability; |
|
3847 _LIT(KSelectAppUidForServiceId,"SELECT DISTINCT AppUid,Embeddable from AppRegistrationInfo"); |
|
3848 stmt1 = iDbHandle->PrepareStatementLC(KSelectAppUidForServiceId); |
|
3849 aSubsessionContext->iApps.Close(); |
|
3850 while(stmt1->ProcessNextRowL()) |
|
3851 { |
|
3852 embeddability = (TApplicationCharacteristics::TAppEmbeddability)stmt1->IntColumnL(1); |
|
3853 if(aFilter.MatchesEmbeddability(embeddability)) |
|
3854 { |
|
3855 TAppUidWithLocaleInfo appUidWithLocaleInfo; |
|
3856 appUidWithLocaleInfo.iAppUid = TUid::Uid(stmt1->IntColumnL(0)); |
|
3857 appUidWithLocaleInfo.iLocale = KUnspecifiedLocale; |
|
3858 GetNearestAppLanguageL(aSubsessionContext->iLocale, appUidWithLocaleInfo.iAppUid, appUidWithLocaleInfo.iLocale); |
|
3859 if(aScreenModePresent) |
|
3860 { |
|
3861 if(DoesAppWithScreenModeExistL(appUidWithLocaleInfo.iAppUid, aSubsessionContext->iScreenMode, appUidWithLocaleInfo.iLocale)) |
|
3862 { |
|
3863 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3864 } |
|
3865 } |
|
3866 else |
|
3867 { |
|
3868 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3869 } |
|
3870 } |
|
3871 else |
|
3872 continue; |
|
3873 } |
|
3874 CleanupStack::PopAndDestroy(stmt1); |
|
3875 } |
|
3876 |
|
3877 void CScrRequestImpl::GetAppUidsWithCapabilityMaskAndValueL(CAppInfoViewSubsessionContext* aSubsessionContext,TUint aCapabilityAttrFilterMask, TUint aCapabilityAttrFilterValue, TBool aScreenModePresent) const |
|
3878 { |
|
3879 CStatement *stmt1; |
|
3880 TUint attributes; |
|
3881 _LIT(KSelectAppUidForServiceId,"SELECT DISTINCT AppUid,Attributes from AppRegistrationInfo"); |
|
3882 stmt1 = iDbHandle->PrepareStatementLC(KSelectAppUidForServiceId); |
|
3883 aSubsessionContext->iApps.Close(); |
|
3884 while(stmt1->ProcessNextRowL()) |
|
3885 { |
|
3886 attributes = stmt1->IntColumnL(1); |
|
3887 if(((attributes & aCapabilityAttrFilterMask) == (aCapabilityAttrFilterValue & aCapabilityAttrFilterMask))) |
|
3888 { |
|
3889 TAppUidWithLocaleInfo appUidWithLocaleInfo; |
|
3890 appUidWithLocaleInfo.iAppUid = TUid::Uid(stmt1->IntColumnL(0)); |
|
3891 appUidWithLocaleInfo.iLocale = KUnspecifiedLocale; |
|
3892 GetNearestAppLanguageL(aSubsessionContext->iLocale, appUidWithLocaleInfo.iAppUid, appUidWithLocaleInfo.iLocale); |
|
3893 if(aScreenModePresent) |
|
3894 { |
|
3895 if(DoesAppWithScreenModeExistL(appUidWithLocaleInfo.iAppUid, aSubsessionContext->iScreenMode, appUidWithLocaleInfo.iLocale)) |
|
3896 { |
|
3897 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3898 } |
|
3899 } |
|
3900 else |
|
3901 { |
|
3902 aSubsessionContext->iApps.AppendL(appUidWithLocaleInfo); |
|
3903 } |
|
3904 } |
|
3905 else |
|
3906 continue; |
|
3907 } |
|
3908 CleanupStack::PopAndDestroy(stmt1); |
|
3909 } |
|
3910 |
|
3911 void CScrRequestImpl::GetLocalesForAppIdL(RArray<TInt>& aLocales, TUid aAppUid) const |
|
3912 { |
|
3913 _LIT(KAllLocales," SELECT Locale from LocalizableAppInfo where AppUid = ? ORDER BY Locale"); |
|
3914 CStatement* stmt = iDbHandle->PrepareStatementLC(KAllLocales); |
|
3915 stmt->BindIntL(1, aAppUid.iUid); |
|
3916 aLocales.Close(); |
|
3917 while(stmt->ProcessNextRowL()) |
|
3918 { |
|
3919 aLocales.Append(stmt->IntColumnL(0)); |
|
3920 } |
|
3921 CleanupStack::PopAndDestroy(1,stmt); |
|
3922 } |
|
3923 |
|
3924 CStatement* CScrRequestImpl::CreateStatementForAppInfoL(const TDesC& aStatement, TLanguage aLocale, TInt aValuesNum,...) const |
|
3925 { |
|
3926 VA_LIST argList; |
|
3927 VA_START(argList, aValuesNum); |
|
3928 |
|
3929 CStatement *stmt = iDbHandle->PrepareStatementLC(aStatement); |
|
3930 BindStatementValuesL(*stmt, aLocale,aValuesNum, argList); |
|
3931 CleanupStack::Pop(stmt); |
|
3932 return stmt; |
|
3933 } |
|
3934 |
|
3935 CAppInfoFilter* CScrRequestImpl::ReadAppInfoFilterL(const RMessage2& aMessage) const |
|
3936 { |
|
3937 CAppInfoFilter *filter = ReadObjectFromMessageLC<CAppInfoFilter>(aMessage, 0); |
|
3938 CleanupStack::Pop(filter); |
|
3939 return filter; |
|
3940 } |
|
3941 |
|
3942 void CScrRequestImpl::OpenAppInfoViewL(CAppInfoFilter& aFilter, CAppInfoViewSubsessionContext* aSubsessionContext) |
|
3943 { |
|
3944 DEBUG_PRINTF(_L8("Opening App Info View.")); |
|
3945 switch(aFilter.iSetFlag) |
|
3946 { |
|
3947 |
|
3948 case CAppInfoFilter::EAllApps: |
|
3949 { |
|
3950 GetAppUidsL(aSubsessionContext); |
|
3951 break; |
|
3952 } |
|
3953 case CAppInfoFilter::EAllAppsWithScreenMode: |
|
3954 { |
|
3955 aSubsessionContext->iScreenMode = aFilter.iScreenMode; |
|
3956 GetAppUidsL(aSubsessionContext, ETrue); |
|
3957 break; |
|
3958 } |
|
3959 |
|
3960 case CAppInfoFilter::EGetEmbeddableApps: |
|
3961 { |
|
3962 GetEmbeddableAppUidsL(aSubsessionContext); |
|
3963 break; |
|
3964 } |
|
3965 |
|
3966 case CAppInfoFilter::EGetEmbeddableAppsWithSreenMode: |
|
3967 { |
|
3968 aSubsessionContext->iScreenMode = aFilter.iScreenMode; |
|
3969 GetEmbeddableAppUidsL(aSubsessionContext, ETrue); |
|
3970 break; |
|
3971 } |
|
3972 |
|
3973 case CAppInfoFilter::EGetFilteredAppsWithEmbeddabilityFilter: |
|
3974 { |
|
3975 GetAppUidsWithEmbeddabilityFilterL(aSubsessionContext, aFilter.iEmbeddabilityFilter); |
|
3976 break; |
|
3977 } |
|
3978 |
|
3979 case CAppInfoFilter::EGetFilteredAppsWithEmbeddabilityFilterWithScreenMode: |
|
3980 { |
|
3981 aSubsessionContext->iScreenMode = aFilter.iScreenMode; |
|
3982 GetAppUidsWithEmbeddabilityFilterL(aSubsessionContext, aFilter.iEmbeddabilityFilter, ETrue); |
|
3983 break; |
|
3984 } |
|
3985 |
|
3986 case CAppInfoFilter::EGetFilteredAppsWithCapabilityMaskAndValue: |
|
3987 { |
|
3988 GetAppUidsWithCapabilityMaskAndValueL(aSubsessionContext,aFilter.iCapabilityAttributeMask,aFilter.iCapabilityAttributeValue); |
|
3989 break; |
|
3990 } |
|
3991 |
|
3992 case CAppInfoFilter::EGetFilteredAppsWithCapabilityMaskAndValueWithScreenMode: |
|
3993 { |
|
3994 aSubsessionContext->iScreenMode = aFilter.iScreenMode; |
|
3995 GetAppUidsWithCapabilityMaskAndValueL(aSubsessionContext,aFilter.iCapabilityAttributeMask,aFilter.iCapabilityAttributeValue, ETrue); |
|
3996 break; |
|
3997 } |
|
3998 case CAppInfoFilter::EGetServerApps: |
|
3999 { |
|
4000 GetServerAppUidsL(aSubsessionContext, aFilter.iServiceUid); |
|
4001 break; |
|
4002 } |
|
4003 |
|
4004 case CAppInfoFilter::EGetServerAppsWithScreenMode: |
|
4005 { |
|
4006 aSubsessionContext->iScreenMode = aFilter.iScreenMode; |
|
4007 GetServerAppUidsL(aSubsessionContext, aFilter.iServiceUid, ETrue); |
|
4008 break; |
|
4009 } |
|
4010 |
|
4011 default: |
|
4012 User::Leave(KErrArgument); |
|
4013 } |
|
4014 |
|
4015 } |
|
4016 |
|
4017 void CScrRequestImpl::NextAppInfoSizeL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo, CAppInfoViewSubsessionContext* aSubsessionContext) |
|
4018 { |
|
4019 while(1) |
|
4020 { |
|
4021 if(aSubsessionContext->iAppInfoIndex < aSubsessionContext->iApps.Count()) |
|
4022 { |
|
4023 TBool isPresent = EFalse; |
|
4024 aAppInfo = new(ELeave) TAppRegInfo; |
|
4025 aAppInfo->iUid = (aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex]).iAppUid; |
|
4026 |
|
4027 _LIT(KSelectAppFilename, "SELECT AppFile FROM AppRegistrationInfo WHERE AppUid=?;"); |
|
4028 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppFilename); |
|
4029 stmt->BindIntL(1, aAppInfo->iUid.iUid); |
|
4030 if(stmt->ProcessNextRowL()) |
|
4031 { |
|
4032 isPresent = ETrue; |
|
4033 aAppInfo->iFullName = stmt->StrColumnL(0); |
|
4034 } |
|
4035 CleanupStack::PopAndDestroy(stmt); |
|
4036 if(isPresent) |
|
4037 { |
|
4038 if((aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex]).iLocale != KUnspecifiedLocale) |
|
4039 { |
|
4040 GetCaptionAndShortCaptionInfoForLocaleL(aAppInfo->iUid, aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex].iLocale, aAppInfo->iShortCaption, aAppInfo->iCaption); |
|
4041 } |
|
4042 aSubsessionContext->iAppInfoIndex++; |
|
4043 WriteObjectSizeL(aMessage, 1, aAppInfo); |
|
4044 break; |
|
4045 } |
|
4046 else |
|
4047 { |
|
4048 DeleteObjectZ(aAppInfo); |
|
4049 aSubsessionContext->iAppInfoIndex++; |
|
4050 } |
|
4051 } |
|
4052 else |
|
4053 { |
|
4054 break; |
|
4055 } |
|
4056 } |
|
4057 } |
|
4058 |
|
4059 void CScrRequestImpl::NextAppInfoDataL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo) |
|
4060 { |
|
4061 DEBUG_PRINTF(_L8("Returning the AppInfo data.")); |
|
4062 WriteObjectDataL(aMessage, 0, aAppInfo); |
|
4063 DeleteObjectZ(aAppInfo); // Delete the object to prevent it to be resent. |
|
4064 aAppInfo = NULL; |
|
4065 } |
|
4066 |
|
4067 void CScrRequestImpl::AddApplicationEntryL(const RMessage2& aMessage) |
|
4068 { |
|
4069 DEBUG_PRINTF(_L8("Adding the application details into SCR")); |
|
4070 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
4071 CApplicationRegistrationData *regInfo = ReadObjectFromMessageLC<CApplicationRegistrationData>(aMessage, 1); |
|
4072 |
|
4073 TSecureId clientSid = aMessage.SecureId(); |
|
4074 TUint32 swTypeId = 0; |
|
4075 if (componentId == 0 && clientSid == KSisRegistryServerSid) |
|
4076 { |
|
4077 swTypeId = HashCaseSensitiveL(Usif::KSoftwareTypeNative); |
|
4078 } |
|
4079 else |
|
4080 { |
|
4081 // Applicaiton is always associated with a component. We use the SoftwareTypeId of the |
|
4082 // component as the ApplicationTypeId. |
|
4083 swTypeId = GetSoftwareTypeForComponentL(componentId); |
|
4084 } |
|
4085 |
|
4086 |
|
4087 _LIT(KInsertAppRegistrationInfo,"INSERT INTO AppRegistrationInfo(AppUid, ComponentId, AppFile, TypeId, Attributes, Hidden, Embeddable, NewFile, Launch, GroupName, DefaultScreenNumber) VALUES(?,?,?,?,?,?,?,?,?,?,?);"); |
|
4088 TInt numberOfValues = 11; |
|
4089 ExecuteStatementL(KInsertAppRegistrationInfo(), numberOfValues, EValueInteger, regInfo->AppUid(), EValueInteger, componentId, EValueString, &(regInfo->AppFile()), EValueInteger, swTypeId, EValueInteger, regInfo->Attributes(), EValueInteger, regInfo->Hidden(), EValueInteger, regInfo->Embeddability(), EValueInteger, regInfo->NewFile(), EValueInteger, regInfo->Launch(), EValueString, &(regInfo->GroupName()), EValueInteger, regInfo->DefaultScreenNumber()); |
|
4090 |
|
4091 RPointerArray<HBufC> ownedFileArray = regInfo->OwnedFileArray(); |
|
4092 for(TInt i=0;i<ownedFileArray.Count();++i) |
|
4093 { |
|
4094 AddFileOwnershipInfoL(regInfo->AppUid(),*(ownedFileArray[i])); |
|
4095 } |
|
4096 |
|
4097 RPointerArray<CServiceInfo> serviceArray = regInfo->ServiceArray(); |
|
4098 for(TInt i=0;i<serviceArray.Count();++i) |
|
4099 { |
|
4100 AddServiceInfoL(regInfo->AppUid(),serviceArray[i]); |
|
4101 } |
|
4102 |
|
4103 RPointerArray<CLocalizableAppInfo> localizableAppInfo = regInfo->LocalizableAppInfoList(); |
|
4104 for(TInt i=0;i<localizableAppInfo.Count();++i) |
|
4105 { |
|
4106 AddLocalizableAppInfoL(regInfo->AppUid(), localizableAppInfo[i]); |
|
4107 } |
|
4108 |
|
4109 RPointerArray<CPropertyEntry> appPropertiesList = regInfo->AppProperties(); |
|
4110 for(TInt i=0;i<appPropertiesList.Count();++i) |
|
4111 { |
|
4112 AddPropertyL(regInfo->AppUid(), appPropertiesList[i]); |
|
4113 } |
|
4114 |
|
4115 RPointerArray<COpaqueData> opaqueDataList = regInfo->AppOpaqueData(); |
|
4116 for (TInt i = 0; i < opaqueDataList.Count(); ++i) |
|
4117 { |
|
4118 AddOpaqueDataL(regInfo->AppUid(), opaqueDataList[i]); |
|
4119 } |
|
4120 |
|
4121 CleanupStack::PopAndDestroy(regInfo); |
|
4122 DEBUG_PRINTF(_L8("Added the application details into SCR successfully ")); |
|
4123 } |
|
4124 |
|
4125 void CScrRequestImpl::AddFileOwnershipInfoL(TUid aAppUid, const TDesC& aFileName) |
|
4126 { |
|
4127 DEBUG_PRINTF(_L8("Adding the File Ownership Info details into SCR")); |
|
4128 if(aAppUid == KNullUid || !aFileName.CompareF(KNullDesC())) |
|
4129 { |
|
4130 DEBUG_PRINTF(_L8("Mandatory values not provided.")); |
|
4131 User::Leave(KErrArgument); |
|
4132 } |
|
4133 |
|
4134 _LIT(KInsertFileOwnershipInfo,"INSERT INTO FileOwnershipInfo(AppUid, FileName) VALUES(?,?);"); |
|
4135 TInt numberOfValues = 2; |
|
4136 ExecuteStatementL(KInsertFileOwnershipInfo(), numberOfValues, EValueInteger, aAppUid, EValueString, &aFileName); |
|
4137 } |
|
4138 |
|
4139 void CScrRequestImpl::AddLocalizableAppInfoL(TUid aAppUid, Usif::CLocalizableAppInfo* aLocalizableAppInfoEntry) |
|
4140 { |
|
4141 DEBUG_PRINTF(_L8("Adding the Localizable App Info details into SCR")); |
|
4142 TInt captionAndIconInfoId = 0; |
|
4143 if(NULL != aLocalizableAppInfoEntry->iCaptionAndIconInfo) |
|
4144 { |
|
4145 captionAndIconInfoId = AddCaptionAndIconInfoL(aLocalizableAppInfoEntry->iCaptionAndIconInfo); |
|
4146 } |
|
4147 _LIT(KInsertLocalizableAppInfo,"INSERT INTO LocalizableAppInfo(AppUid, ShortCaption, GroupName, Locale, CaptionAndIconId) VALUES(?,?,?,?,?);"); |
|
4148 TInt numberOfValues = 5; |
|
4149 ExecuteStatementL(KInsertLocalizableAppInfo(), numberOfValues, EValueInteger, aAppUid, EValueString, &(aLocalizableAppInfoEntry->ShortCaption()), EValueString, &(aLocalizableAppInfoEntry->GroupName()), EValueInteger, aLocalizableAppInfoEntry->ApplicationLanguage(), EValueInteger, captionAndIconInfoId); |
|
4150 TInt localAppInfoId = iDbHandle->LastInsertedIdL(); |
|
4151 RPointerArray<CAppViewData> viewDataList = aLocalizableAppInfoEntry->ViewDataList(); |
|
4152 for (TInt i=0;i<viewDataList.Count();i++) |
|
4153 { |
|
4154 AddViewDataL(localAppInfoId, viewDataList[i]); |
|
4155 } |
|
4156 } |
|
4157 |
|
4158 void CScrRequestImpl::AddViewDataL(TInt aLocalAppInfoId, Usif::CAppViewData* aViewDataEntry) |
|
4159 { |
|
4160 DEBUG_PRINTF(_L8("Adding the ViewData details into SCR")); |
|
4161 if(aLocalAppInfoId == 0 || aViewDataEntry->Uid() == KNullUid ) |
|
4162 { |
|
4163 DEBUG_PRINTF(_L8("Mandatory values not provided.")); |
|
4164 User::Leave(KErrArgument); |
|
4165 } |
|
4166 |
|
4167 TInt captionAndIconInfoId = 0; |
|
4168 if(NULL != aViewDataEntry->iCaptionAndIconInfo) |
|
4169 { |
|
4170 captionAndIconInfoId = AddCaptionAndIconInfoL(aViewDataEntry->iCaptionAndIconInfo); |
|
4171 } |
|
4172 |
|
4173 _LIT(KInsertViewData,"INSERT INTO ViewData(LocalAppInfoId, Uid, ScreenMode, CaptionAndIconId) VALUES(?,?,?,?);"); |
|
4174 TInt numberOfValues = 4; |
|
4175 ExecuteStatementL(KInsertViewData(), numberOfValues, EValueInteger, aLocalAppInfoId, EValueInteger, aViewDataEntry->Uid(), EValueInteger, aViewDataEntry->ScreenMode(), EValueInteger, captionAndIconInfoId); |
|
4176 } |
|
4177 |
|
4178 TInt CScrRequestImpl::AddCaptionAndIconInfoL(Usif::CCaptionAndIconInfo* aCaptionAndIconEntry) |
|
4179 { |
|
4180 DEBUG_PRINTF(_L8("Adding the Caption And Icon Info details into SCR")); |
|
4181 _LIT(KCaptionAndIconInfo,"INSERT INTO CaptionAndIconInfo(Caption, NumberOfIcons, IconFile) VALUES(?,?,?);"); |
|
4182 TInt numberOfValues = 3; |
|
4183 ExecuteStatementL(KCaptionAndIconInfo(), numberOfValues, EValueString, &(aCaptionAndIconEntry->Caption()), EValueInteger, aCaptionAndIconEntry->NumOfAppIcons(), EValueString, &(aCaptionAndIconEntry->IconFileName())); |
|
4184 return iDbHandle->LastInsertedIdL(); |
|
4185 } |
|
4186 |
|
4187 void CScrRequestImpl::AddServiceInfoL(TUid aAppUid, Usif::CServiceInfo* aAppServiceInfoEntry) |
|
4188 { |
|
4189 DEBUG_PRINTF(_L8("Adding the Service Info details into SCR")); |
|
4190 if(aAppUid == KNullUid) |
|
4191 { |
|
4192 DEBUG_PRINTF(_L8("Values for app uid is absent")); |
|
4193 User::Leave(KErrArgument); |
|
4194 } |
|
4195 _LIT(KInsertServiceInfo,"INSERT INTO ServiceInfo(AppUid, Uid) VALUES(?,?);"); |
|
4196 TInt numberOfValues = 2; |
|
4197 |
|
4198 ExecuteStatementL(KInsertServiceInfo(), numberOfValues, EValueInteger, aAppUid, EValueInteger, aAppServiceInfoEntry->Uid()); |
|
4199 TInt serviceId = iDbHandle->LastInsertedIdL(); |
|
4200 |
|
4201 RPointerArray<Usif::COpaqueData> opaqueData = aAppServiceInfoEntry->OpaqueData(); |
|
4202 for(TInt i=0;i<opaqueData.Count();i++) |
|
4203 { |
|
4204 AddOpaqueDataL(aAppUid, opaqueData[i], aAppServiceInfoEntry->Uid()); |
|
4205 } |
|
4206 |
|
4207 RPointerArray<Usif::CDataType> dataTypes = aAppServiceInfoEntry->DataTypes(); |
|
4208 for (TInt i=0;i<dataTypes.Count();i++) |
|
4209 { |
|
4210 AddServiceDataTypeL(serviceId, dataTypes[i]); |
|
4211 } |
|
4212 } |
|
4213 |
|
4214 void CScrRequestImpl::AddServiceDataTypeL(TInt aServiceUid, Usif::CDataType* aDataTypeEntry) |
|
4215 { |
|
4216 DEBUG_PRINTF(_L8("Adding the Service Data Type details into SCR")); |
|
4217 if(!((aDataTypeEntry->Type()).CompareF(KNullDesC()))) |
|
4218 { |
|
4219 DEBUG_PRINTF(_L8("Values for service uid or type is absent")); |
|
4220 User::Leave(KErrArgument); |
|
4221 } |
|
4222 _LIT(KInsertServiceDataTypeInfo,"INSERT INTO DataType(ServiceId, Priority, Type) VALUES(?,?,?);"); |
|
4223 TInt numberOfValues = 3; |
|
4224 ExecuteStatementL(KInsertServiceDataTypeInfo(), numberOfValues, EValueInteger, aServiceUid, EValueInteger, aDataTypeEntry->Priority() , EValueString, &(aDataTypeEntry->Type())); |
|
4225 } |
|
4226 |
|
4227 void CScrRequestImpl::AddPropertyL(TUid aAppUid, Usif::CPropertyEntry* aAppPropertiesEntry) |
|
4228 { |
|
4229 DEBUG_PRINTF(_L8("Adding the Property details into SCR")); |
|
4230 if(aAppUid == KNullUid || !((aAppPropertiesEntry->PropertyName().CompareF(KNullDesC())))) |
|
4231 { |
|
4232 DEBUG_PRINTF(_L8("Property name is absent and hence cannot be entered into the DB.")); |
|
4233 User::Leave(KErrArgument); |
|
4234 } |
|
4235 _LIT(KInsertAppProperties, "INSERT INTO AppProperties(AppUid, %S;"); |
|
4236 _LIT(KPropertyIntValue," Name, IntValue) VALUES(?,?,?)"); |
|
4237 _LIT(KPropertyStrValue," Locale, Name, StrValue) VALUES(?,?,?,?)"); |
|
4238 _LIT(KPropertyBinaryValue," Name, StrValue, IsStr8Bit) VALUES(?,?,?,1)"); |
|
4239 |
|
4240 HBufC *statementStr(0); |
|
4241 CStatement *stmt ; |
|
4242 |
|
4243 switch(aAppPropertiesEntry->PropertyType()) |
|
4244 { |
|
4245 case CPropertyEntry::EIntProperty: |
|
4246 { |
|
4247 statementStr = FormatStatementLC(KInsertAppProperties, KPropertyIntValue().Length(), &KPropertyIntValue()); |
|
4248 stmt = iDbHandle->PrepareStatementLC(*statementStr); |
|
4249 CIntPropertyEntry *intProp = static_cast<CIntPropertyEntry *>(aAppPropertiesEntry); |
|
4250 stmt->BindIntL(1, aAppUid.iUid); |
|
4251 stmt->BindStrL(2, intProp->PropertyName()); |
|
4252 stmt->BindInt64L(3, intProp->Int64Value()); |
|
4253 stmt->ExecuteStatementL(); |
|
4254 CleanupStack::PopAndDestroy(2,statementStr); |
|
4255 } |
|
4256 break; |
|
4257 case CPropertyEntry::ELocalizedProperty: |
|
4258 { |
|
4259 statementStr = FormatStatementLC(KInsertAppProperties, KPropertyStrValue().Length(), &KPropertyStrValue()); |
|
4260 stmt = iDbHandle->PrepareStatementLC(*statementStr); |
|
4261 CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aAppPropertiesEntry); |
|
4262 stmt->BindIntL(1, aAppUid.iUid); |
|
4263 stmt->BindIntL(2, localizedProp->LocaleL()); |
|
4264 stmt->BindStrL(3, localizedProp->PropertyName()); |
|
4265 stmt->BindStrL(4, localizedProp->StrValue()); |
|
4266 stmt->ExecuteStatementL(); |
|
4267 CleanupStack::PopAndDestroy(2,statementStr); |
|
4268 } |
|
4269 break; |
|
4270 case CPropertyEntry::EBinaryProperty: |
|
4271 { |
|
4272 statementStr = FormatStatementLC(KInsertAppProperties, KPropertyBinaryValue().Length(), &KPropertyBinaryValue()); |
|
4273 stmt = iDbHandle->PrepareStatementLC(*statementStr); |
|
4274 CBinaryPropertyEntry *binaryProp = static_cast<CBinaryPropertyEntry *>(aAppPropertiesEntry); |
|
4275 stmt->BindIntL(1, aAppUid.iUid); |
|
4276 stmt->BindStrL(2, binaryProp->PropertyName()); |
|
4277 stmt->BindBinaryL(3, binaryProp->BinaryValue()); |
|
4278 stmt->ExecuteStatementL(); |
|
4279 CleanupStack::PopAndDestroy(2,statementStr); |
|
4280 } |
|
4281 break; |
|
4282 |
|
4283 default: |
|
4284 DEBUG_PRINTF(_L8("The property type couldn't be recognized.")); |
|
4285 User::Leave(KErrAbort); |
|
4286 } |
|
4287 } |
|
4288 |
|
4289 void CScrRequestImpl::AddOpaqueDataL(TUid aAppUid, Usif::COpaqueData* aOpaqueDataEntry, TUid aServiceUid) |
|
4290 { |
|
4291 DEBUG_PRINTF(_L8("Adding the Opaque Data details into SCR")); |
|
4292 const TInt KMaxOpaqueDataLength = 4096; |
|
4293 /* AppUid cannot be NULL since this function is invoked from AddApplicationEntryL */ |
|
4294 __ASSERT_DEBUG(aAppUid != TUid::Null(), User::Leave(KErrArgument)); |
|
4295 |
|
4296 _LIT(KOpaqueDataEntry, "INSERT INTO AppProperties(AppUid, Name, Locale, ServiceUid, StrValue, IsStr8Bit) VALUES(?,?,?,?,?,1)"); |
|
4297 |
|
4298 CStatement *stmt = iDbHandle->PrepareStatementLC(KOpaqueDataEntry); |
|
4299 |
|
4300 stmt->BindIntL(1, aAppUid.iUid); |
|
4301 stmt->BindStrL(2, _L("OpaqueData")); |
|
4302 stmt->BindIntL(3, (TInt)aOpaqueDataEntry->iLanguage); |
|
4303 stmt->BindIntL(4, aServiceUid.iUid); |
|
4304 stmt->BindBinaryL(5, *(aOpaqueDataEntry->iOpaqueData), KMaxOpaqueDataLength); |
|
4305 stmt->ExecuteStatementL(); |
|
4306 CleanupStack::PopAndDestroy(stmt); |
|
4307 } |
|
4308 |
|
4309 void CScrRequestImpl::DeleteApplicationEntryInternalL(const TInt aAppUid) |
|
4310 { |
|
4311 TInt numberOfValues = 1; |
|
4312 |
|
4313 DeleteFromTableL(KFileOwnershipInfoTable,KAppIdColumnName,aAppUid); |
|
4314 |
|
4315 _LIT(KDeleteDataType, "DELETE FROM DataType WHERE ServiceId IN \ |
|
4316 (SELECT ServiceId FROM ServiceInfo WHERE AppUid=?);"); |
|
4317 ExecuteStatementL(KDeleteDataType, numberOfValues, EValueInteger, aAppUid); |
|
4318 DEBUG_PRINTF2(_L8("Service datatype details associated with application(%d) have been deleted."), aAppUid); |
|
4319 |
|
4320 DeleteFromTableL(KServiceInfoTable,KAppIdColumnName,aAppUid); |
|
4321 |
|
4322 RArray<TInt> viewId; |
|
4323 CleanupClosePushL(viewId); |
|
4324 DEBUG_PRINTF2(_L8("Deleting the LocalizableAppInfo details associated with application (%d)"), aAppUid); |
|
4325 _LIT(KSelectViewId, "SELECT ViewId FROM ViewData WHERE LocalAppInfoId IN(SELECT LocalAppInfoId FROM LocalizableAppInfo WHERE AppUid = ?);"); |
|
4326 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectViewId); |
|
4327 stmt->BindIntL(1, aAppUid); |
|
4328 viewId.Close(); |
|
4329 while(stmt->ProcessNextRowL()) |
|
4330 { |
|
4331 viewId.AppendL(stmt->IntColumnL(0)); |
|
4332 } |
|
4333 |
|
4334 _LIT(KViewId,"ViewId"); |
|
4335 _LIT(KDeleteCaptionAndIconInfoAssociatedToViewData, "DELETE FROM CaptionAndIconInfo WHERE CaptionAndIconId = (SELECT CaptionAndIconId FROM ViewData WHERE ViewId=?);"); |
|
4336 |
|
4337 for(TInt i=0; i< viewId.Count();i++) |
|
4338 { |
|
4339 ExecuteStatementL(KDeleteCaptionAndIconInfoAssociatedToViewData, numberOfValues, EValueInteger, viewId[i]); |
|
4340 DeleteFromTableL(KViewDataTable,KViewId,viewId[i]); |
|
4341 } |
|
4342 CleanupStack::PopAndDestroy(2, &viewId); |
|
4343 |
|
4344 _LIT(KDeleteCaptionAndIconInfo, "DELETE FROM CaptionAndIconInfo WHERE CaptionAndIconId IN \ |
|
4345 (SELECT CaptionAndIconId FROM LocalizableAppInfo WHERE AppUid=?);"); |
|
4346 ExecuteStatementL(KDeleteCaptionAndIconInfo, numberOfValues, EValueInteger, aAppUid); |
|
4347 |
|
4348 DeleteFromTableL(KLocalizableAppInfoTable,KAppIdColumnName,aAppUid); |
|
4349 |
|
4350 DeleteFromTableL(KAppPropertiesTable,KAppIdColumnName,aAppUid); |
|
4351 DeleteFromTableL(KAppRegistrationInfoTable,KAppIdColumnName,aAppUid); |
|
4352 |
|
4353 } |
|
4354 |
|
4355 void CScrRequestImpl::DeleteApplicationEntryL(const RMessage2& aMessage) |
|
4356 { |
|
4357 DEBUG_PRINTF(_L8("Deleting Application Entry details from SCR")); |
|
4358 TInt applicationUid = aMessage.Int0(); |
|
4359 DeleteApplicationEntryInternalL(applicationUid); |
|
4360 } |
|
4361 |
|
4362 void CScrRequestImpl::DeleteAllAppsWithinPackageL(const RMessage2& aMessage) |
|
4363 { |
|
4364 TComponentId componentId = GetComponentIdFromMsgL(aMessage); |
|
4365 TSecureId clientSid = aMessage.SecureId(); |
|
4366 if(componentId == 0 && clientSid != KSisRegistryServerSid) |
|
4367 { |
|
4368 DEBUG_PRINTF(_L8("ComponentId 0 corresponds to In-Rom Applications that cannot be deleted.")); |
|
4369 User::Leave(KErrNotSupported); |
|
4370 } |
|
4371 |
|
4372 DeleteAllAppsWithinPackageInternalL(componentId); |
|
4373 } |
|
4374 |
|
4375 void CScrRequestImpl::DeleteAllAppsWithinPackageInternalL(const TComponentId aComponentId) |
|
4376 { |
|
4377 DEBUG_PRINTF2(_L8("Deleting all the applications associated with component (%d) from SCR."), aComponentId); |
|
4378 |
|
4379 // Fetching all the applications associated with the component |
|
4380 _LIT(KSelectAssociatedAppIds, "SELECT AppUid FROM AppRegistrationInfo WHERE ComponentId=?;"); |
|
4381 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAssociatedAppIds); |
|
4382 stmt->BindIntL(1, aComponentId); |
|
4383 |
|
4384 while(stmt->ProcessNextRowL()) |
|
4385 { |
|
4386 TInt appId = stmt->IntColumnL(0); |
|
4387 DeleteApplicationEntryInternalL(appId); |
|
4388 } |
|
4389 |
|
4390 // Release allocated memories |
|
4391 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
4392 } |
|
4393 |
|
4394 void CScrRequestImpl::DeleteFromTableL(const TDesC& aTableName, const TDesC& aAttribute, const TInt aValue) |
|
4395 { |
|
4396 _LIT(KDeleteFromTable,"DELETE FROM %S WHERE %S=?;"); |
|
4397 TInt formattedLen = aTableName.Length() + aAttribute.Length(); |
|
4398 HBufC *statementStr = FormatStatementLC(KDeleteFromTable(), formattedLen, &aTableName, &aAttribute ); |
|
4399 TInt numberOfValues = 1; |
|
4400 ExecuteStatementL(*statementStr, numberOfValues, EValueInteger, aValue); |
|
4401 DEBUG_PRINTF4(_L8("%S info where %S = %d has been deleted."), &aTableName, &aAttribute, aValue); |
|
4402 CleanupStack::PopAndDestroy(statementStr); |
|
4403 } |
|
4404 |
|
4405 CCaptionAndIconInfo* CScrRequestImpl::GetCaptionAndIconInfoL(TInt aCaptionAndIconId) const |
|
4406 { |
|
4407 DEBUG_PRINTF2(_L8("Returning the Caption And Icon Info associated with CaptionAndIconId (%d) from SCR."), aCaptionAndIconId); |
|
4408 _LIT(KGetLocalizedCaptionAndIconInfo, "Select Caption,NumberOfIcons,Iconfile from CaptionAndIconInfo where CaptionAndIconId = ?"); |
|
4409 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetLocalizedCaptionAndIconInfo); |
|
4410 stmt->BindIntL(1, aCaptionAndIconId); |
|
4411 if(stmt->ProcessNextRowL()) |
|
4412 { |
|
4413 TPtrC caption(stmt->StrColumnL(0)); |
|
4414 TInt noOfAppIcons(stmt->IntColumnL(1)); |
|
4415 TPtrC iconFilename(stmt->StrColumnL(2)); |
|
4416 CCaptionAndIconInfo* captionandIconInfo = CCaptionAndIconInfo::NewL(caption, iconFilename, noOfAppIcons); |
|
4417 DEBUG_PRINTF2(_L("The Caption for this App is %S "), captionandIconInfo->iCaption); |
|
4418 DEBUG_PRINTF2(_L("The Number of AppIcons for this App is %d "), captionandIconInfo->iNumOfAppIcons); |
|
4419 DEBUG_PRINTF2(_L("The Icon File Name this App is %S "), captionandIconInfo->iIconFileName); |
|
4420 CleanupStack::PopAndDestroy(stmt); |
|
4421 return captionandIconInfo; |
|
4422 } |
|
4423 else |
|
4424 { |
|
4425 CleanupStack::PopAndDestroy(stmt); |
|
4426 return NULL; |
|
4427 } |
|
4428 } |
|
4429 |
|
4430 void CScrRequestImpl::GetViewsL(RPointerArray<Usif::CAppViewData>& aViewInfoArray, TUid aAppUid, TLanguage aLanguage) const |
|
4431 { |
|
4432 _LIT(KSelectViewDetailsWithAppUid, "SELECT Uid, ScreenMode, CaptionAndIconId FROM ViewData WHERE LocalAppInfoId IN(SELECT LocalAppInfoId FROM LocalizableAppInfo WHERE AppUid = ? AND Locale = ?);"); |
|
4433 CStatement *stmt1 = iDbHandle->PrepareStatementLC(KSelectViewDetailsWithAppUid); |
|
4434 stmt1->BindIntL(1, aAppUid.iUid); |
|
4435 stmt1->BindIntL(2, aLanguage); |
|
4436 aViewInfoArray.ResetAndDestroy(); |
|
4437 while(stmt1->ProcessNextRowL()) |
|
4438 { |
|
4439 TUid uid; |
|
4440 uid.iUid = stmt1->IntColumnL(0); |
|
4441 TInt screenMode(stmt1->IntColumnL(1)); |
|
4442 TInt captionAndIconId(stmt1->IntColumnL(2)); |
|
4443 DEBUG_PRINTF2(_L("The view Uid for this App is 0x%x "),uid.iUid); |
|
4444 DEBUG_PRINTF2(_L("The view Screen Mode for this App is %d "), screenMode); |
|
4445 CCaptionAndIconInfo *captionAndIconInfo = GetCaptionAndIconInfoL(captionAndIconId); |
|
4446 CAppViewData *viewdataInfo = CAppViewData::NewLC(uid, screenMode, captionAndIconInfo); |
|
4447 aViewInfoArray.AppendL(viewdataInfo); |
|
4448 CleanupStack::Pop(viewdataInfo); // viewdataInfo |
|
4449 } |
|
4450 CleanupStack::PopAndDestroy(1, stmt1); // stmt1 |
|
4451 } |
|
4452 |
|
4453 void CScrRequestImpl::GetViewSizeL(const RMessage2& aMessage, TUid aAppUid, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4454 { |
|
4455 GetViewsL(aSubsessionContext->iViewInfoArray,aAppUid,aSubsessionContext->iAppLanguageForCurrentLocale); |
|
4456 if(aSubsessionContext->iViewInfoArray.Count() == 0) |
|
4457 { |
|
4458 DEBUG_PRINTF2(_L8("No view details associated with the given AppUid,%d"),aAppUid); |
|
4459 } |
|
4460 DEBUG_PRINTF2(_L8("Returning the view details' entry size of application(0x%x) for the current locale."), aAppUid); |
|
4461 WriteArraySizeL(aMessage, 1, aSubsessionContext->iViewInfoArray); |
|
4462 } |
|
4463 |
|
4464 void CScrRequestImpl::GetViewDataL(const RMessage2& aMessage, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4465 { |
|
4466 DEBUG_PRINTF(_L8("Returning the localized information entry data.")); |
|
4467 WriteArrayDataL(aMessage, 0, aSubsessionContext->iViewInfoArray); |
|
4468 aSubsessionContext->iViewInfoArray.ResetAndDestroy(); |
|
4469 } |
|
4470 |
|
4471 void CScrRequestImpl::OpenApplicationRegistrationViewL(const RMessage2& aMessage, CAppRegistrySubsessionContext* aSubsessionContext) |
|
4472 { |
|
4473 TLanguage requiredLanguage = TLanguage(aMessage.Int0()); |
|
4474 if(requiredLanguage == KUnspecifiedLocale) |
|
4475 { |
|
4476 requiredLanguage = User::Language(); |
|
4477 } |
|
4478 aSubsessionContext->iLanguage = requiredLanguage; |
|
4479 |
|
4480 CStatement* stmt; |
|
4481 _LIT(KAllAppIds," SELECT AppUid from AppRegistrationInfo"); |
|
4482 stmt = iDbHandle->PrepareStatementLC(KAllAppIds); |
|
4483 aSubsessionContext->iAppUids.Close(); |
|
4484 while(stmt->ProcessNextRowL()) |
|
4485 { |
|
4486 TUid appUid = TUid::Uid(stmt->IntColumnL(0)); |
|
4487 TComponentId componentId(0); |
|
4488 if(GetComponentIdForAppInternalL(appUid, componentId)) |
|
4489 { |
|
4490 if(!componentId || IsComponentPresentL(componentId)) |
|
4491 { |
|
4492 aSubsessionContext->iAppUids.AppendL(appUid); |
|
4493 } |
|
4494 } |
|
4495 } |
|
4496 CleanupStack::PopAndDestroy(stmt); |
|
4497 } |
|
4498 |
|
4499 void CScrRequestImpl::OpenApplicationRegistrationForAppUidsViewL(const RMessage2& aMessage, CAppRegistrySubsessionContext* aSubsessionContext) |
|
4500 { |
|
4501 TLanguage requiredLanguage = TLanguage(aMessage.Int0()); |
|
4502 if(requiredLanguage == KUnspecifiedLocale) |
|
4503 { |
|
4504 requiredLanguage = User::Language(); |
|
4505 } |
|
4506 aSubsessionContext->iLanguage = requiredLanguage; |
|
4507 |
|
4508 //Read languages need to pass |
|
4509 TInt bufSize=0; |
|
4510 bufSize = aMessage.GetDesMaxLength(1); |
|
4511 HBufC8* bufToHoldAppUids = HBufC8::NewLC(bufSize); |
|
4512 TPtr8 bufPtrDscToHoldAppUids = bufToHoldAppUids->Des(); |
|
4513 aMessage.ReadL(1, bufPtrDscToHoldAppUids); |
|
4514 RDesReadStream inStream(bufPtrDscToHoldAppUids); |
|
4515 CleanupClosePushL(inStream); |
|
4516 TInt size = inStream.ReadInt32L(); |
|
4517 |
|
4518 aSubsessionContext->iAppUids.Close(); |
|
4519 for (TInt i =0; i<size ;i++) |
|
4520 { |
|
4521 TUid appUid = TUid::Uid(inStream.ReadInt32L()); |
|
4522 TComponentId componentId(0); |
|
4523 if(GetComponentIdForAppInternalL(appUid, componentId)) // Check for application presence and fetch the corresponding ComponentId |
|
4524 { |
|
4525 if(!componentId || IsComponentPresentL(componentId)) // Check if the component is present |
|
4526 { |
|
4527 aSubsessionContext->iAppUids.AppendL(appUid); |
|
4528 } |
|
4529 } |
|
4530 } |
|
4531 |
|
4532 CleanupStack::PopAndDestroy(2,bufToHoldAppUids); //bufToHoldAppUids, inStream |
|
4533 } |
|
4534 |
|
4535 TBool CScrRequestImpl::GetApplicationRegistrationInfoL(CApplicationRegistrationData& aApplicationRegistration,TUid aAppUid) const |
|
4536 { |
|
4537 _LIT(KSelectAppRegInfo, "SELECT AppUid, ComponentId, AppFile, TypeId, Attributes, Hidden, Embeddable, NewFile, Launch, GroupName, DefaultScreenNumber FROM AppRegistrationInfo WHERE AppUid = ?"); |
|
4538 |
|
4539 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppRegInfo); |
|
4540 stmt->BindIntL(1, aAppUid.iUid); |
|
4541 if(stmt->ProcessNextRowL()) |
|
4542 { |
|
4543 aApplicationRegistration.iAppUid = TUid::Uid(stmt->IntColumnL(0)); |
|
4544 HBufC* appFile = stmt->StrColumnL(2).AllocL(); |
|
4545 DeleteObjectZ(aApplicationRegistration.iAppFile); |
|
4546 aApplicationRegistration.iAppFile = appFile; |
|
4547 aApplicationRegistration.iTypeId = stmt->IntColumnL(3); |
|
4548 aApplicationRegistration.iCharacteristics.iAttributes = stmt->IntColumnL(4); |
|
4549 aApplicationRegistration.iCharacteristics.iAppIsHidden = stmt->IntColumnL(5); |
|
4550 aApplicationRegistration.iCharacteristics.iEmbeddability = (TApplicationCharacteristics::TAppEmbeddability)stmt->IntColumnL(6); |
|
4551 aApplicationRegistration.iCharacteristics.iSupportsNewFile = stmt->IntColumnL(7); |
|
4552 aApplicationRegistration.iCharacteristics.iLaunchInBackground = stmt->IntColumnL(8); |
|
4553 aApplicationRegistration.iCharacteristics.iGroupName = stmt->StrColumnL(9); |
|
4554 aApplicationRegistration.iDefaultScreenNumber = stmt->IntColumnL(10); |
|
4555 |
|
4556 DEBUG_PRINTF2(_L("The Uid for this App is 0x%x "),aApplicationRegistration.iAppUid); |
|
4557 DEBUG_PRINTF2(_L("The App File for this App is %S "), aApplicationRegistration.iAppFile); |
|
4558 DEBUG_PRINTF2(_L("The Attribute for this App is %d "), aApplicationRegistration.iCharacteristics.iAttributes); |
|
4559 DEBUG_PRINTF2(_L("The Hidden for this App is %d "), (aApplicationRegistration.iCharacteristics.iAppIsHidden)); |
|
4560 DEBUG_PRINTF2(_L("The Embeddability for this App is %d "), aApplicationRegistration.iCharacteristics.iEmbeddability); |
|
4561 DEBUG_PRINTF2(_L("The New File for this App is %d "), aApplicationRegistration.iCharacteristics.iSupportsNewFile); |
|
4562 DEBUG_PRINTF2(_L("The Launch for this App is %d "), aApplicationRegistration.iCharacteristics.iLaunchInBackground); |
|
4563 DEBUG_PRINTF2(_L("The Group Name for this App is %S "), &(aApplicationRegistration.iCharacteristics.iGroupName)); |
|
4564 DEBUG_PRINTF2(_L("The Default screen number for this App is %d "), aApplicationRegistration.iDefaultScreenNumber); |
|
4565 |
|
4566 } |
|
4567 else |
|
4568 { |
|
4569 DEBUG_PRINTF2(_L8("AppUid %d Not Found in the SCR"),aAppUid); |
|
4570 CleanupStack::PopAndDestroy(stmt); |
|
4571 return EFalse; |
|
4572 } |
|
4573 CleanupStack::PopAndDestroy(stmt); |
|
4574 return ETrue; |
|
4575 } |
|
4576 |
|
4577 void CScrRequestImpl::GetFileOwnershipInfoL(CApplicationRegistrationData& aApplicationRegistration,TUid aAppUid) const |
|
4578 { |
|
4579 _LIT(KGetFileOwnershipInfo, "SELECT FileName FROM FileOwnershipInfo WHERE AppUid = ?"); |
|
4580 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetFileOwnershipInfo); |
|
4581 stmt->BindIntL(1, aAppUid.iUid); |
|
4582 aApplicationRegistration.iOwnedFileArray.ResetAndDestroy(); |
|
4583 while(stmt->ProcessNextRowL()) |
|
4584 { |
|
4585 HBufC *fileName = stmt->StrColumnL(0).AllocLC(); |
|
4586 aApplicationRegistration.iOwnedFileArray.AppendL(fileName); |
|
4587 DEBUG_PRINTF2(_L("The File Name for owned Files for this App is %S "), fileName); |
|
4588 CleanupStack::Pop(); |
|
4589 } |
|
4590 CleanupStack::PopAndDestroy(stmt); |
|
4591 } |
|
4592 |
|
4593 |
|
4594 void CScrRequestImpl::GetDataTypesL(RPointerArray<Usif::CDataType>& aDataTypes,TInt aServiceId)const |
|
4595 { |
|
4596 _LIT(KGetDataType, "SELECT Priority, Type FROM DataType where ServiceId = ?"); |
|
4597 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetDataType); |
|
4598 stmt->BindIntL(1, aServiceId); |
|
4599 aDataTypes.ResetAndDestroy(); |
|
4600 while(stmt->ProcessNextRowL()) |
|
4601 { |
|
4602 Usif::CDataType* dataType = CDataType::NewLC(); |
|
4603 dataType->iPriority = stmt->IntColumnL(0); |
|
4604 DeleteObjectZ(dataType->iType); |
|
4605 dataType->iType = stmt->StrColumnL(1).AllocLC(); |
|
4606 DEBUG_PRINTF2(_L("The Service Info Priority for this App is %d "), dataType->iPriority); |
|
4607 DEBUG_PRINTF2(_L("The Service Type for this App is %S "), dataType->iType); |
|
4608 aDataTypes.AppendL(dataType); |
|
4609 CleanupStack::Pop(2,dataType); //for iType and dataType |
|
4610 } |
|
4611 CleanupStack::PopAndDestroy(stmt); |
|
4612 } |
|
4613 |
|
4614 void CScrRequestImpl::GetServiceInfoL(CApplicationRegistrationData& aApplicationRegistration, TUid aAppUid, TLanguage aLanguage) const |
|
4615 { |
|
4616 Usif::CServiceInfo* serviceInfo = NULL; |
|
4617 TInt serviceId = 0; |
|
4618 _LIT(KGetServiceInfo, "SELECT ServiceId, Uid FROM ServiceInfo where AppUid = ?"); |
|
4619 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetServiceInfo); |
|
4620 stmt->BindIntL(1, aAppUid.iUid); |
|
4621 aApplicationRegistration.iServiceArray.ResetAndDestroy(); |
|
4622 while(stmt->ProcessNextRowL()) |
|
4623 { |
|
4624 serviceInfo = Usif::CServiceInfo::NewLC(); |
|
4625 serviceId = stmt->IntColumnL(0); |
|
4626 serviceInfo->iUid = TUid::Uid(stmt->IntColumnL(1)); |
|
4627 |
|
4628 DEBUG_PRINTF2(_L("The Service Uid for this App is 0x%x "), serviceInfo->iUid); |
|
4629 if(serviceInfo->iUid.iUid) |
|
4630 { |
|
4631 GetOpaqueDataArrayL(aAppUid, serviceInfo->iUid, serviceInfo->iOpaqueDataArray, aLanguage); |
|
4632 } |
|
4633 |
|
4634 //populate the data types for a service Id |
|
4635 GetDataTypesL(serviceInfo->iDataTypes,serviceId); |
|
4636 |
|
4637 aApplicationRegistration.iServiceArray.AppendL(serviceInfo); |
|
4638 CleanupStack::Pop(serviceInfo); // serviceInfo |
|
4639 } |
|
4640 CleanupStack::PopAndDestroy(stmt); |
|
4641 } |
|
4642 |
|
4643 void CScrRequestImpl::GetLocalizableAppInfoL(CApplicationRegistrationData& aApplicationRegistration,TUid aAppUid, TLanguage aLanguage) |
|
4644 { |
|
4645 TLanguage storedLanguage; |
|
4646 if(GetNearestAppLanguageL(aLanguage, aAppUid, storedLanguage)) |
|
4647 { |
|
4648 Usif::CLocalizableAppInfo* localizedAppInfo = NULL; |
|
4649 _LIT(KGetServiceInfo, "Select ShortCaption,GroupName,Locale,CaptionAndIconId from LocalizableAppInfo where AppUid = ? and Locale = ?"); |
|
4650 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetServiceInfo); |
|
4651 stmt->BindIntL(1, aAppUid.iUid); |
|
4652 stmt->BindIntL(2, (TInt)storedLanguage); |
|
4653 if(stmt->ProcessNextRowL()) |
|
4654 { |
|
4655 localizedAppInfo = Usif::CLocalizableAppInfo::NewLC(); |
|
4656 DeleteObjectZ(localizedAppInfo->iShortCaption); |
|
4657 localizedAppInfo->iShortCaption = stmt->StrColumnL(0).AllocLC(); |
|
4658 DeleteObjectZ(localizedAppInfo->iGroupName); |
|
4659 localizedAppInfo->iGroupName = stmt->StrColumnL(1).AllocLC(); |
|
4660 localizedAppInfo->iApplicationLanguage = (TLanguage)stmt->IntColumnL(2); |
|
4661 |
|
4662 DEBUG_PRINTF2(_L("The Short Caption for this App is %S "), localizedAppInfo->iShortCaption); |
|
4663 DEBUG_PRINTF2(_L("The Group name this App is %S "), localizedAppInfo->iGroupName); |
|
4664 DEBUG_PRINTF2(_L("The application language this App is %d "), localizedAppInfo->iApplicationLanguage); |
|
4665 |
|
4666 //populate localized caption and icon info |
|
4667 TInt captionAndIconID = stmt->IntColumnL(3); |
|
4668 localizedAppInfo->iCaptionAndIconInfo = GetCaptionAndIconInfoL(captionAndIconID); |
|
4669 //populate view data |
|
4670 GetViewsL(localizedAppInfo->iViewDataList, aAppUid, storedLanguage); |
|
4671 |
|
4672 aApplicationRegistration.iLocalizableAppInfoList.AppendL(localizedAppInfo); |
|
4673 CleanupStack::Pop(3,localizedAppInfo); //poping iGroupName, iShortCaption and localizedAppInfo |
|
4674 } |
|
4675 CleanupStack::PopAndDestroy(stmt); |
|
4676 } |
|
4677 else |
|
4678 { |
|
4679 DEBUG_PRINTF2(_L("No Nearest locale found for AppUid 0x%x in the SCR"), aAppUid); |
|
4680 } |
|
4681 } |
|
4682 |
|
4683 void CScrRequestImpl::GetAppRegOpaqueDataL(CApplicationRegistrationData& aApplicationRegistration, TUid aAppUid, TLanguage aLanguage) const |
|
4684 { |
|
4685 GetOpaqueDataArrayL(aAppUid, TUid::Null(), aApplicationRegistration.iOpaqueDataArray, aLanguage); |
|
4686 } |
|
4687 |
|
4688 void CScrRequestImpl::NextApplicationRegistrationInfoSizeL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration, CAppRegistrySubsessionContext* aSubsessionContext) |
|
4689 { |
|
4690 while(1) |
|
4691 { |
|
4692 TBool dataFound = EFalse; |
|
4693 DeleteObjectZ(aApplicationRegistration); |
|
4694 aApplicationRegistration = CApplicationRegistrationData::NewL(); |
|
4695 if((aSubsessionContext->iAppRegIndex < aSubsessionContext->iAppUids.Count())) |
|
4696 { |
|
4697 TUid appUid = aSubsessionContext->iAppUids[aSubsessionContext->iAppRegIndex]; |
|
4698 |
|
4699 //Populate the Application Registration Info |
|
4700 TBool retVal = EFalse; |
|
4701 TRAPD(err, retVal = GetApplicationRegistrationInfoL(*aApplicationRegistration, appUid)); |
|
4702 |
|
4703 //Check if we have a valid application |
|
4704 if((KErrNone == err) && retVal) |
|
4705 { |
|
4706 TRAP(err, |
|
4707 //Populate File ownership info |
|
4708 GetFileOwnershipInfoL(*aApplicationRegistration, appUid); |
|
4709 //Populate service info |
|
4710 GetServiceInfoL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage); |
|
4711 //Populate localizable appinfo including caption and icon info |
|
4712 //and view data and its caption and icon info. |
|
4713 GetLocalizableAppInfoL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage); |
|
4714 |
|
4715 GetAppRegOpaqueDataL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage); |
|
4716 |
|
4717 GetAppPropertiesInfoL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage); ); |
|
4718 |
|
4719 dataFound = ETrue; |
|
4720 } |
|
4721 else |
|
4722 { |
|
4723 DeleteObjectZ(aApplicationRegistration); |
|
4724 } |
|
4725 |
|
4726 if(KErrNone != err) |
|
4727 DEBUG_PRINTF2(_L8("Error while reading the app registration info 0x%x. Ignoring current application details."), appUid); |
|
4728 |
|
4729 //Incrementing the index |
|
4730 aSubsessionContext->iAppRegIndex++; |
|
4731 |
|
4732 if(dataFound) |
|
4733 { |
|
4734 WriteObjectSizeL(aMessage, 1, aApplicationRegistration); |
|
4735 break; |
|
4736 } |
|
4737 } |
|
4738 else |
|
4739 { |
|
4740 DEBUG_PRINTF(_L8("Reached the end of the view.")); |
|
4741 WriteIntValueL(aMessage, 1, 0); |
|
4742 DeleteObjectZ(aApplicationRegistration); |
|
4743 break; |
|
4744 } |
|
4745 } |
|
4746 } |
|
4747 |
|
4748 void CScrRequestImpl::NextApplicationRegistrationInfoDataL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration) |
|
4749 { |
|
4750 DEBUG_PRINTF(_L8("Returning the Application Registration data.")); |
|
4751 WriteObjectDataL(aMessage, 0, aApplicationRegistration); |
|
4752 DeleteObjectZ(aApplicationRegistration); // Delete the object to prevent it to be resent. |
|
4753 } |
|
4754 |
|
4755 void CScrRequestImpl::GetAppOwnedFilesSizeL(const RMessage2& aMessage, TUid aAppUid, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4756 { |
|
4757 DEBUG_PRINTF2(_L8("Returning the Application Owned files size for application 0X%x."), aAppUid); |
|
4758 _LIT(KSelectFileOwnershipInfoWithAppUid, "SELECT FileName FROM FileOwnershipInfo WHERE AppUid = ? ;"); |
|
4759 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectFileOwnershipInfoWithAppUid); |
|
4760 stmt->BindIntL(1, aAppUid.iUid); |
|
4761 aSubsessionContext->iAppOwnedFiles.ResetAndDestroy(); |
|
4762 while(stmt->ProcessNextRowL()) |
|
4763 { |
|
4764 HBufC* fileName=stmt->StrColumnL(0).AllocLC(); |
|
4765 aSubsessionContext->iAppOwnedFiles.AppendL(fileName); |
|
4766 CleanupStack::Pop(1, fileName); |
|
4767 } |
|
4768 CleanupStack::PopAndDestroy(1, stmt); |
|
4769 if(0 == aSubsessionContext->iAppOwnedFiles.Count() ) |
|
4770 { |
|
4771 DEBUG_PRINTF2(_L8("Application with AppUid :0X%x does not own any file "),aAppUid); |
|
4772 } |
|
4773 WriteArraySizeL(aMessage, 1, aSubsessionContext->iAppOwnedFiles); |
|
4774 } |
|
4775 |
|
4776 void CScrRequestImpl::GetAppOwnedFilesDataL(const RMessage2& aMessage, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4777 { |
|
4778 DEBUG_PRINTF(_L8("Returning the Application Owned files .")); |
|
4779 WriteArrayDataL(aMessage, 0, aSubsessionContext->iAppOwnedFiles); |
|
4780 aSubsessionContext->iAppOwnedFiles.ResetAndDestroy(); |
|
4781 } |
|
4782 |
|
4783 void CScrRequestImpl::GetAppCharacteristicsL(const RMessage2& aMessage, TUid aAppUid) const |
|
4784 { |
|
4785 DEBUG_PRINTF2(_L8("Returning the characteristics of application 0X%x."), aAppUid); |
|
4786 _LIT(KSelectApplicationCapability, "SELECT Attributes, Hidden, Embeddable, NewFile, Launch, GroupName FROM AppRegistrationInfo WHERE AppUid = ? ;"); |
|
4787 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectApplicationCapability); |
|
4788 stmt->BindIntL(1, aAppUid.iUid); |
|
4789 TApplicationCharacteristics appCharacteristics; |
|
4790 if(stmt->ProcessNextRowL()) |
|
4791 { |
|
4792 appCharacteristics.iAttributes = stmt->IntColumnL(0); |
|
4793 appCharacteristics.iAppIsHidden = stmt->IntColumnL(1); |
|
4794 appCharacteristics.iEmbeddability = (TApplicationCharacteristics::TAppEmbeddability)stmt->IntColumnL(2); |
|
4795 appCharacteristics.iSupportsNewFile = stmt->IntColumnL(3); |
|
4796 appCharacteristics.iLaunchInBackground = stmt->IntColumnL(4); |
|
4797 appCharacteristics.iGroupName = stmt->StrColumnL(5); |
|
4798 TPckgC<TApplicationCharacteristics> infoPk(appCharacteristics); |
|
4799 aMessage.WriteL(0, infoPk); |
|
4800 } |
|
4801 else |
|
4802 { |
|
4803 DEBUG_PRINTF2(_L8("No Data found for Application capability with AppUid :0X%x "),aAppUid); |
|
4804 } |
|
4805 CleanupStack::PopAndDestroy(1, stmt); |
|
4806 } |
|
4807 |
|
4808 void CScrRequestImpl::GetAppIconForFileNameL(const RMessage2& aMessage, TUid aAppUid, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4809 { |
|
4810 DEBUG_PRINTF2(_L8("Returning the Icon File Name for application 0X%x."), aAppUid); |
|
4811 _LIT(KSelectIconFileNameForApplication, "SELECT IconFile FROM CaptionAndIconInfo WHERE CaptionAndIconId IN (SELECT CaptionAndIconId FROM LocalizableAppInfo WHERE AppUid = ? AND Locale = ?);"); |
|
4812 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectIconFileNameForApplication); |
|
4813 stmt->BindIntL(1, aAppUid.iUid); |
|
4814 stmt->BindIntL(2, aSubsessionContext->iAppLanguageForCurrentLocale); |
|
4815 if(stmt->ProcessNextRowL()) |
|
4816 { |
|
4817 TFileName fileName = stmt->StrColumnL(0); |
|
4818 TPckgC<TFileName> pckg(fileName); |
|
4819 aMessage.WriteL(0, pckg); |
|
4820 } |
|
4821 else |
|
4822 { |
|
4823 DEBUG_PRINTF2(_L8("No Icon file found for Application with AppUid :0X%x "),aAppUid); |
|
4824 } |
|
4825 CleanupStack::PopAndDestroy(1, stmt); |
|
4826 } |
|
4827 |
|
4828 void CScrRequestImpl::GetAppViewIconFileNameL(const RMessage2& aMessage, TUid aAppUid, CRegInfoForApplicationSubsessionContext *aSubsessionContext) const |
|
4829 { |
|
4830 TUid viewUid; |
|
4831 viewUid.iUid= aMessage.Int0(); |
|
4832 DEBUG_PRINTF2(_L8("Returning the view Icon File Name size for application 0X%x."), aAppUid); |
|
4833 _LIT(KSelectIconFileNameFromViewForApplication, "SELECT IconFile FROM CaptionAndIconInfo WHERE CaptionAndIconId IN (SELECT CaptionAndIconId FROM ViewData WHERE Uid = ? AND LocalAppInfoId IN ( SELECT LocalAppInfoId FROM LocalizableAppInfo WHERE AppUid = ? AND Locale = ?));"); |
|
4834 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectIconFileNameFromViewForApplication); |
|
4835 stmt->BindIntL(1, viewUid.iUid); |
|
4836 stmt->BindIntL(2, aAppUid.iUid); |
|
4837 stmt->BindIntL(3, aSubsessionContext->iAppLanguageForCurrentLocale); |
|
4838 if(stmt->ProcessNextRowL()) |
|
4839 { |
|
4840 TFileName fileName = stmt->StrColumnL(0); |
|
4841 TPckgC<TFileName> pckg(fileName); |
|
4842 aMessage.WriteL(1, pckg); |
|
4843 } |
|
4844 else |
|
4845 { |
|
4846 DEBUG_PRINTF3(_L8("No view Icon file found for Application with AppUid :0X%x and View ID :0X%x "),aAppUid,viewUid); |
|
4847 } |
|
4848 CleanupStack::PopAndDestroy(1, stmt); |
|
4849 } |
|
4850 |
|
4851 void CScrRequestImpl::GetAppServiceInfoSizeL(const RMessage2& aMessage, CApplicationRegInfoSubsessionContext *aSubsessionContext ) const |
|
4852 { |
|
4853 CAppServiceInfoFilter *filter = ReadObjectFromMessageLC<CAppServiceInfoFilter>(aMessage, 0); |
|
4854 TLanguage locale = (TLanguage)aMessage.Int1(); |
|
4855 |
|
4856 switch(filter->iSetFlag) |
|
4857 { |
|
4858 case CAppServiceInfoFilter::EGetServiceInfoForApp: |
|
4859 { |
|
4860 GetAppServicesL(filter->iAppUid, aSubsessionContext->iServiceInfoArray, locale); |
|
4861 break; |
|
4862 } |
|
4863 case CAppServiceInfoFilter::EGetServiceImplementationForServiceUid: |
|
4864 { |
|
4865 GetServiceImplementationsL(filter->iServiceUid, aSubsessionContext->iServiceInfoArray, locale); |
|
4866 break; |
|
4867 } |
|
4868 case CAppServiceInfoFilter::EGetServiceImplementationForServiceUidAndDatatType: |
|
4869 { |
|
4870 GetServiceImplementationsL(filter->iServiceUid, *(filter->iDataType), aSubsessionContext->iServiceInfoArray, locale); |
|
4871 break; |
|
4872 } |
|
4873 case CAppServiceInfoFilter::EGetOpaqueDataForAppWithServiceUid: |
|
4874 { |
|
4875 GetAppServiceOpaqueDataL(filter->iAppUid, filter->iServiceUid, aSubsessionContext->iServiceInfoArray, locale); |
|
4876 break; |
|
4877 } |
|
4878 default: |
|
4879 { |
|
4880 DEBUG_PRINTF(_L8("No match found for the query requested.")); |
|
4881 User::Leave(KErrArgument); |
|
4882 } |
|
4883 } |
|
4884 if(aSubsessionContext->iServiceInfoArray.Count()== 0) |
|
4885 { |
|
4886 DEBUG_PRINTF(_L8("No service info associated with the given parameters found")); |
|
4887 User::Leave(KErrNotFound); |
|
4888 } |
|
4889 WriteArraySizeL(aMessage, 2, aSubsessionContext->iServiceInfoArray); |
|
4890 CleanupStack::PopAndDestroy(filter); |
|
4891 } |
|
4892 |
|
4893 void CScrRequestImpl::GetAppServiceInfoDataL(const RMessage2& aMessage, CApplicationRegInfoSubsessionContext *aSubsessionContext) const |
|
4894 { |
|
4895 DEBUG_PRINTF(_L8("Returning the service information details.")); |
|
4896 WriteArrayDataL(aMessage, 0, aSubsessionContext->iServiceInfoArray); |
|
4897 aSubsessionContext->iServiceInfoArray.ResetAndDestroy(); |
|
4898 } |
|
4899 |
|
4900 void CScrRequestImpl::GetAppServicesL(TUid aAppUid, RPointerArray< |
|
4901 CServiceInfo>& aServiceInfoArray, TLanguage aLocale) const |
|
4902 { |
|
4903 DEBUG_PRINTF2(_L8("Returning the size of the service info details entry of application (%d)."), aAppUid.iUid); |
|
4904 _LIT(KSelectMatchingServiceInfo, "SELECT ServiceId, Uid FROM ServiceInfo WHERE AppUid=?;"); |
|
4905 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectMatchingServiceInfo); |
|
4906 stmt->BindIntL(1, aAppUid.iUid); |
|
4907 aServiceInfoArray.ResetAndDestroy(); |
|
4908 while (stmt->ProcessNextRowL()) |
|
4909 { |
|
4910 /* AppProperties is being used for OpaqueData of both AppRegInfo |
|
4911 * and ServiceInfo. So add to ServiceInfoArray only if serviceId is not 0 |
|
4912 */ |
|
4913 if (stmt->IntColumnL(1)) |
|
4914 { |
|
4915 CServiceInfo* serviceInfo = CServiceInfo::NewLC(); |
|
4916 serviceInfo->iUid = TUid::Uid(stmt->IntColumnL(1)); |
|
4917 |
|
4918 GetOpaqueDataArrayL(aAppUid, serviceInfo->iUid, serviceInfo->iOpaqueDataArray, aLocale); |
|
4919 GetDataTypesL(serviceInfo->iDataTypes, stmt->IntColumnL(0)); |
|
4920 aServiceInfoArray.AppendL(serviceInfo); |
|
4921 CleanupStack::Pop(serviceInfo); |
|
4922 } |
|
4923 } |
|
4924 // Release allocated memories |
|
4925 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
4926 } |
|
4927 |
|
4928 void CScrRequestImpl::GetServiceImplementationsL(TUid aServiceUid, |
|
4929 RPointerArray<CServiceInfo>& aServiceInfoArray, TLanguage aLocale) const |
|
4930 { |
|
4931 if (aServiceUid.iUid) |
|
4932 { |
|
4933 DEBUG_PRINTF2(_L8("Returning the size of the service info details entry associated with service Uid (%d)."), aServiceUid.iUid); |
|
4934 _LIT(KSelectMatchingServiceInfo, "SELECT ServiceId, Uid, AppUid FROM ServiceInfo WHERE Uid=?;"); |
|
4935 CStatement *stmt = iDbHandle->PrepareStatementLC( |
|
4936 KSelectMatchingServiceInfo); |
|
4937 stmt->BindIntL(1, aServiceUid.iUid); |
|
4938 aServiceInfoArray.ResetAndDestroy(); |
|
4939 while (stmt->ProcessNextRowL()) |
|
4940 { |
|
4941 CServiceInfo* serviceInfo = CServiceInfo::NewLC(); |
|
4942 |
|
4943 serviceInfo->iUid = TUid::Uid(stmt->IntColumnL(1)); |
|
4944 TUid appUid = TUid::Uid(stmt->IntColumnL(2)); |
|
4945 GetOpaqueDataArrayL(appUid, serviceInfo->iUid, serviceInfo->iOpaqueDataArray, aLocale); |
|
4946 GetDataTypesL(serviceInfo->iDataTypes, stmt->IntColumnL(0)); |
|
4947 |
|
4948 aServiceInfoArray.AppendL(serviceInfo); |
|
4949 CleanupStack::Pop(serviceInfo); |
|
4950 } |
|
4951 // Release allocated memories |
|
4952 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
4953 } |
|
4954 } |
|
4955 |
|
4956 void CScrRequestImpl::GetServiceImplementationsL(TUid aServiceUid, |
|
4957 TDesC& aDataType, RPointerArray<CServiceInfo>& aServiceInfoArray, TLanguage aLocale) const |
|
4958 { |
|
4959 if (aServiceUid.iUid) |
|
4960 { |
|
4961 DEBUG_PRINTF3(_L8("Returning the size of the service info details entry associated with service Uid (%d) and datatype (%S)."), aServiceUid.iUid, &aDataType); |
|
4962 _LIT(KSelectMatchingServiceInfo, "SELECT Uid, Priority, Type, AppUid FROM (ServiceInfo JOIN DataType ON ServiceInfo.ServiceId = DataType.ServiceId) WHERE Uid=? AND Type=?;"); |
|
4963 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectMatchingServiceInfo); |
|
4964 stmt->BindIntL(1, aServiceUid.iUid); |
|
4965 stmt->BindStrL(2, aDataType); |
|
4966 aServiceInfoArray.ResetAndDestroy(); |
|
4967 while (stmt->ProcessNextRowL()) |
|
4968 { |
|
4969 CServiceInfo* serviceInfo = CServiceInfo::NewLC(); |
|
4970 |
|
4971 serviceInfo->iUid = TUid::Uid(stmt->IntColumnL(0)); |
|
4972 |
|
4973 TUid appUid = TUid::Uid(stmt->IntColumnL(3)); |
|
4974 GetOpaqueDataArrayL(appUid, serviceInfo->iUid, serviceInfo->iOpaqueDataArray, aLocale); |
|
4975 TInt priority(stmt->IntColumnL(1)); |
|
4976 TPtrC datatype(stmt->StrColumnL(2)); |
|
4977 CDataType* dataType = CDataType::NewL(priority,datatype); |
|
4978 CleanupStack::PushL(dataType); |
|
4979 serviceInfo->iDataTypes.AppendL(dataType); |
|
4980 CleanupStack::Pop(dataType); |
|
4981 aServiceInfoArray.AppendL(serviceInfo); |
|
4982 CleanupStack::Pop(serviceInfo); |
|
4983 } |
|
4984 // Release allocated memories |
|
4985 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
4986 } |
|
4987 } |
|
4988 |
|
4989 |
|
4990 void CScrRequestImpl::GetAppServiceOpaqueDataL(TUid aAppUid, |
|
4991 TUid aServiceUid, RPointerArray<CServiceInfo>& aServiceInfoArray, TLanguage aLocale) const |
|
4992 { |
|
4993 if (aServiceUid.iUid) |
|
4994 { |
|
4995 DEBUG_PRINTF3(_L8("Returning the size of the service info details entry associated with app Uid (%d) and service Uid (%d)."), aAppUid.iUid, aServiceUid.iUid); |
|
4996 _LIT(KSelectMatchingServiceInfo, "SELECT ServiceId, Uid FROM ServiceInfo WHERE AppUid=? AND Uid=? ;"); |
|
4997 CStatement *stmt = iDbHandle->PrepareStatementLC( |
|
4998 KSelectMatchingServiceInfo); |
|
4999 stmt->BindIntL(1, aAppUid.iUid); |
|
5000 stmt->BindIntL(2, aServiceUid.iUid); |
|
5001 aServiceInfoArray.ResetAndDestroy(); |
|
5002 while (stmt->ProcessNextRowL()) |
|
5003 { |
|
5004 CServiceInfo* serviceInfo = CServiceInfo::NewLC(); |
|
5005 |
|
5006 serviceInfo->iUid = TUid::Uid(stmt->IntColumnL(1)); |
|
5007 GetOpaqueDataArrayL(aAppUid, serviceInfo->iUid, serviceInfo->iOpaqueDataArray, aLocale); |
|
5008 GetDataTypesL(serviceInfo->iDataTypes, stmt->IntColumnL(0)); |
|
5009 |
|
5010 aServiceInfoArray.AppendL(serviceInfo); |
|
5011 CleanupStack::Pop(serviceInfo); |
|
5012 } |
|
5013 // Release allocated memories |
|
5014 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
5015 } |
|
5016 } |
|
5017 |
|
5018 void CScrRequestImpl::GetOpaqueDataArrayL(TUid aAppUid, TUid aServiceUid, RPointerArray<COpaqueData>& aOpaqueDataArray, TLanguage aLanguage) const |
|
5019 { |
|
5020 TLanguage finalAppLocale; |
|
5021 GetNearestAppLanguageForOpaqueDataL(aLanguage, aAppUid, aServiceUid, finalAppLocale); |
|
5022 |
|
5023 _LIT(KOpaqueData, "SELECT StrValue FROM AppProperties where Name = ? AND ServiceUid = ? AND AppUid = ? AND Locale = ?"); |
|
5024 CStatement *stmt = iDbHandle->PrepareStatementLC(KOpaqueData); |
|
5025 |
|
5026 stmt->BindStrL(1, _L("OpaqueData")); |
|
5027 stmt->BindIntL(2, aServiceUid.iUid); |
|
5028 stmt->BindIntL(3, aAppUid.iUid); |
|
5029 stmt->BindIntL(4, (TInt)finalAppLocale); |
|
5030 |
|
5031 aOpaqueDataArray.ResetAndDestroy(); |
|
5032 while (stmt->ProcessNextRowL()) |
|
5033 { |
|
5034 Usif::COpaqueData* opaqueData = Usif::COpaqueData::NewLC(); |
|
5035 opaqueData->iLanguage = finalAppLocale; |
|
5036 DeleteObjectZ(opaqueData->iOpaqueData); |
|
5037 opaqueData->iOpaqueData = stmt->BinaryColumnL(0).AllocL(); |
|
5038 DEBUG_PRINTF2(_L("Locale for opaque entry for this App is %d "), opaqueData->iLanguage); |
|
5039 aOpaqueDataArray.AppendL(opaqueData); |
|
5040 CleanupStack::Pop(opaqueData); |
|
5041 } |
|
5042 CleanupStack::PopAndDestroy(stmt); |
|
5043 } |
|
5044 |
|
5045 TBool CScrRequestImpl::GetComponentIdForAppInternalL(TUid aAppUid, TComponentId& aComponentId) const |
|
5046 { |
|
5047 return GetIntforConditionL(KComponentIdColumnName, KAppRegistrationInfoTable, KAppIdColumnName, aAppUid.iUid, aComponentId); |
|
5048 } |
|
5049 |
|
5050 void CScrRequestImpl::GetComponentIdForAppL(const RMessage2& aMessage) const |
|
5051 { |
|
5052 DEBUG_PRINTF(_L8("Returning the componentId that the given appUid is associated with.")); |
|
5053 TUid appUid; |
|
5054 TPckg<TUid> appUidPckg(appUid); |
|
5055 aMessage.ReadL(0,appUidPckg); |
|
5056 TComponentId compId; |
|
5057 |
|
5058 if(GetComponentIdForAppInternalL(appUid, compId)) |
|
5059 { |
|
5060 TPckg<TComponentId> compIdPckg(compId); |
|
5061 aMessage.WriteL(1, compIdPckg); |
|
5062 } |
|
5063 else |
|
5064 { |
|
5065 DEBUG_PRINTF(_L8("The given app doesnot exist")); |
|
5066 User::Leave(KErrNotFound); |
|
5067 } |
|
5068 } |
|
5069 |
|
5070 void CScrRequestImpl::GetAppUidsForComponentSizeL(const RMessage2& aMessage) const |
|
5071 { |
|
5072 DEBUG_PRINTF(_L8("Returning the size of the list of AppUids associated with the component.")); |
|
5073 TComponentId compId = aMessage.Int0(); |
|
5074 |
|
5075 _LIT(KSelectAppUids, "SELECT AppUid FROM AppRegistrationInfo WHERE ComponentId=?;"); |
|
5076 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppUids); |
|
5077 stmt->BindIntL(1, compId); |
|
5078 iComponentAppUids.Close(); |
|
5079 while(stmt->ProcessNextRowL()) |
|
5080 { |
|
5081 TInt appUid(stmt->IntColumnL(0)); |
|
5082 iComponentAppUids.AppendL(TUid::Uid(appUid)); |
|
5083 } |
|
5084 // Release allocated memories |
|
5085 CleanupStack::PopAndDestroy(1, stmt); // stmt |
|
5086 |
|
5087 if(iComponentAppUids.Count()== 0) |
|
5088 { |
|
5089 DEBUG_PRINTF(_L8("No apps associated with the given componentId found")); |
|
5090 User::Leave(KErrNotFound); |
|
5091 } |
|
5092 |
|
5093 WriteArraySizeL(aMessage, 1, iComponentAppUids); |
|
5094 } |
|
5095 |
|
5096 void CScrRequestImpl::GetAppUidsForComponentDataL(const RMessage2& aMessage) const |
|
5097 { |
|
5098 DEBUG_PRINTF(_L8("Returning the list of appUids associated with the component.")); |
|
5099 WriteArrayDataL(aMessage, 0, iComponentAppUids); |
|
5100 iComponentAppUids.Reset(); |
|
5101 } |
|
5102 |
|
5103 void CScrRequestImpl::GetApplicationInfoL(const RMessage2& aMessage) |
|
5104 { |
|
5105 TUid appUid = TUid::Uid(aMessage.Int0()); |
|
5106 TLanguage locale = (TLanguage)aMessage.Int1(); |
|
5107 if(locale == KUnspecifiedLocale) |
|
5108 { |
|
5109 locale = User::Language(); |
|
5110 } |
|
5111 TAppRegInfo appRegInfo; |
|
5112 TPckg<TAppRegInfo> appRegInfoPckg(appRegInfo); |
|
5113 aMessage.ReadL(2, appRegInfoPckg); |
|
5114 |
|
5115 _LIT(KNull,""); |
|
5116 DEBUG_PRINTF2(_L8("Returning the basic information contained in TAppRegInfo for application 0x%x."), appUid.iUid); |
|
5117 _LIT(KSelectAppInfo, "SELECT AppFile FROM AppRegistrationInfo WHERE AppUid = ?;"); |
|
5118 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppInfo); |
|
5119 stmt->BindIntL(1, appUid.iUid); |
|
5120 if(stmt->ProcessNextRowL()) |
|
5121 { |
|
5122 appRegInfo.iUid = appUid; |
|
5123 appRegInfo.iFullName.Copy(stmt->StrColumnL(0)); |
|
5124 TLanguage finallocale = KUnspecifiedLocale; |
|
5125 if(GetNearestAppLanguageL(locale,appRegInfo.iUid, finallocale)) |
|
5126 { |
|
5127 GetCaptionAndShortCaptionInfoForLocaleL(appRegInfo.iUid, finallocale, appRegInfo.iShortCaption, appRegInfo.iCaption); |
|
5128 } |
|
5129 else |
|
5130 { |
|
5131 appRegInfo.iCaption.Copy(KNull); |
|
5132 appRegInfo.iShortCaption.Copy(KNull); |
|
5133 } |
|
5134 aMessage.WriteL(2, appRegInfoPckg); |
|
5135 } |
|
5136 else |
|
5137 { |
|
5138 appRegInfo.iUid = TUid::Null(); |
|
5139 DEBUG_PRINTF2(_L8("Application 0x%x not found."), appUid.iUid); |
|
5140 } |
|
5141 CleanupStack::PopAndDestroy(stmt); |
|
5142 } |
|
5143 |
|
5144 void CScrRequestImpl::GetCaptionAndShortCaptionInfoForLocaleL(TUid aAppUid, TLanguage aLocale, TAppCaption& aShortCaption, TAppCaption& aCaption) |
|
5145 { |
|
5146 _LIT(KGetShortCaptionAndCaptionAndIconId,"SELECT CaptionAndIconId, ShortCaption FROM LocalizableAppInfo WHERE AppUid = ? AND Locale = ?;"); |
|
5147 CStatement *stmt1 = iDbHandle->PrepareStatementLC(KGetShortCaptionAndCaptionAndIconId); |
|
5148 stmt1->BindIntL(1, aAppUid.iUid); |
|
5149 stmt1->BindIntL(2, aLocale); |
|
5150 stmt1->ProcessNextRowL(); |
|
5151 aShortCaption.Copy(stmt1->StrColumnL(1)); |
|
5152 TInt captionAndIconId = stmt1->IntColumnL(0); |
|
5153 if(captionAndIconId) |
|
5154 { |
|
5155 _LIT(KGetCaption,"SELECT Caption FROM CaptionAndIconInfo WHERE CaptionAndIconId = ?;"); |
|
5156 CStatement *stmt2 = iDbHandle->PrepareStatementLC(KGetCaption); |
|
5157 stmt2->BindIntL(1, captionAndIconId); |
|
5158 stmt2->ProcessNextRowL(); |
|
5159 aCaption.Copy(stmt2->StrColumnL(0)); |
|
5160 CleanupStack::PopAndDestroy(stmt2); |
|
5161 } |
|
5162 CleanupStack::PopAndDestroy(stmt1); |
|
5163 } |
|
5164 |
|
5165 void CScrRequestImpl::GetAppPropertiesInfoL(CApplicationRegistrationData& aApplicationRegistration,TUid aAppUid, TLanguage aLanguage) |
|
5166 { |
|
5167 DEBUG_PRINTF2(_L8("returning App Properties Info for AppUid %d in the SCR"), aAppUid); |
|
5168 TLanguage appSupportedLanguage; |
|
5169 if(GetNearestAppLanguageL(aLanguage, aAppUid, appSupportedLanguage)) |
|
5170 { |
|
5171 _LIT(KGetAppPropertiesInfo, "SELECT Name, IntValue, StrValue, Locale, IsStr8Bit FROM AppProperties WHERE (AppUid =?) AND (Locale= ? OR Locale= ?)"); |
|
5172 CStatement *stmt = iDbHandle->PrepareStatementLC(KGetAppPropertiesInfo); |
|
5173 stmt->BindIntL(1, aAppUid.iUid); |
|
5174 stmt->BindIntL(2, Usif::KNonLocalized); |
|
5175 stmt->BindIntL(3, (TInt)appSupportedLanguage); |
|
5176 while(stmt->ProcessNextRowL()) |
|
5177 { |
|
5178 TPtrC name(stmt->StrColumnL(0)); |
|
5179 CPropertyEntry *entry = GetPropertyEntryL(*stmt, name, 1); // aStartingIndex=1 |
|
5180 DEBUG_PRINTF2(_L("Value read for Property %S "), &name); |
|
5181 CleanupStack::PushL(entry); |
|
5182 aApplicationRegistration.iAppPropertiesArray.AppendL(entry); |
|
5183 CleanupStack::Pop(entry); // because array is now owner |
|
5184 } |
|
5185 CleanupStack::PopAndDestroy(stmt); |
|
5186 } |
|
5187 else |
|
5188 { |
|
5189 DEBUG_PRINTF2(_L8("No Nearest locale found for AppUid %d in the SCR"), aAppUid); |
|
5190 } |
|
5191 } |
|
5192 |
|
5193 void CScrRequestImpl::GetApplicationLaunchersSizeL(const RMessage2& aMessage) const |
|
5194 { |
|
5195 DEBUG_PRINTF(_L8("Returning the size of the list of application launchers")); |
|
5196 |
|
5197 _LIT(KSelectLauncher, "SELECT SoftwareTypeId, LauncherExecutable FROM SoftwareTypes;"); |
|
5198 CStatement* stmt = iDbHandle->PrepareStatementLC(KSelectLauncher); |
|
5199 |
|
5200 while(stmt->ProcessNextRowL()) |
|
5201 { |
|
5202 CLauncherExecutable* launcher = CLauncherExecutable::NewLC(); |
|
5203 launcher->iTypeId = stmt->IntColumnL(0); |
|
5204 DeleteObjectZ(launcher->iLauncher); |
|
5205 launcher->iLauncher = stmt->StrColumnL(1).AllocL(); |
|
5206 iLaunchers.AppendL(launcher); |
|
5207 CleanupStack::Pop(launcher); |
|
5208 } |
|
5209 CleanupStack::PopAndDestroy(stmt); |
|
5210 |
|
5211 WriteArraySizeL(aMessage, 1, iLaunchers); |
|
5212 } |
|
5213 |
|
5214 void CScrRequestImpl::GetApplicationLaunchersDataL(const RMessage2& aMessage) const |
|
5215 { |
|
5216 DEBUG_PRINTF(_L8("Returning the list of application launchers")); |
|
5217 WriteArrayDataL(aMessage, 0, iLaunchers); |
|
5218 iLaunchers.ResetAndDestroy(); |
|
5219 } |
|
5220 |
|
5221 |
|
5222 void CScrRequestImpl::GenerateNonNativeAppUidL(const RMessage2& aMessage) |
|
5223 { |
|
5224 DEBUG_PRINTF(_L8("Generating Non Native AppUid")); |
|
5225 //Get access to the repository instance. |
|
5226 CScrRepository* scrRepository = CScrRepository::GetRepositoryInstanceL(); |
|
5227 |
|
5228 //Number of ranges defined in the cenrep file |
|
5229 TInt rangeCount = scrRepository->AppUidRangeCountL(); |
|
5230 |
|
5231 TUid rangeBegin = TUid::Null(); |
|
5232 TUid rangeEnd = TUid::Null(); |
|
5233 TUid generatedUid = TUid::Null(); // Used to store final result. |
|
5234 |
|
5235 for(TInt counter = 1; counter <= rangeCount; counter++) |
|
5236 { |
|
5237 // Retrieve the range. |
|
5238 TRAPD(err, scrRepository->GetAppUidRangeL(counter, rangeBegin, rangeEnd)); |
|
5239 |
|
5240 if(KErrNotFound == err) |
|
5241 continue;// Incorrect range, try the next one. |
|
5242 if(rangeBegin.iUid >= rangeEnd.iUid) |
|
5243 continue; // Incorrect range, try the next one. |
|
5244 |
|
5245 _LIT(KSelectAppUids, "SELECT AppUid FROM AppRegistrationInfo WHERE AppUid >= ? AND AppUid <= ? ORDER BY AppUid;"); |
|
5246 |
|
5247 CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppUids); |
|
5248 stmt->BindIntL(1, rangeBegin.iUid); |
|
5249 stmt->BindIntL(2, rangeEnd.iUid); |
|
5250 |
|
5251 TInt prevUid = rangeBegin.iUid-1; |
|
5252 while(stmt->ProcessNextRowL()) |
|
5253 { |
|
5254 TInt currUid(stmt->IntColumnL(0)); |
|
5255 if(currUid > prevUid+1) |
|
5256 break; |
|
5257 prevUid = currUid; |
|
5258 } |
|
5259 |
|
5260 if(prevUid != rangeEnd.iUid) //If the range is not full |
|
5261 { |
|
5262 generatedUid = TUid::Uid(prevUid+1); |
|
5263 CleanupStack::PopAndDestroy(1, stmt); |
|
5264 break; |
|
5265 } |
|
5266 |
|
5267 // Release allocated memories |
|
5268 CleanupStack::PopAndDestroy(1, stmt); |
|
5269 } |
|
5270 |
|
5271 TPckg<TUid> generatedUidPckg(generatedUid); |
|
5272 aMessage.WriteL(0, generatedUidPckg); |
|
5273 } |