// 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 (__pBookmarkPresentationModel)
{
+ __pBookmarkPresentationModel->UnInitialize();
delete __pBookmarkPresentationModel;
__pBookmarkPresentationModel = null;
}
result
BookmarkPresentationModel::SaveFolder(BookmarkData& bookmark)
{
- bookmark.SetParentId("-1");
- SaveTempBookmark(bookmark);
- /*
- result r = E_FAILURE;
- String bookmarkFolderTable(BOOKMARK_FOLDER_TABLE);
- String query;
- String columnNames;
- int resultCount = -1;
- int rowId = -1;
- DateTime dt;
- String bookmarkId;
- String bookmarkTitle = bookmark.GetBookmarkTitle();
- bookmarkTitle.Replace(L"'", L"''");
-
- PresentationModelBase::GetCurrentDateTime(dt);
- if (bookmark.GetBookmarkId() == "")
- {
- columnNames.Append(L"TITLE, ");
- columnNames.Append(L"CREATED_TIME, ");
- columnNames.Append(L"MODIFIED_TIME");
-
- query.Append(L"INSERT INTO ");
- query.Append(bookmarkFolderTable);
- query.Append("(");
- query.Append(columnNames);
- query.Append(") ");
- query.Append("VALUES(");
- query.Append("'");
- query.Append(bookmarkTitle);
- query.Append("', ");
- query.Append("'");
- query.Append(dt.ToString());
- query.Append("', ");
- query.Append("'");
- query.Append(dt.ToString());
- query.Append("')");
- }
- else
- {
- query.Append(L"UPDATE ");
- query.Append(bookmarkFolderTable);
- query.Append(" SET TITLE = ");
- query.Append("'");
- query.Append(bookmarkTitle);
- query.Append("'");
- query.Append(", MODIFIED_TIME = ");
- query.Append("'");
- query.Append(dt.ToString());
- query.Append("'");
- query.Append(" WHERE ID = ");
- query.Append(bookmark.GetBookmarkId());
- }
-
-
- r = PresentationModelBase::ExecuteQuery(query, resultCount);
- TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::SaveFolder query failed %s",GetErrorMessage(r));
-
- r = PresentationModelBase::CommitDb();
-
- r = GetLastInsertedId(bookmarkFolderTable, rowId);
- TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::SaveFolder GetLastInsertedId failed %s",GetErrorMessage(r));
-
- if (rowId < 0)
- return E_FAILURE;
-
- bookmarkId.Append(rowId);
-
- //Set the generated ID to Bookmark
- bookmark.SetBookmarkId(bookmarkId);
-
- CATCH: return r;
-*/}
+ bookmark.SetParentId("0");
+ return SaveTempBookmark(bookmark);
+}
result
BookmarkPresentationModel::SaveBookmark(BookmarkData& bookmark)
DateTime dt;
String bookmarkId;
String bookmarkTitle = bookmark.GetBookmarkTitle();
- bookmarkTitle.Replace(L"'", L"''");
+ bookmarkTitle.Replace(L"'", L"\'");
String bookmarkUrl = bookmark.GetUrl();
- bookmarkUrl.Replace(L"'", L"''");
+ bookmarkUrl.Replace(L"'", L"\'");
AppLog("BookmarkPresentationModel::SaveBookmark");
CATCH: return r;
}
+result BookmarkPresentationModel::GetBookmarkForHistory(int startIndex, Tizen::Base::Collection::ArrayList& pBookmarkList)
+{
+ int count = -1;
+ String query;
+ String bookmarkTable(BOOKMARK_URL_TABLE);
+ result r = E_FAILURE;
+
+ query.Append(L"SELECT * FROM ");
+ query.Append(bookmarkTable);
+ query.Append(" WHERE ADDRESS != ''");
+
+ r = PresentationModelBase::ExecuteQuery(query, count);
+ TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetBookmark query failed %s",GetErrorMessage(r));
+
+ r = CreateBookmarkList(count, pBookmarkList);
+ TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::CreateBookmarkList failed %s",GetErrorMessage(r));
+
+ CATCH: return r;
+}
+
result
BookmarkPresentationModel::GetFolder(const String& parentID, int startIndex, int limit, ArrayList& folderList)
{
String bookmarkTable(BOOKMARK_URL_TABLE);
result r = E_FAILURE;
bool nextRowPresent = false;
- text.Replace(L"'", L"''");
+ text.Replace(L"'", L"\'");
query.Append(L"SELECT COUNT(ID) FROM ");
query.Append(bookmarkTable);
query.Append(" OR ");
query.Append(L"ADDRESS LIKE '%");
query.Append(text);
- query.Append("%')");
+ query.Append("%'");
+ query.Append(" ESCAPE '/')");
query.Append(" AND ADDRESS != ''");
r = BookmarkPresentationModel::ExecuteQuery(query, count);
}
searchBookmarkCount = intVal;
- CATCH: return r;
+ CATCH:
+// text.Replace(L"''", L"'");
+ return r;
+
}
String bookmarkTable(BOOKMARK_URL_TABLE);
result r = E_FAILURE;
bool nextRowPresent = false;
- text.Replace(L"'", L"''");
+ text.Replace(L"'", L"\'");
query.Append(L"SELECT COUNT(ID) FROM ");
query.Append(bookmarkTable);
query.Append(L" WHERE TITLE LIKE '%");
query.Append(text);
query.Append("%'");
+ query.Append(" ESCAPE '/'");
query.Append(" AND ADDRESS = ''");
r = BookmarkPresentationModel::ExecuteQuery(query, count);
}
searchFolderCount = intVal;
- CATCH: return r;
+ CATCH:
+// text.Replace(L"''", L"'");
+ return r;
}
String bookmarkTable(BOOKMARK_URL_TABLE);
result r = E_FAILURE;
- text.Replace(L"'", L"''");
+ text.Replace(L"'", L"\'");
query.Append(L"SELECT * FROM ");
query.Append(bookmarkTable);
- query.Append(L" WHERE (TITLE LIKE '%");
+ query.Append(L" WHERE ((TITLE LIKE '%");
query.Append(text);
- query.Append("%')");
+ query.Append("%' ESCAPE '/')");
query.Append(" OR ");
query.Append(L"(ADDRESS LIKE '%");
query.Append(text);
- query.Append("%')");
- query.Append(" AND ADDRESS != ''");
+ query.Append("%' ESCAPE '/') )");
+ query.Append(" AND (ADDRESS != '')");
//Append LIMIT
if (limit > 0)
{
query.Append(startIndex);
}
}
-
+ AppLog("Query is %ls", query.GetPointer());
r = BookmarkPresentationModel::ExecuteQuery(query, count);
TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::GetSearchBookmark query failed %s",GetErrorMessage(r));
r = CreateBookmarkList(count, pBookmarkList);
TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::CreateBookmarkList failed %s",GetErrorMessage(r));
- CATCH: return r;
+ CATCH:
+// text.Replace(L"''", L"'");
+ return r;
}
result
String query;
String bookmarkTable(BOOKMARK_URL_TABLE);
result r = E_FAILURE;
- text.Replace(L"'", L"''");
+ text.Replace(L"'", L"\'");
query.Append(L"SELECT * FROM ");
query.Append(bookmarkTable);
query.Append(text);
//query.Append("%')");
query.Append("%'");
+ query.Append(" ESCAPE '/'");
query.Append(" AND ADDRESS = ''");
//Append LIMIT
r = CreateFolderList(count, pFolderList);
TryCatch( r == E_SUCCESS,,"BookmarkPresentationModel::CreateBookmarkList failed %s",GetErrorMessage(r));
- CATCH: return r;
+ CATCH:
+// text.Replace(L"''", L"'");
+ return r;
}
result
result r = E_FAILURE;
bool nextRowPresent = false;
int count = 0;
+ String tempURL = Url;
+ tempURL.Replace(L"'", L"''");
query.Append(L"SELECT COUNT(ID) FROM ");
query.Append(bookmarkTable);
query.Append(" WHERE ADDRESS = '");
- query.Append(Url);
+ query.Append(tempURL);
+ if(tempURL.EndsWith(L"/"))
+ {
+ query.Append("' OR ADDRESS = '");
+ String newUrl = L"";
+ tempURL.SubString(0,tempURL.GetLength()-1 ,newUrl);
+ query.Append(newUrl);
+ }
+ else
+ {
+ query.Append("' OR ADDRESS = '");
+ String newUrl = tempURL;
+// Url.SubString(0,Url.GetLength()-1 ,newUrl);
+ newUrl.Append(L"/");
+ query.Append(newUrl);
+ }
+
if(checkParentId == true)
{
query.Append(L"' AND PARENT = '");
{
exist = true ;
}
-
+ tempURL.Replace(L"''",L"'");
CATCH: return r;
}
query.Append(bookmarkTable);
query.Append(" WHERE ADDRESS = '");
query.Append(url);
+
+ if(url.EndsWith(L"/"))
+ {
+ query.Append("' OR ADDRESS = '");
+ String newUrl = L"";
+ url.SubString(0,url.GetLength()-1 ,newUrl);
+ query.Append(newUrl);
+ }
+ else
+ {
+ query.Append("' OR ADDRESS = '");
+ String newUrl = url;
+// Url.SubString(0,Url.GetLength()-1 ,newUrl);
+ newUrl.Append(L"/");
+ query.Append(newUrl);
+
+ }
+
query.Append(L"'");
r = BookmarkPresentationModel::ExecuteQuery(query, resultCount);