// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
{
if (__pHistoryPresentationModel)
{
+ __pHistoryPresentationModel->UnInitialize();
delete __pHistoryPresentationModel;
__pHistoryPresentationModel = null;
}
CATCH: return r;
}
+void HistoryPresentationModel::UpdateHistoryFavIcon(History& history, Tizen::Graphics::Bitmap& favIconImage)
+{
+ result r = E_FAILURE;
+ String historyTable(HISTORY_DATA_TABLE);
+ String query;
+ String columnNames;
+ int resultCount = -1;
+
+ Image* pImage = null;
+ pImage = new Image();
+ 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;
+
+ query.Append(L"UPDATE ");
+ query.Append(historyTable);
+ query.Append(" SET FAVICON = ");
+ query.Append("?");
+ query.Append(", FAVICON_W = ");
+ query.Append("?");
+ query.Append(", FAVICON_H = ");
+ query.Append("?");
+ query.Append(" WHERE ID = ");
+ query.Append("?");
+
+ AppLog("query is %ls", query.GetPointer());
+
+ r = PresentationModelBase::ExecuteUpdateHistoryFavIconQuery(query, resultCount, history);
+ if (r == E_SUCCESS)
+ {
+ AppLog("HistoryPresentationModel::SaveHistory result is success");
+ }
+ else
+ {
+ AppLog("HistoryPresentationModel::SaveHistory result is failure");
+ }
+ r = PresentationModelBase::CommitDb();
+
+}
+
result
HistoryPresentationModel::SaveTempHistory(History& history)
{
for(int count = 0; count < todaysCount; count++)
{
History *pHistoryItem = dynamic_cast<History*>(pTodaysList->GetAt(count));
- //AppLog("HistoryPresentationModel::saveHistory pHistoryItem id is %ls",pHistoryItem->GetHistoryId().GetPointer());
- AppLog("SaveHistory pHistoryItem url is %ls",pHistoryItem->GetHistoryUrl().GetPointer());
AppLog("SaveHistory history url is %ls",history.GetHistoryUrl().GetPointer());
if(pHistoryItem != null && pHistoryItem->GetHistoryUrl().CompareTo(history.GetHistoryUrl()) == 0)
}
}
+ if (pTodaysList)
+ {
+ pTodaysList->RemoveAll();
+ delete pTodaysList;
+ }
+
pMostVisitedSites = new(std::nothrow) ArrayList();
pMostVisitedSites->Construct();
String historyTitle = history.GetHistoryTitle();
r = GetHistory(0, count, *__pDataList);
if (IsFailed(r))
{
+ delete __pDataList;
+ __pDataList = null;
return r;
}
}
for (int counter = 0 ; counter < count; counter++)
{
History *pHistory = dynamic_cast<History*>(__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++;
{
pFavIconBuffer = new ByteBuffer();
r = PresentationModelBase::GetColumn(columnCount, *pFavIconBuffer);
- if (!IsFailed(r))
+ if (!IsFailed(r) && pFavIconBuffer->GetCapacity() > 0)
{
pHistory->SetFavIconBuffer(*pFavIconBuffer);
}
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;
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<History*>(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));
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<History*>(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;
}
r = GetHistory(0, count, *__pDataList);
if(IsFailed(r))
{
+ delete __pDataList;
+ __pDataList = null;
return r;
}
}