diff -r 84a16765cd86 -r 98b66e4fb0be secureswitools/swisistools/source/interpretsislib/dbhelper.cpp --- a/secureswitools/swisistools/source/interpretsislib/dbhelper.cpp Fri Mar 19 09:33:35 2010 +0200 +++ b/secureswitools/swisistools/source/interpretsislib/dbhelper.cpp Fri Apr 16 15:05:20 2010 +0300 @@ -31,6 +31,11 @@ const int DbHelper::Absent = -1; +DbHelper::~DbHelper() + { + delete iScrDbHandler; + } + DbHelper::DbHelper( const std::wstring& aDrivePath, bool aIsSystemDrive) { std::string dllName = "sqlite3.dll"; @@ -69,6 +74,19 @@ return (uid == aUid); } +TBool DbHelper::IsAppUidInstalled(TUint32 aAppUid) const + { + std::string selectUid("SELECT AppFile FROM AppRegistrationInfo WHERE AppUid=?;"); + std::auto_ptr stmtUid(iScrDbHandler->PrepareStatement(selectUid)); + + stmtUid->BindInt(1, aAppUid); + + if(!stmtUid->ProcessNextRow()) + return false; + + return true; + } + TInt32 DbHelper::GetComponentId(TInt32 aUid, const std::wstring aPackageName, const std::wstring aVendorName ) const { std::string selectUid("SELECT ComponentId from ComponentProperties where Name='CompUid' and IntValue=? and ComponentId IN (SELECT ComponentId FROM \ @@ -250,6 +268,91 @@ void DbHelper::RemoveEntry( TInt32 aComponentId ) const { + + std::vector appUidList = GetAppRegistrationInfoAppUid(aComponentId); + std::vector ::iterator appUidIter; + for( appUidIter = appUidList.begin(); appUidIter != appUidList.end() ; ++appUidIter ) + { + // delete FileOwnershipInfo + std::string delFileOwnerInfo("DELETE FROM FileOwnershipInfo WHERE AppUid=?;"); + std::auto_ptr stmtdelFileOwnerInfo(iScrDbHandler->PrepareStatement(delFileOwnerInfo)); + stmtdelFileOwnerInfo->BindInt(1, *appUidIter); + stmtdelFileOwnerInfo->ExecuteStatement(); + + // delete AppProperties + std::string delAppProperties("DELETE FROM AppProperties WHERE AppUid=?;"); + std::auto_ptr stmtAppProperties(iScrDbHandler->PrepareStatement(delAppProperties)); + stmtAppProperties->BindInt(1, *appUidIter); + stmtAppProperties->ExecuteStatement(); + + std::vector serviceIdList = GetServiceInfoServiceID(*appUidIter); + + std::vector ::iterator serviceIdIter; + for( serviceIdIter = serviceIdList.begin(); serviceIdIter != serviceIdList.end() ; ++serviceIdIter ) + { + // delete DataType + std::string delDataType("DELETE FROM DataType WHERE ServiceId=?;"); + std::auto_ptr stmtDataType(iScrDbHandler->PrepareStatement(delDataType)); + stmtDataType->BindInt(1, *serviceIdIter); + stmtDataType->ExecuteStatement(); + } + + // delete ServiceInfo + std::string delServiceInfo("DELETE FROM ServiceInfo WHERE AppUid=?;"); + std::auto_ptr stmtServiceInfo(iScrDbHandler->PrepareStatement(delServiceInfo)); + stmtServiceInfo->BindInt(1, *appUidIter); + stmtServiceInfo->ExecuteStatement(); + + std::vector localAppInfoIdList = GetLocalAppInfoID(*appUidIter); + + std::vector ::iterator localAppInfoIdIter; + for( localAppInfoIdIter = localAppInfoIdList.begin(); localAppInfoIdIter != localAppInfoIdList.end() ; ++localAppInfoIdIter ) + { + std::vector viewDataCaptionIdList = GetViewDataCaptionAndIconID(*localAppInfoIdIter); + + std::vector ::iterator viewDataCaptionIdIter; + for( viewDataCaptionIdIter = viewDataCaptionIdList.begin(); viewDataCaptionIdIter != viewDataCaptionIdList.end() ; ++viewDataCaptionIdIter ) + { + // delete CaptionAndIconInfo + std::string delCaptionInfo("DELETE FROM CaptionAndIconInfo WHERE CaptionAndIconId=?;"); + std::auto_ptr stmtCaptionInfo(iScrDbHandler->PrepareStatement(delCaptionInfo)); + stmtCaptionInfo->BindInt(1, *viewDataCaptionIdIter); + stmtCaptionInfo->ExecuteStatement(); + } + + // delete ViewData + std::string delViewData("DELETE FROM ViewData WHERE LocalAppInfoId=?;"); + std::auto_ptr stmtViewData(iScrDbHandler->PrepareStatement(delViewData)); + stmtViewData->BindInt(1, *localAppInfoIdIter); + stmtViewData->ExecuteStatement(); + } + + std::vector LocalCaptionIdList = GetLocalCaptionAndIconID(*appUidIter); + std::vector ::iterator LocalCaptionIdIter; + for( LocalCaptionIdIter = LocalCaptionIdList.begin(); LocalCaptionIdIter != LocalCaptionIdList.end() ; ++LocalCaptionIdIter ) + { + // delete CaptionAndIconInfo + std::string delCaptionInfo("DELETE FROM CaptionAndIconInfo WHERE CaptionAndIconId=?;"); + std::auto_ptr stmtCaptionInfo(iScrDbHandler->PrepareStatement(delCaptionInfo)); + stmtCaptionInfo->BindInt(1, *LocalCaptionIdIter); + stmtCaptionInfo->ExecuteStatement(); + } + + // delete LocalizableAppInfo + std::string delLocalizableAppInfo("DELETE FROM LocalizableAppInfo WHERE AppUid=?;"); + std::auto_ptr stmtLocalizableAppInfo(iScrDbHandler->PrepareStatement(delLocalizableAppInfo)); + stmtLocalizableAppInfo->BindInt(1, *appUidIter); + stmtLocalizableAppInfo->ExecuteStatement(); + + } + + // delete AppRegistrationInfo + std::string delAppRegistrationInfo("DELETE FROM AppRegistrationInfo WHERE ComponentId=?;"); + std::auto_ptr stmtAppRegistrationInfo(iScrDbHandler->PrepareStatement(delAppRegistrationInfo)); + stmtAppRegistrationInfo->BindInt(1, aComponentId); + stmtAppRegistrationInfo->ExecuteStatement(); + + // delete component properties std::string delCompProps("DELETE FROM ComponentProperties WHERE ComponentId=?;"); std::auto_ptr stmtDelCompProps(iScrDbHandler->PrepareStatement(delCompProps)); @@ -844,6 +947,85 @@ return stmtCompProperty->IntColumn(0); } +std::vector DbHelper::GetServiceInfoServiceID(TInt32 aAppUid) const +{ + std::vector serviceIdList; + std::string selectServiceId("SELECT ServiceId FROM ServiceInfo WHERE AppUid=?;"); + std::auto_ptr stmtServiceId(iScrDbHandler->PrepareStatement(selectServiceId)); + + stmtServiceId->BindInt(1, aAppUid); + while(stmtServiceId->ProcessNextRow()) + { + serviceIdList.push_back(stmtServiceId->IntColumn(0)); + } + + return serviceIdList; +} + + +std::vector DbHelper::GetLocalAppInfoID(TInt32 aAppUid) const +{ + std::vector localAppInfoIdList; + std::string selectLocalAppInfoId("SELECT LocalAppInfoId FROM LocalizableAppInfo WHERE AppUid=?;"); + std::auto_ptr stmtLocalAppInfoId(iScrDbHandler->PrepareStatement(selectLocalAppInfoId)); + + stmtLocalAppInfoId->BindInt(1, aAppUid); + while(stmtLocalAppInfoId->ProcessNextRow()) + { + localAppInfoIdList.push_back(stmtLocalAppInfoId->IntColumn(0)); + } + + return localAppInfoIdList; +} + + +std::vector DbHelper::GetLocalCaptionAndIconID(TInt32 aAppUid) const +{ + std::vector localCaptionAndIconIdList; + std::string selectLocalCaptionAndIconId("SELECT CaptionAndIconId FROM LocalizableAppInfo WHERE AppUid=?;"); + std::auto_ptr stmtLocalCaptionAndIconId(iScrDbHandler->PrepareStatement(selectLocalCaptionAndIconId)); + + stmtLocalCaptionAndIconId->BindInt(1, aAppUid); + while(stmtLocalCaptionAndIconId->ProcessNextRow()) + { + localCaptionAndIconIdList.push_back(stmtLocalCaptionAndIconId->IntColumn(0)); + } + + return localCaptionAndIconIdList; +} + + +std::vector DbHelper::GetViewDataCaptionAndIconID(TInt32 aLocalAppInfoID) const +{ + std::vector viewCaptionIdList; + std::string selectViewCaptionId("SELECT CaptionAndIconId FROM ViewData WHERE LocalAppInfoId=?;"); + std::auto_ptr stmtViewCaptionId(iScrDbHandler->PrepareStatement(selectViewCaptionId)); + + stmtViewCaptionId->BindInt(1, aLocalAppInfoID); + while(stmtViewCaptionId->ProcessNextRow()) + { + viewCaptionIdList.push_back(stmtViewCaptionId->IntColumn(0)); + } + + return viewCaptionIdList; +} + + +std::vector DbHelper::GetAppRegistrationInfoAppUid(TInt32 aComponentId) const +{ + std::vector appUidList; + std::string selectAppUid("SELECT AppUid FROM AppRegistrationInfo WHERE ComponentId=?;"); + std::auto_ptr stmtAppUid(iScrDbHandler->PrepareStatement(selectAppUid)); + + stmtAppUid->BindInt(1, aComponentId); + while(stmtAppUid->ProcessNextRow()) + { + appUidList.push_back(stmtAppUid->IntColumn(0)); + } + + return appUidList; +} + TInt32 DbHelper::GetComponentPropertyIntFormattedValue(TInt32 aComponentId, std::wstring aComponentPropertyName, TInt32 aIntFormatter) const { TInt32 propertyValue = 0;