X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FIntHistoryPresentationModel.cpp;h=cabc82fdb8eb3b8a5b9f07e0b99dd6f55c24c61e;hb=5a2ca0d204f5a5fffc4cd04f16f9571fecd5d8dd;hp=a325f4c3c078e6bc7a41f3453e233d975c963444;hpb=55f94ec991b59552ea462075d58b94bdb60c27e6;p=apps%2Fosp%2FInternet.git diff --git a/src/IntHistoryPresentationModel.cpp b/src/IntHistoryPresentationModel.cpp index a325f4c..cabc82f 100644 --- a/src/IntHistoryPresentationModel.cpp +++ b/src/IntHistoryPresentationModel.cpp @@ -70,6 +70,7 @@ void HistoryPresentationModel::DestroyInstance(void) { if (__pHistoryPresentationModel) { + __pHistoryPresentationModel->UnInitialize(); delete __pHistoryPresentationModel; __pHistoryPresentationModel = null; } @@ -334,6 +335,10 @@ void HistoryPresentationModel::UpdateHistoryFavIcon(History& history, Tizen::Gra pImage->Construct(); Tizen::Base::ByteBuffer* pFavBuffer = pImage->EncodeToBufferN(favIconImage, IMG_FORMAT_PNG); + // added because conversion may fail + if(GetLastResult() != E_SUCCESS) + return; + delete pFavBuffer; history.SetFavIconBitmap(favIconImage); delete pImage; @@ -409,6 +414,12 @@ HistoryPresentationModel::SaveTempHistory(History& history) } } + if (pTodaysList) + { + pTodaysList->RemoveAll(); + delete pTodaysList; + } + pMostVisitedSites = new(std::nothrow) ArrayList(); pMostVisitedSites->Construct(); String historyTitle = history.GetHistoryTitle(); @@ -726,6 +737,8 @@ HistoryPresentationModel::GetHistoryCountWithTimeRange(Tizen::Base::DateTime& st r = GetHistory(0, count, *__pDataList); if (IsFailed(r)) { + delete __pDataList; + __pDataList = null; return r; } } @@ -738,6 +751,7 @@ HistoryPresentationModel::GetHistoryCountWithTimeRange(Tizen::Base::DateTime& st for (int counter = 0 ; counter < count; counter++) { History *pHistory = dynamic_cast(__pDataList->GetAt(counter)); + AppLog("vinayhistorytimecomparison %d, %d",pHistory->GetVisitedTime().CompareTo(startTime),pHistory->GetVisitedTime().CompareTo(endTime)); if(pHistory != null && pHistory->GetVisitedTime().CompareTo(startTime) > 0 && pHistory->GetVisitedTime().CompareTo(endTime) < 0) { historyCount++; @@ -873,7 +887,7 @@ HistoryPresentationModel::CreateHistoryList(int historyCount, ArrayList& history { pFavIconBuffer = new ByteBuffer(); r = PresentationModelBase::GetColumn(columnCount, *pFavIconBuffer); - if (!IsFailed(r)) + if (!IsFailed(r) && pFavIconBuffer->GetCapacity() > 0) { pHistory->SetFavIconBuffer(*pFavIconBuffer); } @@ -942,6 +956,9 @@ HistoryPresentationModel::CreateHistoryList(int historyCount, ArrayList& history result HistoryPresentationModel::GetSearchHistory(const int startIndex,const int limit, ArrayList& pHistoryList, String& text) { + DateTime endTime; + SystemTime::GetCurrentTime(endTime); + text.Replace(L"'", L"''"); int count = -1; @@ -958,33 +975,42 @@ HistoryPresentationModel::GetSearchHistory(const int startIndex,const int limit, query.Append(historyTable); query.Append(L".TITLE LIKE '%"); query.Append(text); - query.Append("%')"); + query.Append("%' ESCAPE '/')"); query.Append(" OR "); query.Append(L"("); query.Append(historyTable); query.Append(L".ADDRESS LIKE '%"); query.Append(text); - query.Append("%')"); + query.Append("%' ESCAPE '/')"); query.Append(" ORDER BY VISITDATE DESC"); - //Append LIMIT - if (limit > 0) - { - query.Append(" LIMIT "); - query.Append(limit); - //Append OFFESET - if (startIndex >= 0) + r = HistoryPresentationModel::ExecuteQuery(query, count); +// TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetSearchHistory query failed %s",GetErrorMessage(r)); + + ArrayList pAllSearchList; + + r = CreateHistoryList(count, pAllSearchList); + + int itemsFoundIndex = -1; + for (int counter = 0 ; counter < count; counter++) + { + History *pHistory = dynamic_cast(pAllSearchList.GetAt(counter)); + if(pHistory != null && pHistory->GetVisitedTime().CompareTo(endTime) < 0) { - query.Append(" OFFSET "); - query.Append(startIndex); + itemsFoundIndex++; + if(itemsFoundIndex >= startIndex && itemsFoundIndex < (limit + startIndex)) + { + pHistoryList.Add(*pHistory); + } + else if(itemsFoundIndex > (limit + startIndex)) + { + break; + } } } - r = HistoryPresentationModel::ExecuteQuery(query, count); - TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetSearchHistory query failed %s",GetErrorMessage(r)); - r = CreateHistoryList(count, pHistoryList); if (IsFailed(r)) { AppLogDebug("Error:CreateNoteList:failed:%s", GetErrorMessage(r)); @@ -995,41 +1021,55 @@ HistoryPresentationModel::GetSearchHistory(const int startIndex,const int limit, result HistoryPresentationModel::GetSearchHistoryCount(int& historyCount, String& text) { + DateTime endTime; + SystemTime::GetCurrentTime(endTime); + text.Replace(L"'", L"''"); + int count = -1; - int intVal = -1; String query; String historyTable(HISTORY_DATA_TABLE); result r = E_FAILURE; - bool nextRowPresent = false; - text.Replace(L"'", L"''"); - query.Append(L"SELECT COUNT(ID) FROM "); + query.Append(L"SELECT "); + query.Append(historyTable); + query.Append(L".* "); + query.Append(L"FROM "); + query.Append(historyTable); + query.Append(L" WHERE ("); query.Append(historyTable); - query.Append(L" WHERE (TITLE LIKE '%"); + query.Append(L".TITLE LIKE '%"); query.Append(text); - query.Append("%')"); + query.Append("%'ESCAPE '/')"); query.Append(" OR "); - query.Append(L"(ADDRESS LIKE '%"); + query.Append(L"("); + query.Append(historyTable); + query.Append(L".ADDRESS LIKE '%"); query.Append(text); - query.Append("%')"); + query.Append("%' ESCAPE '/')"); + query.Append(" ORDER BY VISITDATE DESC"); r = HistoryPresentationModel::ExecuteQuery(query, count); - TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetSearchHistoryCount query failed %s",GetErrorMessage(r)); +// TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetSearchHistory query failed %s",GetErrorMessage(r)); - r = HistoryPresentationModel::DbIsNextRowPresent(nextRowPresent); - if (IsFailed(r) != null) - return r; - if (nextRowPresent == true) + ArrayList pAllSearchList; + + r = CreateHistoryList(count, pAllSearchList); + + historyCount = 0; + for (int counter = 0 ; counter < count; counter++) { - r = HistoryPresentationModel::GetColumn(0, intVal); - if (IsFailed(r) != null) + History *pHistory = dynamic_cast(pAllSearchList.GetAt(counter)); + if(pHistory != null && pHistory->GetVisitedTime().CompareTo(endTime) < 0) { - AppLogDebug("Error:HistoryPresentationModel::DbGetColumn:%s", GetErrorMessage(r)); - return r; + historyCount++; } } - historyCount = intVal; + + if (IsFailed(r)) + { + AppLogDebug("Error:CreateNoteList:failed:%s", GetErrorMessage(r)); + } CATCH: return r; } @@ -1053,6 +1093,8 @@ HistoryPresentationModel::GetHistoryWithTimeRange(Tizen::Base::DateTime& startTi r = GetHistory(0, count, *__pDataList); if(IsFailed(r)) { + delete __pDataList; + __pDataList = null; return r; } }