installationservices/swcomponentregistry/source/server/scrrequestimpl.cpp
changeset 42 d17dc5398051
parent 33 8110bf1194d1
child 64 48c14c385b0e
equal deleted inserted replaced
37:6e7b00453237 42:d17dc5398051
  2454 	aLhs.Reset();
  2454 	aLhs.Reset();
  2455 	CopyFixedLengthArrayL(aLhs, tmp);
  2455 	CopyFixedLengthArrayL(aLhs, tmp);
  2456 	CleanupStack::PopAndDestroy(&tmp);
  2456 	CleanupStack::PopAndDestroy(&tmp);
  2457 	}
  2457 	}
  2458 
  2458 
  2459 void CScrRequestImpl::GetComponentIdsHavingThePropertiesL(RArray<TComponentId>& aComponentIds, RPointerArray<CPropertyEntry> aProperties, TBool aDoIntersect) const
  2459 void CScrRequestImpl::GetOperatorStringL(CComponentFilter::TDbOperator aOperator, HBufC*& aOperatorString) const
  2460 	{
  2460     {
  2461 	// GROUP BY is added at the end to avoid fetching twice components which have the same localizable values for different locales
  2461     _LIT(KEqualOperator, "=");
  2462 	_LIT(KFindComponentsFromProperties, "SELECT ComponentId FROM ComponentProperties WHERE Name=? AND %S GROUP BY ComponentId;");
  2462     _LIT(KLikeOperator, "LIKE");
  2463 	_LIT(KPropertyIntValue,"IntValue=?");
  2463     
  2464 	_LIT(KPropertyStrValue,"StrValue=?");
  2464     switch(aOperator)
  2465 	_LIT(KPropertyLocalizedValue,"StrValue=? AND Locale=?");
  2465         {
  2466 			
  2466         case CComponentFilter::EEqual:
  2467 	TInt propCount = aProperties.Count();
  2467             aOperatorString = KEqualOperator().AllocL();
  2468 
  2468             break;
  2469 	HBufC *statementStr(0);
  2469             
  2470 	RArray<TComponentId> propCompIds;
  2470         case CComponentFilter::ELike:
  2471 	CleanupClosePushL(propCompIds);
  2471             aOperatorString = KLikeOperator().AllocL();
  2472 	
  2472             break;   
  2473 	for(TInt i=0; i<propCount; ++i)
  2473             
  2474 		{
  2474         default:
  2475 		switch(aProperties[i]->PropertyType())
  2475             User::Leave(KErrArgument);
  2476 			{
  2476 			        
  2477 			case CPropertyEntry::EIntProperty:
  2477         }      
  2478 				statementStr = FormatStatementLC(KFindComponentsFromProperties, KPropertyIntValue().Length(), &KPropertyIntValue());
  2478     }
  2479 				break;
  2479 
  2480 			case CPropertyEntry::EBinaryProperty:
  2480 void CScrRequestImpl::GetComponentIdsHavingThePropertiesL(RArray<TComponentId>& aComponentIds, RPointerArray<CPropertyEntry>& aProperties, 
  2481 				statementStr = FormatStatementLC(KFindComponentsFromProperties, KPropertyStrValue().Length(), &KPropertyStrValue());
  2481                                                               RArray<CComponentFilter::TPropertyOperator>& aPropertyOperatorList, TBool aDoIntersect) const
  2482 				break;
  2482     {
  2483 			case CPropertyEntry::ELocalizedProperty:
  2483     // GROUP BY is added at the end to avoid fetching twice components which have the same localizable values for different locales
  2484 				{
  2484     
  2485 				CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aProperties[i]);
  2485     _LIT(KFindComponentsFromProperties, "SELECT ComponentId FROM ComponentProperties WHERE NAME %S ? AND %S GROUP BY ComponentId;");
  2486 				if (localizedProp->LocaleL() == KUnspecifiedLocale) // If the locale was not specified, then we match across all locales				
  2486 
  2487 					statementStr = FormatStatementLC(KFindComponentsFromProperties, KPropertyStrValue().Length(), &KPropertyStrValue());
  2487     _LIT(KPropertyIntValue, "IntValue %S ?");
  2488 				else // Otherwise we match for a specific locale
  2488     _LIT(KPropertyStrValue, "StrValue %S ?");
  2489 					statementStr = FormatStatementLC(KFindComponentsFromProperties, KPropertyLocalizedValue().Length(), &KPropertyLocalizedValue());
  2489     _LIT(KPropertyLocalizedValue, "StrValue %S ? AND Locale = ?");
  2490 				}
  2490             
  2491 				break;				
  2491     TInt propCount = aProperties.Count();
  2492 			default:
  2492 
  2493 				DEBUG_PRINTF(_L8("The property type couldn't be recognized."));
  2493     RArray<TComponentId> propCompIds;
  2494 				User::Leave(KErrAbort);	
  2494     CleanupClosePushL(propCompIds);
  2495 			}
  2495     
  2496 				
  2496     for(TInt i=0; i<propCount; ++i)
  2497 		CStatement *stmt = iDbHandle->PrepareStatementLC(*statementStr);
  2497         {
  2498 		stmt->BindStrL(1, aProperties[i]->PropertyName());
  2498         //Retrieve the operators to be used to form this query.
  2499 				
  2499         CComponentFilter::TPropertyOperator propOperator = aPropertyOperatorList[i];
  2500 		switch(aProperties[i]->PropertyType())
  2500        
  2501 			{
  2501 	   // Get the name operator.
  2502 			case CPropertyEntry::EIntProperty:
  2502 	    HBufC* nameOperator(0);
  2503 				{
  2503         GetOperatorStringL(aPropertyOperatorList[i].NameOperator(), nameOperator);
  2504 				CIntPropertyEntry *intProp = static_cast<CIntPropertyEntry *>(aProperties[i]);
  2504         CleanupStack::PushL(nameOperator);     
  2505 				stmt->BindInt64L(2, intProp->Int64Value());
  2505         
  2506 				break;
  2506         // Get the value operator.
  2507 				}
  2507         HBufC* valueOperator(0);
  2508 			case CPropertyEntry::EBinaryProperty:
  2508         GetOperatorStringL(aPropertyOperatorList[i].ValueOperator(), valueOperator);
  2509 				{
  2509         CleanupStack::PushL(valueOperator);
  2510 				CBinaryPropertyEntry *binaryProp = static_cast<CBinaryPropertyEntry *>(aProperties[i]);
  2510         
  2511 				stmt->BindBinaryL(2, binaryProp->BinaryValue());
  2511         // Create the value string based on the property type.
  2512 				break;
  2512         HBufC* valueString(0);
  2513 				}
  2513         switch(aProperties[i]->PropertyType())
  2514 			case CPropertyEntry::ELocalizedProperty:
  2514             {            
  2515 				{
  2515             case CPropertyEntry::EIntProperty:
  2516 				CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aProperties[i]);
  2516                 {
  2517 				stmt->BindStrL(2, localizedProp->StrValue());
  2517                 valueString = FormatStatementLC(KPropertyIntValue, valueOperator->Length(), valueOperator);               
  2518 				if (localizedProp->LocaleL() != KUnspecifiedLocale)
  2518                 }
  2519 					stmt->BindIntL(3, localizedProp->LocaleL());
  2519 
  2520 				break;
  2520                 break;
  2521 				}
  2521                 
  2522 			default:
  2522             case CPropertyEntry::EBinaryProperty:
  2523 				DEBUG_PRINTF(_L8("The property type couldn't be recognized."));
  2523                 {
  2524 				User::Leave(KErrAbort);	
  2524                 valueString = FormatStatementLC(KPropertyStrValue, valueOperator->Length(), valueOperator);            
  2525 			}
  2525                 }
  2526 		
  2526 
  2527 		while(stmt->ProcessNextRowL())
  2527                 break;
  2528 			{
  2528             case CPropertyEntry::ELocalizedProperty:
  2529 			User::LeaveIfError(propCompIds.InsertInOrder(stmt->IntColumnL(0)));
  2529                 {
  2530 			}
  2530                 CLocalizablePropertyEntry *localizedProp = static_cast<CLocalizablePropertyEntry *>(aProperties[i]);
  2531 		
  2531                 if (localizedProp->LocaleL() == KUnspecifiedLocale) // If the locale was not specified, then we match across all locales  
  2532 		CleanupStack::PopAndDestroy(2, statementStr); // stmt, statementStr
  2532                     {
  2533 		
  2533                     valueString = FormatStatementLC(KPropertyStrValue, valueOperator->Length(), valueOperator);        
  2534 		if (aDoIntersect)
  2534                     }
  2535 			{
  2535                 else
  2536 			IntersectSortedArraysL(aComponentIds, propCompIds);
  2536                     {
  2537 			}
  2537                     valueString = FormatStatementLC(KPropertyLocalizedValue, valueOperator->Length(), valueOperator);                
  2538 		else
  2538                     }
  2539 			{
  2539                 }
  2540 			CopyFixedLengthArrayL(aComponentIds, propCompIds);
  2540                 break;              
  2541 			aDoIntersect = ETrue; // If many properties are present in the filter, we need to intersect the component Ids on further iterations
  2541             default:
  2542 			}
  2542                 DEBUG_PRINTF(_L8("The property type couldn't be recognized."));
  2543 		
  2543                 User::Leave(KErrAbort); 
  2544 		propCompIds.Reset();
  2544             }
  2545 		}
  2545         
  2546 	CleanupStack::PopAndDestroy(&propCompIds);
  2546         // Prepare full statement using the name operator and the value string.
  2547 	}
  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 
  2548 
  2603 
  2549 void ReallocStatementIfNeededL(RBuf& aStatementStr, TInt aAddedLength)
  2604 void ReallocStatementIfNeededL(RBuf& aStatementStr, TInt aAddedLength)
  2550 	{
  2605 	{
  2551 	TInt freeSpace = aStatementStr.MaxLength() - aStatementStr.Length();
  2606 	TInt freeSpace = aStatementStr.MaxLength() - aStatementStr.Length();
  2552 	TInt extraSpace = aAddedLength - freeSpace;
  2607 	TInt extraSpace = aAddedLength - freeSpace;
  2698 		aFilterSupersetInUse = ETrue;
  2753 		aFilterSupersetInUse = ETrue;
  2699 		}
  2754 		}
  2700 	
  2755 	
  2701 	if(aFilter.iSetFlag & CComponentFilter::EProperty)
  2756 	if(aFilter.iSetFlag & CComponentFilter::EProperty)
  2702 		{
  2757 		{
  2703 		GetComponentIdsHavingThePropertiesL(aComponentFilterSuperset, aFilter.iPropertyList, doIntersect);
  2758 		GetComponentIdsHavingThePropertiesL(aComponentFilterSuperset, aFilter.iPropertyList, aFilter.iPropertyOperatorList, doIntersect);
  2704 		// Inside the function, componentIds array is intersected with the components Ids which have the given properties.
  2759 		// Inside the function, componentIds array is intersected with the components Ids which have the given properties.
  2705 		doIntersect = ETrue;
  2760 		doIntersect = ETrue;
  2706 		aFilterSupersetInUse = ETrue;
  2761 		aFilterSupersetInUse = ETrue;
  2707 		}
  2762 		}
  2708 	
  2763 	
  2788 	if(aFilter.iSetFlag & (CComponentFilter::EName | CComponentFilter::EVendor))
  2843 	if(aFilter.iSetFlag & (CComponentFilter::EName | CComponentFilter::EVendor))
  2789 		{ // If a name or vendor is specified in the filter, the locale is ignored
  2844 		{ // If a name or vendor is specified in the filter, the locale is ignored
  2790 		  // and the provided names are retrieved from the ComponentLocalizables table.
  2845 		  // and the provided names are retrieved from the ComponentLocalizables table.
  2791 		CStatement *stmt = CreateStatementObjectForComponentLocalizablesLC(*aFilter.iName, *aFilter.iVendor, aFilter.iSetFlag, aComponentId);
  2846 		CStatement *stmt = CreateStatementObjectForComponentLocalizablesLC(*aFilter.iName, *aFilter.iVendor, aFilter.iSetFlag, aComponentId);
  2792 		TBool res = stmt->ProcessNextRowL();
  2847 		TBool res = stmt->ProcessNextRowL();
  2793 		// If the name and the vendor are not found, it means that there is a defect in this class, the filter shouldn't have returned the component in the first place		
  2848 		// If the name and the vendor are not found, leave with KErrNotFound.
  2794 		__ASSERT_ALWAYS(res, User::Leave(KErrNotFound)); 		
  2849 		__ASSERT_ALWAYS(res, User::Leave(KErrNotFound)); 		
  2795 		DeleteObjectZ(aEntry.iName);
  2850 		DeleteObjectZ(aEntry.iName);
  2796 		aEntry.iName = stmt->StrColumnL(1).AllocL(); // Ownership is transferred to the entry object
  2851 		aEntry.iName = stmt->StrColumnL(1).AllocL(); // Ownership is transferred to the entry object
  2797 		DeleteObjectZ(aEntry.iVendor);
  2852 		DeleteObjectZ(aEntry.iVendor);
  2798 		aEntry.iVendor = stmt->StrColumnL(2).AllocL(); // Ownership is transferred to the entry object
  2853 		aEntry.iVendor = stmt->StrColumnL(2).AllocL(); // Ownership is transferred to the entry object
  2869 	__ASSERT_ALWAYS(aStmt && aFilter, PanicClient(aMessage, KScrIllegalCallSequence));
  2924 	__ASSERT_ALWAYS(aStmt && aFilter, PanicClient(aMessage, KScrIllegalCallSequence));
  2870 	
  2925 	
  2871 	TLanguage locale = TLanguage(aMessage.Int0());
  2926 	TLanguage locale = TLanguage(aMessage.Int0());
  2872 	
  2927 	
  2873 	DeleteObjectZ(aEntry);
  2928 	DeleteObjectZ(aEntry);
  2874 	aEntry = GetNextComponentEntryL(*aStmt, *aFilter, locale, aSubsessionContext);
  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 	
  2875 	TInt sizeSlot = 1;
  2940 	TInt sizeSlot = 1;
  2876 	if(!aEntry)
  2941 	if(!aEntry)
  2877 		{
  2942 		{
  2878 		DEBUG_PRINTF(_L8("Reached the end of the view."));
  2943 		DEBUG_PRINTF(_L8("Reached the end of the view."));
  2879 		WriteIntValueL(aMessage, sizeSlot, 0);
  2944 		WriteIntValueL(aMessage, sizeSlot, 0);
  2896 
  2961 
  2897 	TInt maxArraySize = aMessage.Int0();
  2962 	TInt maxArraySize = aMessage.Int0();
  2898 	TLanguage locale = TLanguage(aMessage.Int1());
  2963 	TLanguage locale = TLanguage(aMessage.Int1());
  2899 	
  2964 	
  2900 	aEntryList.ResetAndDestroy();
  2965 	aEntryList.ResetAndDestroy();
       
  2966 	CComponentEntry *entry(0);
       
  2967 	TInt err(0);
  2901 	for(TInt i=0; i<maxArraySize; ++i)
  2968 	for(TInt i=0; i<maxArraySize; ++i)
  2902 		{
  2969 		{
  2903 		CComponentEntry *entry = GetNextComponentEntryL(*aStmt, *aFilter, locale, aSubsessionContext);
  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         
  2904 		if(!entry)
  2979 		if(!entry)
  2905 			{
  2980 			{
  2906 			break;
  2981 			break;
  2907 			}
  2982 			}
  2908 		CleanupStack::PushL(entry);
  2983 		CleanupStack::PushL(entry);
  2909 		aEntryList.AppendL(entry);
  2984 		aEntryList.AppendL(entry);
  2910 		CleanupStack::Pop(entry); // Ownership is transferred
  2985 		CleanupStack::Pop(entry); // Ownership is transferred
  2911 		}
  2986 		}
  2912 	WriteArraySizeL(aMessage, 2, aEntryList);
  2987 	WriteArraySizeL(aMessage, 2, aEntryList);
  2913 	}
  2988 	}
       
  2989 
  2914 
  2990 
  2915 void CScrRequestImpl::NextComponentSetDataL(const RMessage2& aMessage, RPointerArray<CComponentEntry>& aEntryList) const
  2991 void CScrRequestImpl::NextComponentSetDataL(const RMessage2& aMessage, RPointerArray<CComponentEntry>& aEntryList) const
  2916 	{
  2992 	{
  2917 	DEBUG_PRINTF(_L8("Returning the next component entry set."));
  2993 	DEBUG_PRINTF(_L8("Returning the next component entry set."));
  2918 	WriteArrayDataL(aMessage, 0, aEntryList);
  2994 	WriteArrayDataL(aMessage, 0, aEntryList);
  3119 TBool CompareHBufDescs(const HBufC& aLeft, const HBufC& aRight)
  3195 TBool CompareHBufDescs(const HBufC& aLeft, const HBufC& aRight)
  3120 	{
  3196 	{
  3121 	return !aLeft.CompareF(aRight);
  3197 	return !aLeft.CompareF(aRight);
  3122 	}
  3198 	}
  3123 
  3199 
  3124 TBool CScrRequestImpl::IsSoftwareTypeExistingL(TUint32 aSwTypeId, TUint32 aSifPluginUid, TUint32 aInstallerSecureId, TUint32 aExecutionLayerSecureId, const RPointerArray<HBufC>& aMimeTypesArray, const RPointerArray<CLocalizedSoftwareTypeName>& aLocalizedNamesArray)
  3200 TBool CScrRequestImpl::IsSoftwareTypeExistingL(TUint32 aSwTypeId, TUint32 aSifPluginUid, RArray<TCustomAccessInfo>& aSidArray, const RPointerArray<HBufC>& aMimeTypesArray, const RPointerArray<CLocalizedSoftwareTypeName>& aLocalizedNamesArray, const TDesC& aLauncherExecutable)
  3125 	{
  3201 	{
       
  3202 	//Check if software type id exists
  3126     if(!IsSoftwareTypeExistingL(aSwTypeId))
  3203     if(!IsSoftwareTypeExistingL(aSwTypeId))
  3127         {
  3204         {
  3128         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: Software Type Id (%d) doesn't exist in the SCR."), aSwTypeId);
  3205         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: Software Type Id (%d) doesn't exist in the SCR."), aSwTypeId);
  3129         return EFalse;
  3206         return EFalse;
  3130         }
  3207         }
  3131     
  3208     
       
  3209     //Check if sif plugin uid for the software type id is the same 
  3132     TInt pluginUid(0);
  3210     TInt pluginUid(0);
  3133     if(!GetSifPluginUidIInternalL(aSwTypeId, pluginUid))
  3211     if(!GetSifPluginUidIInternalL(aSwTypeId, pluginUid))
  3134         {
  3212         {
  3135         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't exist in the SCR for TypeId %d."), aSwTypeId);
  3213         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't exist in the SCR for TypeId %d."), aSwTypeId);
  3136         return EFalse;
  3214         return EFalse;
  3139     if(aSifPluginUid != pluginUid)
  3217     if(aSifPluginUid != pluginUid)
  3140         {
  3218         {
  3141         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't match with the one in the SCR."), pluginUid);
  3219         DEBUG_PRINTF2(_L8("IsSoftwareTypeExistingL: SIF Plugin Uid doesn't match with the one in the SCR."), pluginUid);
  3142         return EFalse;
  3220         return EFalse;
  3143         }
  3221         }
  3144         
  3222     
  3145     TBool isInstallerSidPresent = EFalse;
  3223     //Check if launcher executable for the software type id is the same
  3146     TBool isExecutionLayerSidPresent = EFalse;
  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     
  3147     RArray<TSecureId> installerSids;
  3249     RArray<TSecureId> installerSids;
  3148     CleanupClosePushL(installerSids);
  3250     CleanupClosePushL(installerSids);
  3149     if(GetSidsForSoftwareTypeIdL(aSwTypeId, installerSids))
  3251     if(GetSidsForSoftwareTypeIdL(aSwTypeId, installerSids))
  3150         {
  3252         {
  3151         TInt count = installerSids.Count();
  3253         for(TInt i=0; i<aSidArray.Count(); ++i)
  3152         for (TInt i = 0; i < count; i++)
       
  3153             {
  3254             {
  3154             if (aInstallerSecureId == installerSids[i])
  3255             if(KErrNotFound == installerSids.Find(aSidArray[i].SecureId()))
  3155                 isInstallerSidPresent = ETrue;
  3256                 {
  3156             if (aExecutionLayerSecureId == installerSids[i])
  3257                 DEBUG_PRINTF(_L8("IsSoftwareTypeExistingL: One of the Sid doesn't match with the one in the SCR."));
  3157                 isExecutionLayerSidPresent = ETrue;
  3258                 CleanupStack::PopAndDestroy(&installerSids);
  3158 
  3259                 return EFalse;
  3159 			if(isInstallerSidPresent && isExecutionLayerSidPresent)
  3260                 }
  3160 				break;
       
  3161             }
  3261             }
  3162         }
  3262         }
  3163     CleanupStack::PopAndDestroy(&installerSids);
  3263     CleanupStack::PopAndDestroy(&installerSids);
  3164     
  3264     
  3165 	if(!isInstallerSidPresent || !isExecutionLayerSidPresent)
  3265 	//Check if localized software type name for the software type id is the same
  3166 		{
       
  3167 		DEBUG_PRINTF(_L8("IsSoftwareTypeExistingL: One of the UIDs is different from the one in the database."));
       
  3168 		return EFalse;
       
  3169 		}
       
  3170 	
       
  3171 	_LIT(KSelectSwTypeNames, "SELECT Locale,Name FROM SoftwareTypeNames WHERE SoftwareTypeId=? AND Locale!=?;");
  3266 	_LIT(KSelectSwTypeNames, "SELECT Locale,Name FROM SoftwareTypeNames WHERE SoftwareTypeId=? AND Locale!=?;");
  3172 	CStatement* stmtNames = iDbHandle->PrepareStatementLC(KSelectSwTypeNames);
  3267 	CStatement* stmtNames = iDbHandle->PrepareStatementLC(KSelectSwTypeNames);
  3173 	stmtNames->BindIntL(1, aSwTypeId);
  3268 	stmtNames->BindIntL(1, aSwTypeId);
  3174 	stmtNames->BindIntL(2, KNonLocalized);
  3269 	stmtNames->BindIntL(2, KNonLocalized);
  3175 	TInt numOfFoundNames (0);
  3270 	TInt numOfFoundNames (0);
  3192 		{
  3287 		{
  3193 		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());
  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());
  3194 		return EFalse;
  3289 		return EFalse;
  3195 		}
  3290 		}
  3196 	
  3291 	
       
  3292 	//Check if mime type for the software type id is the same
  3197 	_LIT(KSelectMimeTypes, "SELECT MimeType FROM MimeTypes WHERE SoftwareTypeId=?;");
  3293 	_LIT(KSelectMimeTypes, "SELECT MimeType FROM MimeTypes WHERE SoftwareTypeId=?;");
  3198 	CStatement* stmtMimes = iDbHandle->PrepareStatementLC(KSelectMimeTypes);
  3294 	CStatement* stmtMimes = iDbHandle->PrepareStatementLC(KSelectMimeTypes);
  3199 	stmtMimes->BindIntL(1, aSwTypeId);
  3295 	stmtMimes->BindIntL(1, aSwTypeId);
  3200 	TInt numOfFoundMimes (0);
  3296 	TInt numOfFoundMimes (0);
  3201 	while(stmtMimes->ProcessNextRowL())
  3297 	while(stmtMimes->ProcessNextRowL())
  3233 	// with the corresponding installer which had been re-installed.
  3329 	// with the corresponding installer which had been re-installed.
  3234 	// Another advantage of this approach is that it is not mandatory to query SoftwareTypes table in order to get
  3330 	// Another advantage of this approach is that it is not mandatory to query SoftwareTypes table in order to get
  3235 	// the software type id of an installer. If the uniqe software type name of the installer is known, its hash
  3331 	// the software type id of an installer. If the uniqe software type name of the installer is known, its hash
  3236 	// is simply calculated to obtain its software type id.
  3332 	// is simply calculated to obtain its software type id.
  3237 	
  3333 	
  3238 	// Slot-0 contains Unique Software Type Name
  3334 	CSoftwareTypeRegInfo *regInfo = ReadObjectFromMessageLC<CSoftwareTypeRegInfo>(aMessage, 0);
  3239 	HBufC *uniqueSwTypeName = ReadDescLC(aMessage, 0);
  3335 	
  3240 	TUint32 swTypeId = HashCaseSensitiveL(*uniqueSwTypeName);
  3336 	HBufC* uniqueSwTypeName = HBufC::NewLC(regInfo->UniqueSoftwareTypeName().Length());
  3241 	
  3337 	uniqueSwTypeName->Des().Copy(regInfo->UniqueSoftwareTypeName());
  3242 	// Slot-1 contains the concatenated values of SifPluginUid, InstallerSecureId and ExecutionLayerSecureId in turn.
  3338 
  3243 	HBufC8 *uidString = ReadDesc8LC(aMessage, 1);
  3339 	TUint32 swTypeId = HashCaseSensitiveL(regInfo->UniqueSoftwareTypeName());
       
  3340 	    
  3244 	TUint32 sifPluginUid (0);
  3341 	TUint32 sifPluginUid (0);
  3245 	TUint32 installerSecureId (0);
  3342 	sifPluginUid = regInfo->SifPluginUid().iUid;
  3246 	TUint32 executionLayerSecureId (0);
  3343 	
  3247 	ParseUidHexStringL(*uidString, sifPluginUid, installerSecureId, executionLayerSecureId);
  3344 	RArray<TCustomAccessInfo> sidArray;
  3248 	CleanupStack::PopAndDestroy(uidString);
  3345 	sidArray = regInfo->CustomAccessList();
  3249 	
  3346 	
  3250 	// Slot-2 contains the list of MIME types
  3347 	RPointerArray<HBufC> mimeTypesArray = regInfo->MimeTypes();
  3251 	RIpcReadStream mimeTypesReader;
  3348 	
  3252 	CleanupClosePushL(mimeTypesReader);
  3349 	RPointerArray<CLocalizedSoftwareTypeName> localizedNamesArray = regInfo->LocalizedSoftwareTypeNames();
  3253 	mimeTypesReader.Open(aMessage, 2);
  3350 	
  3254 				
  3351 	HBufC* launcherExecutable = HBufC::NewLC(regInfo->LauncherExecutable().Length());
  3255 	RPointerArray<HBufC> mimeTypesArray;
  3352 	launcherExecutable->Des().Copy(regInfo->LauncherExecutable());
  3256 	CleanupResetAndDestroyPushL(mimeTypesArray);
  3353 
  3257 	InternalizePointersArrayL(mimeTypesArray, mimeTypesReader);
  3354 	if (IsSoftwareTypeExistingL(swTypeId, sifPluginUid, sidArray, mimeTypesArray, localizedNamesArray, *launcherExecutable))
  3258 	
       
  3259 	// Slot-3 contains Localized Software Type Names
       
  3260 	RIpcReadStream localizedNamesReader;
       
  3261 	CleanupClosePushL(localizedNamesReader);
       
  3262 	localizedNamesReader.Open(aMessage, 3);
       
  3263 				
       
  3264 	RPointerArray<CLocalizedSoftwareTypeName> localizedNamesArray;
       
  3265 	CleanupResetAndDestroyPushL(localizedNamesArray);
       
  3266 	InternalizePointersArrayL(localizedNamesArray, localizedNamesReader);
       
  3267 	
       
  3268 	if (IsSoftwareTypeExistingL(swTypeId, sifPluginUid, installerSecureId, executionLayerSecureId, mimeTypesArray, localizedNamesArray))
       
  3269 		{ // If the software type exists, do nothing and return;	
  3355 		{ // If the software type exists, do nothing and return;	
  3270 		CleanupStack::PopAndDestroy(5, uniqueSwTypeName); // uniqueSwTypeName, mimeTypesReader, mimeTypesArray, localizedNamesReader, localizedNamesArray
  3356 		CleanupStack::PopAndDestroy(3, regInfo); // uniqueSwTypeName, launcherExecutable, regInfo
  3271 		return; 
  3357 		return; 
  3272 		}
  3358 		}
  3273 	
  3359 	
  3274 	// First, insert the main record to SoftwareTypes table
  3360 	// First, insert the main record to SoftwareTypes table
  3275 	// TODO: Have to insert the Launcher Executable name here
  3361 	_LIT(KInsertSwType, "INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid,LauncherExecutable) VALUES(?,?,?);");
  3276 	_LIT(KInsertSwType, "INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid) VALUES(?,?);");
  3362 	TInt numberOfValuesSwType = 3;
  3277 	TInt numberOfValuesSwType = 2;
  3363 	ExecuteStatementL(KInsertSwType(), numberOfValuesSwType, EValueInteger, swTypeId, EValueInteger, sifPluginUid, EValueString, launcherExecutable);
  3278 	ExecuteStatementL(KInsertSwType(), numberOfValuesSwType, EValueInteger, swTypeId, EValueInteger, sifPluginUid);
       
  3279 	
  3364 	
  3280 	_LIT(KInsertCustomAccess, "INSERT INTO CustomAccessList(SoftwareTypeId,SecureId,AccessMode) VALUES(?,?,?);");
  3365 	_LIT(KInsertCustomAccess, "INSERT INTO CustomAccessList(SoftwareTypeId,SecureId,AccessMode) VALUES(?,?,?);");
  3281 	TInt numberOfValuesCustomAccess = 3;
  3366 	TInt numberOfValuesCustomAccess = 3;
  3282 	// TODO: This should be modified to insert more than 2 Sids
  3367 	for(TInt i=0; i<sidArray.Count(); ++i)
  3283 	ExecuteStatementL(KInsertCustomAccess(), numberOfValuesCustomAccess, EValueInteger, swTypeId, EValueInteger, installerSecureId, EValueInteger, (TInt)ETransactionalSid);
  3368 		{
  3284 	ExecuteStatementL(KInsertCustomAccess(), numberOfValuesCustomAccess, EValueInteger, swTypeId, EValueInteger, executionLayerSecureId, EValueInteger, (TInt)ETransactionalSid);
  3369 		TUint32 sid = sidArray[i].SecureId();
  3285 	
  3370 		TAccessMode accessMode = sidArray[i].AccessMode();
       
  3371 		ExecuteStatementL(KInsertCustomAccess(), numberOfValuesCustomAccess, EValueInteger, swTypeId, EValueInteger, sid, EValueInteger, accessMode);
       
  3372 		}
       
  3373 
  3286 	// Then, insert MIME types of this software type into MimeTypes table
  3374 	// Then, insert MIME types of this software type into MimeTypes table
  3287 	_LIT(KInsertMimeType, "INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
  3375 	_LIT(KInsertMimeType, "INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
  3288 	TInt numberOfValuesMimeType = 2;
  3376 	TInt numberOfValuesMimeType = 2;
  3289 	TInt countMimeTypes = mimeTypesArray.Count();
  3377 	TInt countMimeTypes = mimeTypesArray.Count();
  3290 	for(TInt i=0; i<countMimeTypes; ++i)
  3378 	for(TInt i=0; i<countMimeTypes; ++i)
  3302 		{
  3390 		{
  3303 		TLanguage locale = localizedNamesArray[i]->Locale();
  3391 		TLanguage locale = localizedNamesArray[i]->Locale();
  3304 		const TDesC& name = localizedNamesArray[i]->NameL();
  3392 		const TDesC& name = localizedNamesArray[i]->NameL();
  3305 		ExecuteStatementL(KInsertSwTypeName(), numberOfValuesSwTypeName, EValueInteger, swTypeId, EValueInteger, locale, EValueString, &name);
  3393 		ExecuteStatementL(KInsertSwTypeName(), numberOfValuesSwTypeName, EValueInteger, swTypeId, EValueInteger, locale, EValueString, &name);
  3306 		}	
  3394 		}	
  3307 	CleanupStack::PopAndDestroy(5, uniqueSwTypeName); // uniqueSwTypeName, mimeTypesReader, mimeTypesArray, localizedNamesReader, localizedNamesArray
  3395 	CleanupStack::PopAndDestroy(3, regInfo); // uniqueSwTypeName, launcherExecutable, regInfo
  3308 	}
  3396 	}
  3309 
  3397 
  3310 void CScrRequestImpl::DeleteSoftwareTypeL(const RMessage2& aMessage)
  3398 void CScrRequestImpl::DeleteSoftwareTypeL(const RMessage2& aMessage)
  3311 	{
  3399 	{
  3312 	HBufC *uniqueSwTypeName = ReadDescLC(aMessage, 0);
  3400 	HBufC *uniqueSwTypeName = ReadDescLC(aMessage, 0);
  3578 	}
  3666 	}
  3579 
  3667 
  3580 void CScrRequestImpl::GetIsComponentPresentL(const RMessage2& aMessage) const
  3668 void CScrRequestImpl::GetIsComponentPresentL(const RMessage2& aMessage) const
  3581 	{
  3669 	{
  3582 	TComponentId componentId = GetComponentIdFromMsgL(aMessage);
  3670 	TComponentId componentId = GetComponentIdFromMsgL(aMessage);
  3583 	DEBUG_PRINTF2(_L8("Checking if the component(%d) is available."), componentId);
  3671 	TBool result = IsComponentPresentL(componentId);
  3584 	
       
  3585 	_LIT(KSelectCompPresent, "SELECT CompPresence FROM Components WHERE ComponentId=?;");
       
  3586 	CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectCompPresent);
       
  3587 	stmt->BindIntL(1, componentId);
       
  3588 	if(!stmt->ProcessNextRowL())
       
  3589 		{
       
  3590 		DEBUG_PRINTF2(_L8("Component (%d) couldn't be found in the SCR database."), componentId);
       
  3591 		User::Leave(KErrNotFound);
       
  3592 		}
       
  3593 	TBool result = (stmt->IntColumnL(0) == 1);
       
  3594 	CleanupStack::PopAndDestroy(stmt);
       
  3595 	
       
  3596 	// The default value for CompPresence is ETrue. So when we find that the SCR DB contains the 
       
  3597 	// default property value we check if the drives registered by the component are present.   
       
  3598 	if (result && !CheckForMediaPresenceL(componentId))
       
  3599 		{
       
  3600 		result = EFalse;
       
  3601 		}
       
  3602 				
  3672 				
  3603 	TPckg<TBool> isCompPresent(result);	
  3673 	TPckg<TBool> isCompPresent(result);	
  3604 	aMessage.WriteL(1, isCompPresent);	
  3674 	aMessage.WriteL(1, isCompPresent);	
  3605 	}
  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     }
  3606 
  3701 
  3607 void CScrRequestImpl::SetIsComponentPresentL(const RMessage2& aMessage)
  3702 void CScrRequestImpl::SetIsComponentPresentL(const RMessage2& aMessage)
  3608 	{
  3703 	{
  3609 	DEBUG_PRINTF(_L8("Setting the component as present."));
  3704 	DEBUG_PRINTF(_L8("Setting the component as present."));
  3610 	_LIT(KColumnNameCompPresence, "CompPresence");
  3705 	_LIT(KColumnNameCompPresence, "CompPresence");
  3919     
  4014     
  3920     }
  4015     }
  3921 
  4016 
  3922 void CScrRequestImpl::NextAppInfoSizeL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo, CAppInfoViewSubsessionContext* aSubsessionContext)
  4017 void CScrRequestImpl::NextAppInfoSizeL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo, CAppInfoViewSubsessionContext* aSubsessionContext)
  3923     {
  4018     {
  3924     if(aSubsessionContext->iAppInfoIndex < aSubsessionContext->iApps.Count())
  4019     while(1)
  3925         {
  4020         {
  3926         TInt count1 = User::CountAllocCells();
  4021         if(aSubsessionContext->iAppInfoIndex < aSubsessionContext->iApps.Count())
  3927         aAppInfo = new(ELeave) TAppRegInfo;
       
  3928         TInt count2 = User::CountAllocCells();        
       
  3929         aAppInfo->iUid = (aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex]).iAppUid;
       
  3930 
       
  3931         _LIT(KSelectAppFilename, "SELECT AppFile FROM AppRegistrationInfo WHERE AppUid=?;");
       
  3932         CStatement *stmt = iDbHandle->PrepareStatementLC(KSelectAppFilename);
       
  3933         stmt->BindIntL(1, aAppInfo->iUid.iUid);
       
  3934         stmt->ProcessNextRowL();
       
  3935         aAppInfo->iFullName = stmt->StrColumnL(0);
       
  3936         CleanupStack::PopAndDestroy(stmt);
       
  3937 
       
  3938         if((aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex]).iLocale != KUnspecifiedLocale)
       
  3939             {
  4022             {
  3940             GetCaptionAndShortCaptionInfoForLocaleL(aAppInfo->iUid, aSubsessionContext->iApps[aSubsessionContext->iAppInfoIndex].iLocale, aAppInfo->iShortCaption, aAppInfo->iCaption);
  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                 }        
  3941             }
  4051             }
  3942         aSubsessionContext->iAppInfoIndex++;
  4052         else
  3943         }
  4053             {
  3944     else
  4054             break;
  3945         {
  4055             }
  3946         DEBUG_PRINTF(_L8("Reached the end of the view."));
  4056         }        
  3947         }
       
  3948 
       
  3949     WriteObjectSizeL(aMessage, 1, aAppInfo);
       
  3950     }
  4057     }
  3951 
  4058 
  3952 void CScrRequestImpl::NextAppInfoDataL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo)
  4059 void CScrRequestImpl::NextAppInfoDataL(const RMessage2& aMessage, TAppRegInfo*& aAppInfo)
  3953     {
  4060     {
  3954     DEBUG_PRINTF(_L8("Returning the AppInfo data."));
  4061     DEBUG_PRINTF(_L8("Returning the AppInfo data."));
  4180     }
  4287     }
  4181 
  4288 
  4182 void CScrRequestImpl::AddOpaqueDataL(TUid aAppUid, Usif::COpaqueData* aOpaqueDataEntry, TUid aServiceUid)
  4289 void CScrRequestImpl::AddOpaqueDataL(TUid aAppUid, Usif::COpaqueData* aOpaqueDataEntry, TUid aServiceUid)
  4183     {
  4290     {
  4184 	DEBUG_PRINTF(_L8("Adding the Opaque Data details into SCR"));
  4291 	DEBUG_PRINTF(_L8("Adding the Opaque Data details into SCR"));
  4185     const TInt KMaxOpaqueDataLength = 1024;
  4292     const TInt KMaxOpaqueDataLength = 4096;
  4186     /* AppUid cannot be NULL since this function is invoked from AddApplicationEntryL */ 
  4293     /* AppUid cannot be NULL since this function is invoked from AddApplicationEntryL */ 
  4187     __ASSERT_DEBUG(aAppUid != TUid::Null(), User::Leave(KErrArgument));
  4294     __ASSERT_DEBUG(aAppUid != TUid::Null(), User::Leave(KErrArgument));
  4188     
  4295     
  4189     _LIT(KOpaqueDataEntry, "INSERT INTO AppProperties(AppUid, Name, Locale, ServiceUid, StrValue, IsStr8Bit) VALUES(?,?,?,?,?,1)");
  4296     _LIT(KOpaqueDataEntry, "INSERT INTO AppProperties(AppUid, Name, Locale, ServiceUid, StrValue, IsStr8Bit) VALUES(?,?,?,?,?,1)");
  4190     
  4297     
  4374     _LIT(KAllAppIds," SELECT AppUid from AppRegistrationInfo"); 
  4481     _LIT(KAllAppIds," SELECT AppUid from AppRegistrationInfo"); 
  4375     stmt = iDbHandle->PrepareStatementLC(KAllAppIds);
  4482     stmt = iDbHandle->PrepareStatementLC(KAllAppIds);
  4376     aSubsessionContext->iAppUids.Close();
  4483     aSubsessionContext->iAppUids.Close();
  4377     while(stmt->ProcessNextRowL())
  4484     while(stmt->ProcessNextRowL())
  4378         {
  4485         {
  4379         aSubsessionContext->iAppUids.AppendL(TUid::Uid(stmt->IntColumnL(0)));                  
  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 	    	}
  4380         }
  4495         }
  4381     CleanupStack::PopAndDestroy(stmt);  
  4496     CleanupStack::PopAndDestroy(stmt);  
  4382     }
  4497     }
  4383 
  4498 
  4384 void CScrRequestImpl::OpenApplicationRegistrationForAppUidsViewL(const RMessage2& aMessage, CAppRegistrySubsessionContext*  aSubsessionContext) 
  4499 void CScrRequestImpl::OpenApplicationRegistrationForAppUidsViewL(const RMessage2& aMessage, CAppRegistrySubsessionContext*  aSubsessionContext) 
  4402        
  4517        
  4403     aSubsessionContext->iAppUids.Close();
  4518     aSubsessionContext->iAppUids.Close();
  4404     for (TInt i =0; i<size ;i++)
  4519     for (TInt i =0; i<size ;i++)
  4405         {
  4520         {
  4406         TUid appUid = TUid::Uid(inStream.ReadInt32L());
  4521         TUid appUid = TUid::Uid(inStream.ReadInt32L());
  4407         if(CheckIfAppUidExistsL(appUid)) //Append only if AppUid is present in DB.
  4522 		TComponentId componentId(0);
  4408             {
  4523         if(GetComponentIdForAppInternalL(appUid, componentId)) // Check for application presence and fetch the corresponding ComponentId
  4409             aSubsessionContext->iAppUids.AppendL(appUid);
  4524 	    	{
  4410             }
  4525 	    	if(!componentId || IsComponentPresentL(componentId)) // Check if the component is present
       
  4526             	{
       
  4527             	aSubsessionContext->iAppUids.AppendL(appUid);    
       
  4528             	}
       
  4529 	    	}
  4411         }
  4530         }
  4412     
  4531     
  4413     CleanupStack::PopAndDestroy(2,bufToHoldAppUids); //bufToHoldAppUids, inStream
  4532     CleanupStack::PopAndDestroy(2,bufToHoldAppUids); //bufToHoldAppUids, inStream
  4414     }
  4533     }
  4415 
  4534 
  4446                       
  4565                       
  4447       CleanupStack::Pop(1);
  4566       CleanupStack::Pop(1);
  4448       }
  4567       }
  4449     else
  4568     else
  4450       {
  4569       {
  4451       DEBUG_PRINTF2(_L8("AppUid %d Not Found in th SCR"),aAppUid);       
  4570       DEBUG_PRINTF2(_L8("AppUid %d Not Found in the SCR"),aAppUid);       
  4452       CleanupStack::PopAndDestroy(stmt);
  4571       CleanupStack::PopAndDestroy(stmt);
  4453       return EFalse;
  4572       return EFalse;
  4454       }
  4573       }
  4455     CleanupStack::PopAndDestroy(stmt);
  4574     CleanupStack::PopAndDestroy(stmt);
  4456     return ETrue;
  4575     return ETrue;
  4567     GetOpaqueDataArrayL(aAppUid, TUid::Null(), aApplicationRegistration.iOpaqueDataArray, aLanguage);
  4686     GetOpaqueDataArrayL(aAppUid, TUid::Null(), aApplicationRegistration.iOpaqueDataArray, aLanguage);
  4568     }
  4687     }
  4569 
  4688 
  4570 void CScrRequestImpl::NextApplicationRegistrationInfoSizeL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration, CAppRegistrySubsessionContext*  aSubsessionContext)
  4689 void CScrRequestImpl::NextApplicationRegistrationInfoSizeL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration, CAppRegistrySubsessionContext*  aSubsessionContext)
  4571     {
  4690     {
  4572     DeleteObjectZ(aApplicationRegistration);
  4691     while(1)
  4573     aApplicationRegistration = CApplicationRegistrationData::NewL();
  4692         {
  4574     if((aSubsessionContext->iAppRegIndex < aSubsessionContext->iAppUids.Count()))
  4693         TBool dataFound = EFalse;
  4575         {
  4694         DeleteObjectZ(aApplicationRegistration);
  4576         TUid appUid = aSubsessionContext->iAppUids[aSubsessionContext->iAppRegIndex];
  4695         aApplicationRegistration = CApplicationRegistrationData::NewL();
  4577             
  4696         if((aSubsessionContext->iAppRegIndex < aSubsessionContext->iAppUids.Count()))
  4578         //Populate the Application Registration Info
       
  4579         if(GetApplicationRegistrationInfoL(*aApplicationRegistration,appUid))
       
  4580             {
  4697             {
  4581             //Populate File ownership info           
  4698             TUid appUid = aSubsessionContext->iAppUids[aSubsessionContext->iAppRegIndex];
  4582             GetFileOwnershipInfoL(*aApplicationRegistration,appUid);
  4699                 
  4583                
  4700             //Populate the Application Registration Info
  4584             //Populate service info
  4701             if(GetApplicationRegistrationInfoL(*aApplicationRegistration,appUid))
  4585             GetServiceInfoL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage);
  4702                 {
  4586             
  4703                 //Populate File ownership info           
  4587             //Populate localizable appinfo including caption and icon info 
  4704                 GetFileOwnershipInfoL(*aApplicationRegistration,appUid);
  4588             //and view data and its caption and icon info.            
  4705                    
  4589             GetLocalizableAppInfoL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage);
  4706                 //Populate service info
  4590             
  4707                 GetServiceInfoL(*aApplicationRegistration, appUid, aSubsessionContext->iLanguage);
  4591 			GetAppRegOpaqueDataL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage);
  4708                 
  4592 
  4709                 //Populate localizable appinfo including caption and icon info 
  4593             GetAppPropertiesInfoL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage); 
  4710                 //and view data and its caption and icon info.            
       
  4711                 GetLocalizableAppInfoL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage);
       
  4712                 
       
  4713                 GetAppRegOpaqueDataL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage);
       
  4714     
       
  4715                 GetAppPropertiesInfoL(*aApplicationRegistration,appUid, aSubsessionContext->iLanguage); 
       
  4716                 dataFound = ETrue;
       
  4717                 }
       
  4718             else
       
  4719                 {
       
  4720                 DeleteObjectZ(aApplicationRegistration);
       
  4721                 }
       
  4722                         
       
  4723             //Incrementing the index
       
  4724             aSubsessionContext->iAppRegIndex++;
       
  4725                         
       
  4726             if(dataFound)
       
  4727                 {
       
  4728                 WriteObjectSizeL(aMessage, 1, aApplicationRegistration);
       
  4729                 break;
       
  4730                 }
  4594             }
  4731             }
  4595         else
  4732         else
  4596             {
  4733             {
       
  4734             DEBUG_PRINTF(_L8("Reached the end of the view."));
       
  4735             WriteIntValueL(aMessage, 1, 0);                
  4597             DeleteObjectZ(aApplicationRegistration);
  4736             DeleteObjectZ(aApplicationRegistration);
       
  4737             break;
  4598             }
  4738             }
  4599         
       
  4600         //Incrementing the index
       
  4601         aSubsessionContext->iAppRegIndex++;
       
  4602         WriteObjectSizeL(aMessage, 1, aApplicationRegistration);  
       
  4603         }
       
  4604     else
       
  4605         {
       
  4606         DEBUG_PRINTF(_L8("Reached the end of the view."));
       
  4607         WriteIntValueL(aMessage, 1, 0);                
       
  4608         DeleteObjectZ(aApplicationRegistration);
       
  4609         }
  4739         }
  4610     }
  4740     }
  4611 
  4741 
  4612 void CScrRequestImpl::NextApplicationRegistrationInfoDataL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration)
  4742 void CScrRequestImpl::NextApplicationRegistrationInfoDataL(const RMessage2& aMessage, CApplicationRegistrationData*& aApplicationRegistration)
  4613     {
  4743     {