-//\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Flora License, Version 1.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://floralicense.org/license/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an AS IS BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-/**\r
- * @file: SearchForm.cpp\r
- * @brief: This file contains implementation of SearchForm.\r
- */\r
-\r
-#include "MfSearchForm.h"\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::App::Package;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Collection;\r
-using namespace Tizen::Base::Utility;\r
-using namespace Tizen::Content;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Io;\r
-using namespace Tizen::System;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Ui::Controls;\r
-using namespace Tizen::Ui::Scenes;\r
-\r
-int SearchForm::searchBackSelected = 0;\r
-SearchForm::SearchForm(void)\r
-{\r
- __pContentListFromLastView = null;\r
- __pSearchedContentList = null;\r
-\r
- __pListView = null;\r
- __pSearchBar = null;\r
- __pPopUpPanel = null;\r
- __pPopUpLabel = null;\r
- __pCancelSearch = null;\r
- __pDividerLabel = null;\r
-\r
- __pThumbnailManager = null;\r
- __pSearchModel = null;\r
-\r
- __searchText = L"";\r
- __currentSearchDirectoryPath = L"";\r
- __bIsResultList = false;\r
-\r
- __searchedAllFolders = false;\r
- __isSearchCompleted = false;\r
- __isCancelClicked = false;\r
- __isSearchStarted = false;\r
- __bCheckArgsNull = false;\r
- __isCurrentDirectoryRenamed = false;\r
-\r
- __itemCount = -1;\r
- __searchItemIndex = INVALID_LIST_INDEX;\r
-\r
- __pFolderBitmap = null;\r
- __pDummyImage = null;\r
-\r
- __pDeleteConfirmationPopUp = null;\r
-\r
- __selectedItemIndexForRename = 0;\r
- __selectedItemIndexForDelete = 0;\r
- __SelectedTab = MEMORY_TYPE_NONE;\r
- __previouFormTab = MEMORY_TYPE_NONE;\r
-\r
- __pCancelDeletion = null;\r
- __pDelete = null;\r
- __pFileProgressingCancelButton = null;\r
- __pFileProgressingHeaderLabel = null;\r
- __pItemContext = null;\r
- __pFileProgressingPopup = null;\r
- __pFileProgressingProgress = null;\r
- __pFileEventManager = null;\r
-}\r
-\r
-SearchForm::~SearchForm(void)\r
-{\r
- AppLogDebug("Entry");\r
-\r
- if (__pSearchedContentList != null)\r
- {\r
- __pSearchedContentList->RemoveAll(true);\r
- delete __pSearchedContentList;\r
- }\r
-\r
- if (__pSearchModel != null)\r
- {\r
- delete __pSearchModel;\r
- }\r
-\r
- if (__pItemContext != null)\r
- {\r
- delete __pItemContext;\r
- }\r
-\r
- if (__pDeleteConfirmationPopUp != null)\r
- {\r
- delete __pDeleteConfirmationPopUp;\r
- }\r
- if(__pFolderEntryPM != null)\r
- {\r
- delete __pFolderEntryPM;\r
- }\r
- if (__pFileEventManager != null)\r
- {\r
- delete __pFileEventManager;\r
- }\r
-\r
-}\r
-\r
-SearchForm&\r
-SearchForm::operator =(const SearchForm& pSearchForm)\r
-{\r
- return *this;\r
-}\r
-\r
-SearchForm::SearchForm(const SearchForm& pSearchForm)\r
-{\r
- __pContentListFromLastView = pSearchForm.__pContentListFromLastView;\r
- __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;\r
-}\r
-\r
-\r
-bool\r
-SearchForm::Initialize(void)\r
-{\r
- result r = Form::Construct(L"IDL_SEARCH");\r
- if (r != E_SUCCESS)\r
- {\r
- AppLogDebug("Form construct failed with %s", GetErrorMessage(r));\r
- return false;\r
- }\r
- return true;\r
-}\r
-\r
-result\r
-SearchForm::OnInitializing(void)\r
-{\r
- AppLogDebug("ENTER::SearchForm::OnInitializing");\r
- result r = E_SUCCESS;\r
- String cancelButton(L"");\r
-\r
- Bitmap* pMainLabelBg = null;\r
- Bitmap* pDeleteNormalBmp = null;\r
- Bitmap* pDeletePressBmp = null;\r
- Label* pSearchPopUpMainlabel = null;\r
- Label* pSearchPopUpBottomlabel = null;\r
- String renameButtonText;\r
- String detailButtonText;\r
- String deleteButtonText;\r
- String strSearching ;\r
- IListT< SceneId >* pSceneList = null;\r
-\r
- __SelectedTab = MEMORY_TYPE_NONE;\r
-\r
- __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);\r
- __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);\r
- AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);\r
- AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);\r
- AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);\r
-\r
- pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);\r
- pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);\r
-\r
- Footer* pFooter = GetFooter();\r
- pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);\r
- pFooter->SetBackButton();\r
-\r
- SetFormBackEventListener(this);\r
- __pThumbnailManager = ThumbnailManager::GetInstance();\r
- TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));\r
-\r
- ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
-\r
- __searchBarMode = SEARCH_BAR_MODE_INPUT;\r
-\r
- __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));\r
- TryCatch(__pSearchBar != null, , "__pSearchBar is Null");\r
-\r
- __pSearchBar->AddSearchBarEventListener(*this);\r
- __pSearchBar->AddTextEventListener(*this);\r
- __pSearchBar->AddKeypadEventListener(*this);\r
- __pSearchBar->SetShowState(true);\r
-\r
- __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();\r
- TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");\r
- __pFolderEntryPM->Construct();\r
- __pPopUpPanel = new (std::nothrow) Panel();\r
- TryCatch(__pPopUpPanel != null, , "Failed to allocate memory to __pPopUpPanel");\r
-\r
- r = __pPopUpPanel->Construct(Rectangle(X_POPUP_SEARCH, Y_POPUP_SEARCH, W_MAX_POPUP, H_POPUP_SEARCH));\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");\r
-\r
-\r
- pSearchPopUpMainlabel = new (std::nothrow) Label();\r
- TryCatch(pSearchPopUpMainlabel != null, , "Failed to allocate memory to _pSearchPopUpMainlabel");\r
-\r
- r = pSearchPopUpMainlabel->Construct(Rectangle(X_DEFAULT, Y_DEFAULT, __pPopUpPanel->GetWidth(), __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL), L"");\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
-\r
- pMainLabelBg = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pSearchPopUpMainlabel->GetWidth(), pSearchPopUpMainlabel->GetHeight());\r
-\r
- if (pMainLabelBg != null)\r
- {\r
- pSearchPopUpMainlabel->SetBackgroundBitmap(*pMainLabelBg);\r
- }\r
- __pPopUpPanel->AddControl(*pSearchPopUpMainlabel);\r
- __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpMainlabel, true);\r
-\r
- pSearchPopUpBottomlabel = new (std::nothrow) Label();\r
- TryCatch(pSearchPopUpBottomlabel != null, , "Failed to allocate memory to _pSearchPopUpBottomlabel");\r
-\r
- r = pSearchPopUpBottomlabel->Construct(Rectangle(X_DEFAULT, __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL, __pPopUpPanel->GetWidth(), H_BOTTOM_PANEL), L"");\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
-\r
- __pPopUpPanel->AddControl(*pSearchPopUpBottomlabel);\r
- __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpBottomlabel, true);\r
-\r
- __pPopUpLabel = new (std::nothrow) Label();\r
- TryCatch(__pPopUpLabel != null, , "Failed to allocate memory to __pPopUpLabel");\r
-\r
- AppResource::GetInstance()->GetString(L"IDS_COM_POP_SEARCHING", strSearching);\r
- r = __pPopUpLabel->Construct(Rectangle(20, 30, __pPopUpPanel->GetWidth() - 40, 60), strSearching);\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
-\r
- __pPopUpLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);\r
- __pPopUpPanel->AddControl(*__pPopUpLabel);\r
-\r
- __pDividerLabel = new (std::nothrow) Label();\r
- TryCatch(__pDividerLabel != null, r = GetLastResult(), "Failed to allocate memory to __pDividerLabel");\r
-\r
- r = __pDividerLabel->Construct(Rectangle(20, 30 + 40, __pPopUpPanel->GetWidth() - 40, 60), L"");\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pDividerLabel");\r
-\r
- __pDividerLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);\r
-\r
- __pPopUpPanel->AddControl(*__pDividerLabel);\r
-\r
- //The cancel button inside the popup, hides the popup and stops search thread, when clicked.\r
- AppResource::GetInstance()->GetString(L"IDS_COM_POP_CANCEL", cancelButton);\r
- __pCancelSearch = new (std::nothrow) Button();\r
- TryCatch(__pCancelSearch != null, , "MfMyFilesApp::Button For Popup not created!");\r
-\r
- r = __pCancelSearch->Construct(Rectangle(110, __pPopUpPanel->GetHeight() - 84, __pPopUpPanel->GetBounds().width - 220, H_DEFAULT_BUTTON), cancelButton);\r
- TryCatch(r == E_SUCCESS, , "failed to construct __pButtonPopPUP");\r
-\r
- AddControl(*__pPopUpPanel);\r
- __pPopUpPanel->AddControl(*__pCancelSearch);\r
-\r
- __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);\r
- __pCancelSearch->AddActionEventListener(*this);\r
-\r
- SetControlAlwaysOnTop(*__pPopUpPanel, true);\r
- __pPopUpPanel->SetControlAlwaysOnTop(*__pCancelSearch, true);\r
-\r
- __pPopUpPanel->SetShowState(false);\r
-\r
-\r
- __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);\r
-\r
- __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));\r
- TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");\r
-\r
- __pListView->SetItemProvider(*this);\r
- __pListView->AddListViewItemEventListener(*this);\r
-\r
- __pSearchModel = new (std::nothrow) SearchPresentationModel();\r
- TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");\r
-\r
- r = __pSearchModel->Initialize();\r
- TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));\r
-\r
- __pSearchedContentList = new (std::nothrow) ArrayList();\r
- TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");\r
-\r
- r = __pSearchedContentList->Construct();\r
- TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");\r
-\r
- __pItemContext = new (std::nothrow) ListContextItem();\r
-\r
- r = __pItemContext->Construct();\r
- TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");\r
-\r
- __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);\r
- __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);\r
-\r
- __pItemContext->AddElement(IDA_CONTEXT_DELETE,\r
- deleteButtonText,\r
- *pDeleteNormalBmp,\r
- *pDeletePressBmp,\r
- null,\r
- true);\r
-\r
- __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();\r
- __previouFormTab = FolderNavigationPresentationModel::GetStorageType();\r
- pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();\r
- if (pSceneList != null)\r
- {\r
- __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();\r
- }\r
-\r
- GetFolderName();\r
-\r
- AppLogDebug("Exit");\r
-\r
- if (pDeleteNormalBmp != null)\r
- {\r
- delete pDeleteNormalBmp;\r
- pDeleteNormalBmp = null;\r
- }\r
- if (pDeletePressBmp != null)\r
- {\r
- delete pDeletePressBmp;\r
- pDeletePressBmp = null;\r
- }\r
-\r
- if (pMainLabelBg != null)\r
- {\r
- delete pMainLabelBg;\r
- pMainLabelBg = null;\r
- }\r
-\r
- return r;\r
-\r
- CATCH:\r
- if (__pDividerLabel != null)\r
- {\r
- delete __pDividerLabel;\r
- }\r
- if (__pPopUpPanel != null)\r
- {\r
- delete __pPopUpPanel;\r
- }\r
- if (__pSearchBar != null)\r
- {\r
- delete __pSearchBar;\r
- }\r
- if (__pListView != null)\r
- {\r
- delete __pListView;\r
- }\r
- if (__pSearchModel != null)\r
- {\r
- delete __pSearchModel;\r
- }\r
-\r
- delete pDeleteNormalBmp;\r
-\r
- delete pDeletePressBmp;\r
-\r
- delete pMainLabelBg;\r
-\r
- AppLogDebug("EXIT::SearchForm::OnInitializing");\r
- return r;\r
-}\r
-\r
-result\r
-SearchForm::OnTerminating(void)\r
-{\r
- result r = E_SUCCESS;\r
- //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);\r
-\r
- if (__pFolderBitmap)\r
- delete __pFolderBitmap;\r
-\r
- if (__pDummyImage)\r
- delete __pDummyImage;\r
- return r;\r
-}\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Call-back functions\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void\r
-SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,\r
- const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)\r
-{\r
- AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));\r
-\r
- ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
-\r
- DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);\r
-#if 0\r
- DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);\r
-#endif\r
-\r
- SceneManager::GetInstance()->AddSceneManagerEventListener(*this);\r
-\r
- if (pArgs != null)\r
- {\r
- __bCheckArgsNull = true;\r
-\r
- __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();\r
- __SelectedTab = FolderNavigationPresentationModel::GetStorageType();\r
-\r
- if (__pFolderEntryPM != null)\r
- {\r
- __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);\r
- if (__currentSearchDirectoryPath.IsEmpty() == false)\r
- {\r
- __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);\r
- __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();\r
- TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");\r
- }\r
- }\r
- __isSearchCompleted = false;\r
- __isSearchStarted = false;\r
-\r
- String topLevelPath = L"";\r
-\r
-\r
- if (__SelectedTab == MEMORY_TYPE_PHONE)\r
- {\r
- topLevelPath = __pFolderEntryPM->GetMediaPath();\r
- }\r
- else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
- {\r
- topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
- }\r
-\r
- if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)\r
- {\r
- AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());\r
- __pDividerLabel->SetText(__currentSearchDirectoryPath);\r
- }\r
-\r
- pArgs->RemoveAll(false);\r
- delete pArgs;\r
- pArgs = null;\r
-\r
- }\r
- else\r
- {\r
- __bCheckArgsNull = false;\r
- }\r
-\r
- AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");\r
- return;\r
-\r
- CATCH:\r
- AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");\r
- return;\r
-\r
-}\r
-\r
-void\r
-SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,\r
- const Tizen::Ui::Scenes::SceneId& nextSceneId)\r
-{\r
- DeviceManager::RemoveAllDeviceEventListeners();\r
-}\r
-\r
-void\r
-SearchForm::OnFormBackRequested(Form& source)\r
-{\r
- TransitionScene();\r
-}\r
-\r
-void\r
-SearchForm::TransitionScene(void)\r
-{\r
- //String rootMediaPath = BasePresentationModel::GetHomePath();\r
- String rootMediaPath = BasePresentationModel::GetMediaPath();\r
- SceneManager* pSceneManager = null;\r
- pSceneManager = SceneManager::GetInstance();\r
-\r
- if (__isSearchStarted == true && __isSearchCompleted == false)\r
- {\r
- __pSearchModel->StopSearch();\r
- }\r
-\r
- if (__previousFormPath.CompareTo("") != 0)\r
- {\r
- if (__isCurrentDirectoryRenamed == false)\r
- FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);\r
- FolderNavigationPresentationModel::SetStorageType(__previouFormTab);\r
- AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());\r
- }\r
-\r
- if(__pFileEventManager != null)\r
- __pFileEventManager->RemovePath(__currentSearchDirectoryPath);\r
-\r
-// pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
-\r
- if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)\r
- {\r
- if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())\r
- {\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
- }\r
- else\r
- {\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
- }\r
- }\r
- else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)\r
- {\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
- }\r
- else\r
- {\r
- pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
- }\r
-}\r
-\r
-void\r
-SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)\r
-{\r
- int modalResult = 0;\r
- CustomAppControl* pCustomAppControl = null;\r
- String topLevelPath;\r
- String emptySearchString;\r
-\r
- DirectoryEntry* pFileDetails = null;\r
- MessageBox messageEmptyString;\r
-\r
- AppResource* pAppResource = null;\r
-\r
-\r
- pAppResource = UiApp::GetInstance()->GetAppResource();\r
- TryReturn(pAppResource != null, , "Failed to fetch AppResource");\r
-\r
- pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);\r
-\r
- __pathOfSelectedFile = L"";\r
-\r
- if (__isCancelClicked == true)\r
- {\r
- return;\r
- }\r
- if (index == __itemCount && __searchedAllFolders == false)\r
- {\r
- AppLogDebug("SearchPresentationModel::Search:%d", index);\r
- messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);\r
-\r
- if (__pSearchBar->GetText().IsEmpty())\r
- {\r
- messageEmptyString.ShowAndWait(modalResult);\r
- return;\r
- }\r
-\r
- __searchedAllFolders = true;\r
-\r
- __searchItemIndex = INVALID_LIST_INDEX;\r
- //Free the content of __pSearchedContentList and Delete the same before searching again\r
- if (__pSearchedContentList != null)\r
- {\r
- __pSearchedContentList->RemoveAll(true);\r
- }\r
-\r
- __pListView->UpdateList();\r
- __pDividerLabel->SetText(L"");\r
- __pPopUpPanel->SetShowState(true);\r
- __pPopUpPanel->Draw();\r
- __pSearchBar->SetEnabled(false);\r
-\r
- if (__SelectedTab == MEMORY_TYPE_PHONE)\r
- {\r
- topLevelPath = __pFolderEntryPM->GetMediaPath();\r
- }\r
- else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
- {\r
- topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
- }\r
-\r
- __pSearchModel->SetFolderToSearch(topLevelPath);\r
- __pSearchModel->SetStringToSearch(__searchText);\r
- __pSearchModel->Start();\r
- }\r
- else\r
- {\r
-\r
- if (__isSearchCompleted == false && __isSearchStarted == false)\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
- }\r
- else\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
- }\r
- TryCatch(pFileDetails != null, , "pFileDetails is Null")\r
-\r
-\r
- __pathOfSelectedFile = pFileDetails->GetFullFilePath();\r
-\r
- if (pFileDetails->IsDirectory() == true)\r
- {\r
- String fileName = pFileDetails->GetFileName();\r
- String filePath = pFileDetails->GetFullFilePath();\r
- LoadSubDirectoryForm(filePath, fileName);\r
- }\r
- else\r
- {\r
- //Else launch the corresponding AppControl.\r
- if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))\r
- {\r
- String* pFileUriScheme = new (std::nothrow) String(L"file://");\r
- pFileUriScheme->Append(__pathOfSelectedFile);\r
-\r
- AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);\r
- //delete pFileUriScheme;\r
- }\r
- else\r
- {\r
- String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();\r
- String parentDirectoryOfSelectedFile = L"";\r
- __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);\r
-\r
- pCustomAppControl = CustomAppControl::GetInstance();\r
- if (pCustomAppControl != null)\r
- {\r
- pCustomAppControl->SetAppControlListener(this);\r
- __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );\r
- AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);\r
- if (pAppControlInUse != null)\r
- CustomAppControl::SetAppControlInUse(pAppControlInUse);\r
- }\r
- }\r
- }\r
- }\r
- return;\r
-\r
- CATCH:\r
- return;\r
-}\r
-\r
-void\r
-SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)\r
-{\r
- //Empty Implementation.\r
-}\r
-\r
-void\r
-SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)\r
-{\r
- AppLogDebug("Enter");\r
- AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);\r
-\r
- String filePath = L"";\r
- DirectoryEntry* pFileDetails = null;\r
-\r
- if (__isSearchCompleted == false)\r
- {\r
- if (__isSearchStarted == true)\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
- }\r
- else\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
- }\r
- }\r
- else\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
- }\r
- TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");\r
-\r
- filePath.Append(pFileDetails->GetFullFilePath());\r
-\r
- switch (elementId)\r
- {\r
- case IDA_CONTEXT_DETAIL:\r
- {\r
- LoadDetailForm(filePath);\r
- }\r
- break;\r
-\r
- case IDA_CONTEXT_RENAME:\r
- {\r
- LoadRenameForm(index, pFileDetails);\r
- }\r
- break;\r
-\r
- case IDA_CONTEXT_DELETE:\r
- {\r
- __selectedItemIndexForDelete = index;\r
- __fileToDelete = pFileDetails->GetFullFilePath();\r
-\r
- ShowDeleteConfirmationPopup();\r
-\r
- }\r
- break;\r
-\r
- default:\r
- {\r
- //Do nothing\r
- }\r
- break;\r
- }\r
-\r
- CATCH:\r
-\r
- AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");\r
-}\r
-\r
-int\r
-SearchForm::GetItemCount(void)\r
-{\r
- AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);\r
- int count = 0;\r
-\r
- TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")\r
-\r
- if (__isSearchCompleted == false)\r
- {\r
- if (__isSearchStarted == true)\r
- count = __pSearchedContentList->GetCount();\r
- else\r
- {\r
- if (__pContentListFromLastView != null)\r
- count = __pContentListFromLastView->GetCount();\r
- }\r
- }\r
- else\r
- {\r
- count = __pSearchedContentList->GetCount();\r
- String topLevelPath = L"";\r
-\r
- if (__SelectedTab == MEMORY_TYPE_PHONE)\r
- {\r
- topLevelPath = defaultPhoneBody;\r
- topLevelPath.Append("/");\r
- }\r
- else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
- {\r
- topLevelPath = defaultSdCardBody;\r
- topLevelPath.Append("/");\r
- }\r
-\r
- if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)\r
- {\r
- __itemCount = count++;\r
- }\r
- }\r
- AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);\r
- return count;\r
-\r
- CATCH:\r
- AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);\r
- return count;\r
-}\r
-\r
-ListItemBase*\r
-SearchForm::CreateItem(int index, int itemWidth)\r
-{\r
- AppLogDebug("ENTER::SearchForm::CreateItem");\r
- result r = E_SUCCESS;\r
- String filename;\r
- String imageIconPath;\r
- String strHightlightedText;\r
- String filepath;\r
- String cacheImagePath;\r
-\r
- Bitmap* pFetchedCacheImage = null;\r
- Bitmap* pThumbnailImage = null;\r
- HashMap* pCacheList = null;\r
- ContentType contentType = CONTENT_TYPE_UNKNOWN;\r
-\r
- Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);\r
- Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);\r
-\r
- AppResource* pAppResource = null;\r
- DirectoryEntry* pFileDetails = null;\r
- ContentListItem* pCustomItem = null;\r
- ThumbRequest* pThumbReq = null;\r
-\r
- ArrayList* pList = null;\r
-\r
- if (index == __itemCount && __searchedAllFolders == false)\r
- {\r
- CustomItem* pItem = null;\r
- String searchAllFolder = L"";\r
- AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);\r
- pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);\r
- return pItem;\r
- }\r
-\r
- pAppResource = Application::GetInstance()->GetAppResource();\r
- TryCatch(pAppResource != null, , "Resource manager not found!");\r
-\r
- if (__isSearchCompleted == false)\r
- {\r
- if (__isSearchStarted == true)\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
- }\r
- else\r
- {\r
- if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)\r
- pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
- }\r
- }\r
- else\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
- }\r
- TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");\r
-\r
- pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);\r
- TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");\r
-\r
- filename.Clear();\r
- filename.Append(pFileDetails->GetFileName());\r
-\r
- filepath.Clear();\r
- filepath.Append(pFileDetails->GetFullFilePath());\r
-\r
- if (pFileDetails->IsDirectory() == false)\r
- {\r
- filename.Append(".");\r
- filename.Append(pFileDetails->GetFileExtension());\r
- }\r
-\r
- if (__searchText.GetLength() > 0)\r
- strHightlightedText.Append(__searchText);\r
-\r
- pCustomItem->SetTitle(filename, strHightlightedText);\r
-\r
-#if 0\r
- if (__pThumbnailManager != null)\r
- {\r
- if (pFileDetails->IsDirectory() == true)\r
- {\r
- pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);\r
- AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));\r
- }\r
- else\r
- {\r
- imageIconPath = pFileDetails->GetFullFilePath();\r
- pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);\r
- }\r
- TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");\r
- }\r
-#else\r
-\r
- contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());\r
- pCacheList = CacheManager::GetInstance()->GetCacheHashMap();\r
-\r
- if (pFileDetails->IsDirectory() == true)\r
- {\r
- pCustomItem->SetThumbnail(__pFolderBitmap);\r
- }\r
- else\r
- {\r
- if (pFileDetails->GetBitmap() == null)\r
- {\r
- if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))\r
- {\r
- if (pFileDetails != null)\r
- {\r
- cacheImagePath = pFileDetails->GetFullFilePath();\r
- AppLogDebug("cache path is %S",cacheImagePath.GetPointer());\r
- }\r
-\r
- if ((pCacheList->GetValue(cacheImagePath)) != null)\r
- {\r
- pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));\r
- }\r
- }\r
-\r
- if (pFetchedCacheImage != null)\r
- {\r
- AppLogDebug("image taken from cachemanager");\r
- pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);\r
- pCustomItem->SetThumbnail(pThumbnailImage);\r
- }\r
- else\r
- {\r
- pCustomItem->SetThumbnail(__pDummyImage);\r
-\r
- pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);\r
- TryCatch(pThumbReq != null, , "ThumbRequest is null!");\r
-\r
- pThumbReq->iRquestId = index;\r
- pThumbReq->FilePath = pFileDetails->GetFullFilePath();\r
-\r
- pList = new (std::nothrow) ArrayList();\r
- TryCatch(pList != null, , "Failed to create pList");\r
-\r
- r = pList->Construct();\r
- TryCatch(r == E_SUCCESS, , "Failed to construct pList");\r
-\r
- r = pList->Add(pThumbReq);\r
- TryCatch(r == E_SUCCESS, , "Failed to add object to pList");\r
-\r
- __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);\r
- }\r
- }\r
- else\r
- {\r
- pCustomItem->SetThumbnail(pFileDetails->GetBitmap());\r
- }\r
- }\r
-#endif\r
- if (__bIsResultList)\r
- {\r
- GetParentFolderPath(&filepath);\r
- pCustomItem->SetFilepath(filepath);\r
- pCustomItem->MakeSearchFormListItem();\r
- }\r
- else\r
- {\r
- pCustomItem->Make();\r
- } pCustomItem->SetContextItem(__pItemContext);\r
-\r
- AppLogDebug("EXIT::SearchForm::CreateItem");\r
- return pCustomItem;\r
-\r
-CATCH:\r
- if (pCustomItem != null)\r
- {\r
- delete pCustomItem;\r
- }\r
- if (pList != null)\r
- {\r
- delete pList;\r
- }\r
- if (pThumbReq)\r
- {\r
- delete pThumbReq;\r
- }\r
- AppLogDebug("EXIT::SearchForm::CreateItem");\r
- return null;\r
-}\r
-\r
-bool\r
-SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)\r
-{\r
- AppLogDebug("ENTER::SearchForm::DeleteItem");\r
- if (pItem != null)\r
- {\r
- delete pItem;\r
- pItem = null;\r
- }\r
- AppLogDebug("EXIT::SearchForm::DeleteItem");\r
- return true;\r
-}\r
-\r
-void\r
-SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)\r
-{\r
- AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");\r
- int modalResult = 0;\r
- String emptySearchString;\r
-\r
- MessageBox messageEmptyString;\r
- AppResource* pAppResource = null;\r
-\r
- pAppResource = UiApp::GetInstance()->GetAppResource();\r
- TryReturn(pAppResource != null, , "Failed to fetch AppResource");\r
-\r
- pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);\r
-\r
- messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);\r
-\r
-\r
- if (__pSearchBar->GetText().IsEmpty())\r
- {\r
- messageEmptyString.ShowAndWait(modalResult);\r
- __pSearchBar->ShowKeypad();\r
- return;\r
- }\r
-\r
- __isCancelClicked = false;\r
-\r
- //Get the text entered in SearchBar\r
- __searchText.Clear();\r
- __searchText = __pSearchBar->GetText();\r
-\r
- //Start Searching\r
- if (__searchText.IsEmpty() == false)\r
- StartSearch();\r
-\r
- AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");\r
-}\r
-void\r
-SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)\r
-{\r
- AppLogDebug("ENTER::SearchForm::OnKeypadClosed");\r
-\r
- __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
- __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
-\r
- AppLogDebug("EXIT::SearchForm::OnKeypadClosed");\r
-}\r
-void\r
-SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)\r
-{\r
- SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
-\r
- __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
- __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
-\r
-}\r
-void\r
-SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)\r
-{\r
- //Empty Implementation\r
-}\r
-void\r
-SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)\r
-{\r
- AppLogDebug("ENTER::SearchForm::OnActionPerformed");\r
- switch (actionId)\r
- {\r
- case IDA_BTN_POPUP_SEARCH_CANCEL:\r
- {\r
- AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");\r
- __isSearchCompleted = true;\r
-\r
- __pSearchModel->StopSearch();\r
-\r
- __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
- __pSearchBar->SetMode(__searchBarMode);\r
- __pSearchBar->HideKeypad();\r
-\r
- __pPopUpPanel->SetShowState(false);\r
- __pSearchBar->SetEnabled(true);\r
-\r
- SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
- __searchText.Clear();\r
-\r
- }\r
- break;\r
-\r
- case IDA_DELETE_FILE:\r
- {\r
- HideDeleteConfirmationPopup();\r
- //Call the DeleteFile Function.\r
- DeleteFile(__fileToDelete);\r
- }\r
- break;\r
-\r
- case IDA_CANCEL_DELETION:\r
- {\r
- HideDeleteConfirmationPopup();\r
- }\r
- break;\r
-\r
- default:\r
- {\r
- //Do nothing\r
- }\r
- break;\r
- }\r
- AppLogDebug("EXIT::SearchForm::OnActionPerformed");\r
-}\r
-void\r
-SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)\r
-{\r
- AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");\r
- if (__pPopUpPanel->GetShowState() == true)\r
- {\r
- __pPopUpPanel->SetShowState(false);\r
- __pPopUpPanel->Invalidate(true);\r
- __pSearchBar->SetEnabled(true);\r
- }\r
-}\r
-\r
-void\r
-SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)\r
-{\r
- //Empty Implementation.\r
-}\r
-\r
-//SearchBar Control\r
-void\r
-SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)\r
-{\r
- AppLogDebug("SearchForm::OnSearchBarModeChanged");\r
-\r
- if (mode == SEARCH_BAR_MODE_INPUT)\r
- {\r
- __searchBarMode = SEARCH_BAR_MODE_INPUT;\r
- SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
- }\r
- else\r
- {\r
- __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
- SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
- if (__isSearchStarted == true)\r
- {\r
- if (__isSearchCompleted == false)\r
- {\r
- //Stop Search Thread\r
- __pSearchModel->StopSearch();\r
-\r
- //Hide keypad of SearchBar\r
- __pSearchBar->HideKeypad();\r
-\r
- //Hide popUp\r
- if (__pPopUpPanel != null)\r
- {\r
- __pPopUpPanel->SetShowState(false);\r
- __pPopUpPanel->Invalidate(true);\r
- }\r
- }\r
- }\r
- __pListView->UpdateList();\r
- }\r
-\r
- __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
- __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
-\r
- __pSearchBar->Invalidate(true);\r
-}\r
-\r
-void\r
-SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)\r
-{\r
- CustomAppControl::GetInstance()->SetAppControlInUse(null);\r
- ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);\r
-\r
- __pSearchBar->SetMode(__searchBarMode);\r
-\r
- if (GetLastResult() == E_FILE_NOT_FOUND)\r
- {\r
- __isSearchCompleted = false;\r
- if (__searchText.IsEmpty() == false)\r
- StartSearch();\r
- }\r
- else\r
- {\r
- AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);\r
- }\r
-\r
- if (__pListView != null)\r
- __pListView->UpdateList();\r
-}\r
-\r
-void\r
-SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)\r
-{\r
- AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");\r
- result r = E_FAILURE;\r
- Integer* pEventType = null;\r
- DirectoryEntry* pResultDirEntry = null;\r
- HashMap* pCacheList = null;\r
- DirectoryEntry* pCurrentEntry = null;\r
- bool cacheKeyStatus = false;\r
- String cachePath;\r
-\r
- TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");\r
-\r
- pEventType = static_cast< Integer* >(pArgs->GetAt(0));\r
- TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");\r
-\r
- switch (pEventType->ToInt())\r
- {\r
- case ID_FOLDER_SEARCH_STARTED:\r
- {\r
- String* pFolderSearchResult = (String*) pArgs->GetAt(1);\r
- TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");\r
-\r
- String defMediaPath(L"/opt/usr/media");\r
- String defSdCardPath(L"/opt/storage/sdcard");\r
-\r
- String displayPhone = defaultPhoneBody;\r
- String displaySdCard = defaultSdCardBody;\r
-\r
-\r
- if (pFolderSearchResult->IsEmpty() == false)\r
- {\r
- if (pFolderSearchResult->StartsWith(defMediaPath, 0))\r
- {\r
- pFolderSearchResult->Replace(defMediaPath, displayPhone);\r
- }\r
- else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))\r
- {\r
- pFolderSearchResult->Replace(defSdCardPath, displaySdCard);\r
- }\r
-\r
- __pDividerLabel->SetText(*pFolderSearchResult);\r
- __pDividerLabel->Invalidate(true);\r
- }\r
- }\r
- break;\r
-\r
- case ID_SEARCH_COMPLETED:\r
- {\r
- AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");\r
- __isSearchCompleted = true;\r
-\r
- __pPopUpPanel->SetShowState(false);\r
- __pPopUpPanel->Invalidate(true);\r
- __pSearchBar->SetEnabled(true);\r
-\r
- __pSearchModel->StopSearch();\r
-\r
- if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)\r
- {\r
- __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
- __pSearchBar->SetMode(__searchBarMode);\r
- __pSearchBar->SetText(__searchText);\r
- }\r
-\r
- //Scroll the List to top\r
- __pListView->ScrollToItem(0);\r
- }\r
- break;\r
-\r
- case ID_SEARCH_RESULT_FOUND:\r
- {\r
- AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");\r
- __isSearchCompleted = false;\r
- __searchItemIndex++;\r
- AppLogDebug("ItemCount::%d", __searchItemIndex);\r
-\r
- __pSearchBar->SetText(__searchText);\r
-\r
- DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));\r
- TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");\r
-\r
- AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());\r
-\r
- pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);\r
- r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);\r
-\r
- AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));\r
-\r
- TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");\r
-\r
- AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);\r
-\r
- __bIsResultList = true;\r
-\r
- result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);\r
- AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));\r
- }\r
- break;\r
-\r
- case FILE_MANAGING_RESULT_DELETING_SUCCESS:\r
- {\r
- AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");\r
- HideFileProgressingPopup();\r
- pCacheList = CacheManager::GetInstance()->GetCacheHashMap();\r
-\r
- if (__isSearchCompleted == true || __isSearchStarted == true)\r
- {\r
- pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));\r
-\r
- if (pCurrentEntry != null)\r
- {\r
- cachePath = pCurrentEntry->GetFullFilePath();\r
- }\r
-\r
- if (pCacheList != null)\r
- {\r
- cacheKeyStatus = pCacheList->ContainsKey(cachePath);\r
- if (cacheKeyStatus)\r
- {\r
- CacheManager::GetInstance()->RemoveCacheEntry(cachePath);\r
- }\r
- }\r
- __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);\r
- }\r
- else\r
- {\r
- pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));\r
-\r
- if (pCurrentEntry != null)\r
- {\r
- cachePath = pCurrentEntry->GetFullFilePath();\r
- }\r
-\r
- if (pCacheList != null)\r
- {\r
- cacheKeyStatus = pCacheList->ContainsKey(cachePath);\r
- if (cacheKeyStatus)\r
- {\r
- CacheManager::GetInstance()->RemoveCacheEntry(cachePath);\r
- }\r
- }\r
- __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);\r
- }\r
- __pListView->UpdateList();\r
-\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
-\r
- pArgs->RemoveAll(true);\r
- delete pArgs;\r
- pArgs = null;\r
-\r
- AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");\r
- return;\r
-\r
- CATCH:\r
-\r
- AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");\r
- return;\r
-}\r
-\r
-void\r
-SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)\r
-{\r
- //Empty Implementation\r
-}\r
-\r
-void\r
-SearchForm::OnAllFoldersSearchCompleted(void)\r
-{\r
- //Empty Implementation\r
-}\r
-\r
-void\r
-SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)\r
-{\r
- result r = E_SUCCESS;\r
- ArrayList* pArg = null;\r
- SceneManager* pSceneManager = null;\r
- //int storageType = -1;\r
-\r
- if (__SelectedTab == MEMORY_TYPE_PHONE)\r
- {\r
- FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);\r
- }\r
- else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
- {\r
- FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);\r
- }\r
-\r
-\r
- FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);\r
-\r
- pArg = new (std::nothrow) ArrayList();\r
- TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");\r
-\r
- r = pArg->Construct();\r
- TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");\r
-\r
- pArg->Add(&fileName);\r
-\r
- pSceneManager = SceneManager::GetInstance();\r
- TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));\r
-\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);\r
- return;\r
-\r
-CATCH:\r
- if (pArg != null)\r
- {\r
- pArg->RemoveAll(true);\r
- delete pArg;\r
- pArg = null;\r
- }\r
- return;\r
-\r
-}\r
-void\r
-SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)\r
-{\r
- //Empty Implementation.\r
-}\r
-void\r
-SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)\r
-{\r
- AppLogDebug("Enter:SearchForm::OnThumbnailReceived");\r
- ArrayList* pResultList = null;\r
- result res = E_SUCCESS;\r
- DirectoryEntry* pFileDetails = null;\r
-\r
- TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");\r
-\r
- if (pThumbReq != null)\r
- {\r
- if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())\r
- {\r
- if (pThumbReq->pBitmap != null)\r
- {\r
- AppLogDebug("This Bitmap is not requested from same form");\r
- delete pThumbReq->pBitmap;\r
- }\r
- return;\r
- }\r
- }\r
-\r
- if (__isSearchCompleted == false)\r
- {\r
- if (__isSearchStarted == true)\r
- pResultList = __pSearchedContentList;\r
- else\r
- pResultList = __pContentListFromLastView;\r
- }\r
- else\r
- pResultList = __pSearchedContentList;\r
-\r
- TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");\r
-\r
- if (pThumbReq->iRquestId < pResultList->GetCount())\r
- {\r
- pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));\r
- TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");\r
-\r
- pFileDetails->SetBitmap(pThumbReq->pBitmap);\r
- if (__pListView && __pListView->IsVisible())\r
- {\r
- res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);\r
- }\r
- }\r
- else\r
- AppLogDebug("Thumbnail Request is not valid");\r
-\r
- AppLogDebug("Exit");\r
- return;\r
- CATCH:\r
- if (pThumbReq != null)\r
- {\r
- if (pThumbReq->pBitmap != null)\r
- delete pThumbReq->pBitmap;\r
- }\r
- AppLogDebug("Exit");\r
- return;\r
-\r
-}\r
-\r
-void\r
-SearchForm::LoadDetailForm(String& fullFilePath)\r
-{\r
- AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());\r
- result r = E_FAILURE;\r
-\r
- SceneManager* pSceneManager = null;\r
- ArrayList* pList = null;\r
- String* pFullFilePath = null;\r
-\r
- pList = new (std::nothrow) ArrayList();\r
- TryCatch(pList != null, , "Failed to create pList");\r
-\r
- r = pList->Construct();\r
- TryCatch(r == E_SUCCESS, , "Failed to construct pList");\r
-\r
- pFullFilePath = new (std::nothrow) String(fullFilePath);\r
-\r
- r = pList->Add(pFullFilePath);\r
- TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");\r
-\r
- pSceneManager = SceneManager::GetInstance();\r
- TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");\r
-\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);\r
- AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));\r
- return;\r
-\r
- CATCH:\r
-\r
- if (pFullFilePath != null)\r
- {\r
- delete pFullFilePath;\r
- pFullFilePath = null;\r
- }\r
- if (pList != null)\r
- {\r
- delete pList;\r
- pList = null;\r
- }\r
- return;\r
-}\r
-\r
-void\r
-SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)\r
-{\r
- AppLogDebug("ENTER");\r
- result r = E_SUCCESS;\r
-\r
- ArrayList* pArg = null;\r
- Integer* pSourceSelected = null;\r
- SceneManager* pSceneManager = null;\r
-\r
- __selectedItemIndexForRename = index;\r
-\r
- if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))\r
- __isCurrentDirectoryRenamed = true;\r
-\r
- pSceneManager = SceneManager::GetInstance();\r
- TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");\r
-\r
- pArg = new (std::nothrow) ArrayList;\r
- r = pArg->Construct();\r
-\r
- pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);\r
- r = pArg->Add(pSourceSelected);\r
- TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");\r
-\r
- r = pArg->Add(pDirectory);\r
- TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");\r
-\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);\r
-\r
- return;\r
-\r
-CATCH:\r
- if (pSourceSelected != null)\r
- {\r
- delete pSourceSelected;\r
- }\r
-\r
-\r
- delete pDirectory;\r
-\r
- if (pArg != null)\r
- {\r
- delete pArg;\r
- pArg = null;\r
- }\r
- return;\r
-}\r
-\r
-\r
-void\r
-SearchForm::DeleteFile(String& filePath)\r
-{\r
- AppLogDebug("ENTER");\r
-\r
- ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);\r
- ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
-\r
- FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();\r
- if (__pFileManager != null)\r
- {\r
- __pFileManager->SetFileManagingListener(this);\r
- __pFileManager->DeleteFolderEntries(&filePath);\r
- }\r
-\r
- AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));\r
-}\r
-\r
-\r
-void\r
-SearchForm::OnFileManagingStart(void)\r
-{\r
- AppLogDebug("Entry");\r
- ShowFileProgressingPopup();\r
-}\r
-\r
-void\r
-SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)\r
-{\r
- //Empty Implementation\r
-}\r
-\r
-void\r
-SearchForm::ShowFileProgressingPopup(void)\r
-{\r
- CreateFileProgressingPopup();\r
-\r
- if (__pFileProgressingPopup != null)\r
- {\r
- __pFileProgressingPopup->SetShowState(true);\r
- __pFileProgressingPopup->Show();\r
- }\r
-}\r
-\r
-void\r
-SearchForm::HideFileProgressingPopup(void)\r
-{\r
- AppLogDebug("HideFileProgressingPopup:ENTER");\r
- if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())\r
- {\r
- __pFileProgressingPopup->SetShowState(false);\r
-\r
- delete __pFileProgressingPopup;\r
- __pFileProgressingPopup = null;\r
- }\r
-}\r
-\r
-result\r
-SearchForm::CreateFileProgressingPopup(void)\r
-{\r
- AppLogDebug("ENTER");\r
- result r = E_SUCCESS;\r
- String deleting;\r
-\r
- AppResource* pAppResource = null;\r
- pAppResource = UiApp::GetInstance()->GetAppResource();\r
- TryReturn(pAppResource != null, r, "Failed to fetch AppResource");\r
-\r
- pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);\r
-\r
- __pFileProgressingPopup = new (std::nothrow) Popup();\r
- __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");\r
-\r
- __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));\r
- if (__pFileProgressingCancelButton != null)\r
- {\r
- __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);\r
- __pFileProgressingCancelButton->AddActionEventListener(*this);\r
- }\r
- __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));\r
- if (__pFileProgressingProgress != null)\r
- {\r
- __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");\r
- __pFileProgressingProgress->SetValue(0);\r
- }\r
- __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));\r
- if (__pFileProgressingHeaderLabel != null)\r
- {\r
- __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");\r
- __pFileProgressingHeaderLabel->SetText(deleting);\r
- }\r
- __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));\r
- if (__pFileProgressingLabel != null)\r
- {\r
- __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");\r
- }\r
-\r
- return r;\r
-\r
-}\r
-\r
-result\r
-SearchForm::CreateDeleteConfirmationPopup(void)\r
-{\r
- result r = E_SUCCESS;\r
- Rectangle popupBounds;\r
-\r
- //Create a Delete popup control\r
- __pDeleteConfirmationPopUp = new (std::nothrow) Popup();\r
- __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");\r
-\r
- popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();\r
-\r
-\r
- __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));\r
- TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");\r
-\r
- __pDelete->SetActionId(IDA_DELETE_FILE);\r
- __pDelete->AddActionEventListener(*this);\r
- __pDelete->SetShowState(true);\r
-\r
- __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));\r
- TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");\r
-\r
- __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);\r
- __pCancelDeletion->AddActionEventListener(*this);\r
- __pCancelDeletion->SetShowState(true);\r
-\r
- return r;\r
-\r
-CATCH:\r
-\r
- if (__pDeleteConfirmationPopUp != null)\r
- {\r
- delete __pDeleteConfirmationPopUp;\r
- __pDeleteConfirmationPopUp = null;\r
- }\r
-\r
- return r;\r
-\r
-}\r
-\r
-void\r
-SearchForm::HideDeleteConfirmationPopup(void)\r
-{\r
- if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())\r
- {\r
- __pDeleteConfirmationPopUp->SetShowState(false);\r
-\r
- delete __pDeleteConfirmationPopUp;\r
- __pDeleteConfirmationPopUp = null;\r
-\r
- }\r
-}\r
-\r
-void\r
-SearchForm::ShowDeleteConfirmationPopup(void)\r
-{\r
- CreateDeleteConfirmationPopup();\r
-\r
- if (__pDeleteConfirmationPopUp != null)\r
- {\r
- __pDeleteConfirmationPopUp->SetShowState(true);\r
- __pDeleteConfirmationPopUp->Show();\r
- }\r
-}\r
-\r
-void\r
-SearchForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)\r
-{\r
- bool setMediaPath = false;\r
- MemoryType currentMemoryType = MEMORY_TYPE_PHONE;\r
- String unmounted = sdCardStatusUnmounted;\r
- String removed = usbDeviceStatusRemoved;\r
- String currentPath;\r
- SceneManager* pSceneManager = null;\r
-\r
- if (state == unmounted || state == removed)\r
- {\r
- currentPath = FolderNavigationPresentationModel::GetCurrentPath();\r
- if (state == unmounted)\r
- {\r
- if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))\r
- {\r
- FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
- FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
- setMediaPath = true;\r
- }\r
- }\r
-\r
- if (state == removed)\r
- {\r
- if (currentPath.Contains(BasePresentationModel::GetUsbPath()))\r
- {\r
- FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
- FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
- setMediaPath = true;\r
- }\r
- }\r
-\r
- if (setMediaPath)\r
- {\r
- pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager != null)\r
- {\r
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null); }\r
- }\r
- }\r
-}\r
-\r
-void\r
-SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)\r
-{\r
- ComponentType currentDeviceType;\r
- switch (deviceType)\r
- {\r
- case StorageCard:\r
- {\r
- currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;\r
- }\r
- break;\r
-\r
- case UsbClient:\r
- {\r
- currentDeviceType = COMPONENT_TYPE_USB;\r
- }\r
- break;\r
-\r
- default:\r
- {\r
- //Do Nothing.\r
- }\r
- break;\r
- }\r
- OnDeviceChange(currentDeviceType, state);\r
-}\r
-\r
-void\r
-SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,\r
- const Tizen::Ui::Scenes::SceneId ¤tSceneId)\r
-{\r
- SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);\r
-// __pSearchBar->SetText(L"");\r
- __pSearchBar->SetMode(__searchBarMode);\r
-\r
-\r
- if (__pFileEventManager != null)\r
- {\r
- delete __pFileEventManager;\r
- __pFileEventManager = null;\r
-\r
- }\r
- __pFileEventManager = new (std::nothrow) FileEventManager();\r
- __pFileEventManager->Construct(*this);\r
-\r
- //__pFileEventManager->AddPath(__currentSearchDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );\r
-\r
- if (__bCheckArgsNull)\r
- {\r
- if (__pListView != null)\r
- {\r
- __pListView->UpdateList();\r
- }\r
- }\r
- else\r
- {\r
- if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)\r
- {\r
- __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);\r
- }\r
- }\r
-}\r
-\r
-void\r
-SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,\r
- const Tizen::Ui::Scenes::SceneId &nextSceneId)\r
-{\r
- //Empty Implementation.\r
-}\r
-\r
-void\r
-SearchForm::StartSearch(void)\r
-{\r
- String searchtext;\r
- String folderToSearch;\r
- String topLevelPath;\r
-\r
- //Hide keypad of Search bar\r
- __pSearchBar->HideKeypad();\r
- __pSearchBar->SetContentAreaVisible(true);\r
- __pSearchBar->SetEnabled(false);\r
-\r
- //Show Popup\r
- __pDividerLabel->SetText(folderToSearch);\r
- __pPopUpPanel->SetShowState(true);\r
- __pPopUpPanel->Invalidate(true);\r
-\r
- ///Set Application Notification Listener to current form\r
- ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);\r
-\r
- if (__SelectedTab == MEMORY_TYPE_PHONE)\r
- {\r
- //topLevelPath = folderEntryPM.GetMediaPath();\r
- topLevelPath = __pFolderEntryPM->GetMediaPath();\r
- }\r
- else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
- {\r
- //topLevelPath = folderEntryPM.GetSdCardPath();\r
- topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
- }\r
-\r
- if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))\r
- {\r
- __searchedAllFolders = true;\r
- }\r
-\r
- if (__pSearchedContentList != null)\r
- {\r
- __pSearchedContentList->RemoveAll(true);\r
- }\r
- __searchItemIndex = INVALID_LIST_INDEX;\r
- __isSearchCompleted = false;\r
- __isSearchStarted = true;\r
-\r
- __pListView->UpdateList();\r
-\r
- __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);\r
- __pSearchModel->SetStringToSearch(__searchText);\r
- __pSearchModel->Start();\r
-}\r
-\r
-void\r
-SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)\r
-{\r
- if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))\r
- {\r
- __pSearchBar->SetMode(__searchBarMode);\r
-\r
- if (__searchText.IsEmpty() == false)\r
- StartSearch();\r
-\r
- if (__pListView != null)\r
- __pListView->UpdateList();\r
- }\r
-}\r
-\r
-void\r
-SearchForm::GetFolderName(void)\r
-{\r
- String delim(L"/");\r
- String token;\r
- String fullPath;\r
- String folderName(L"Search ");\r
-\r
- fullPath = FolderNavigationPresentationModel::GetCurrentPath();\r
-\r
- StringTokenizer tokenizer(fullPath, delim);\r
-\r
-#if 0\r
- DataBindingContext* pContext = null;\r
- pContext = GetDataBindingContextN();\r
-#endif\r
-\r
- int Counter = 3;\r
-\r
- //Use a string tokenizer to get the filepath until it's the last token, break the loop when\r
- //it is the last token\r
- while (tokenizer.HasMoreTokens())\r
- {\r
- if (Counter > 0)\r
- {\r
- Counter--;\r
- tokenizer.GetNextToken(token);\r
- }\r
- else\r
- {\r
- tokenizer.GetNextToken(token);\r
- folderName.Append(token);\r
- }\r
- }\r
-\r
- if (__pSearchBar != null)\r
- {\r
- __pSearchBar->SetGuideText(folderName);\r
- }\r
-}\r
-\r
-void\r
-SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)\r
-{\r
- String displayPath;\r
- String delim(L"/");\r
- String token;\r
-\r
- StringTokenizer tokenizer(*filePath, delim);\r
-\r
- filePath->Clear();\r
-\r
- //Use a string tokenizer to get the filepath until it's the last token, break the loop when\r
- //it is the last token\r
- while (tokenizer.HasMoreTokens())\r
- {\r
- if (tokenizer.GetTokenCount() != 1)\r
- {\r
- filePath->Append(L"/");\r
- tokenizer.GetNextToken(token);\r
- filePath->Append(token);\r
- }\r
- else\r
- {\r
- break;\r
- }\r
- }\r
-\r
- filePath->Append(L"/");\r
-\r
- if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))\r
- {\r
- filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);\r
- }\r
- else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))\r
- {\r
- filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);\r
- }\r
-\r
-}\r
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file: SearchForm.cpp
+ * @brief: This file contains implementation of SearchForm.
+ */
+
+#include "MfSearchForm.h"
+
+using namespace Tizen::App;
+using namespace Tizen::App::Package;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Content;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+int SearchForm::searchBackSelected = 0;
+SearchForm::SearchForm(void)
+{
+ __pContentListFromLastView = null;
+ __pSearchedContentList = null;
+
+ __pListView = null;
+ __pSearchBar = null;
+ __pSearchPopup = null;
+ __pPopUpSearching = null;
+ __pCancelSearch = null;
+ __pDividerLabel = null;
+
+ __pThumbnailManager = null;
+ __pSearchModel = null;
+
+ __searchText = L"";
+ __currentSearchDirectoryPath = L"";
+ __bIsResultList = false;
+
+ __searchedAllFolders = false;
+ __isSearchCompleted = false;
+ __isCancelClicked = false;
+ __isSearchStarted = false;
+ __bCheckArgsNull = false;
+ __isCurrentDirectoryRenamed = false;
+
+ __itemCount = -1;
+ __searchItemIndex = INVALID_LIST_INDEX;
+
+ __pFolderBitmap = null;
+ __pDummyImage = null;
+
+ __pDeleteConfirmationPopUp = null;
+
+ __selectedItemIndexForRename = 0;
+ __selectedItemIndexForDelete = 0;
+ __SelectedTab = MEMORY_TYPE_NONE;
+ __previouFormTab = MEMORY_TYPE_NONE;
+
+ __pCancelDeletion = null;
+ __pDelete = null;
+ __pFileProgressingCancelButton = null;
+ __pFileProgressingHeaderLabel = null;
+ __pItemContext = null;
+ __pFileProgressingPopup = null;
+ __pFileProgressingProgress = null;
+ __pFileEventManager = null;
+}
+
+SearchForm::~SearchForm(void)
+{
+ AppLogDebug("Entry");
+
+ if (__pSearchedContentList != null)
+ {
+ __pSearchedContentList->RemoveAll(true);
+ delete __pSearchedContentList;
+ }
+
+ if (__pSearchModel != null)
+ {
+ delete __pSearchModel;
+ }
+
+ if (__pItemContext != null)
+ {
+ delete __pItemContext;
+ }
+
+ if (__pDeleteConfirmationPopUp != null)
+ {
+ delete __pDeleteConfirmationPopUp;
+ }
+ if(__pFolderEntryPM != null)
+ {
+ delete __pFolderEntryPM;
+ }
+ if (__pFileEventManager != null)
+ {
+ delete __pFileEventManager;
+ }
+
+}
+
+SearchForm&
+SearchForm::operator =(const SearchForm& pSearchForm)
+{
+ return *this;
+}
+
+SearchForm::SearchForm(const SearchForm& pSearchForm)
+{
+ __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
+ __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
+}
+
+
+bool
+SearchForm::Initialize(void)
+{
+ result r = Form::Construct(L"IDL_SEARCH");
+ if (r != E_SUCCESS)
+ {
+ AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
+ return false;
+ }
+ return true;
+}
+
+result
+SearchForm::OnInitializing(void)
+{
+ AppLogDebug("ENTER::SearchForm::OnInitializing");
+ result r = E_SUCCESS;
+ String cancelButton(L"");
+
+ Bitmap* pMainLabelBg = null;
+ Bitmap* pDeleteNormalBmp = null;
+ Bitmap* pDeletePressBmp = null;
+ String renameButtonText;
+ String detailButtonText;
+ String deleteButtonText;
+ String strSearching ;
+ IListT< SceneId >* pSceneList = null;
+
+ __SelectedTab = MEMORY_TYPE_NONE;
+
+ __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
+ __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
+ AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);
+ AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);
+ AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);
+
+ pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);
+ pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);
+
+ Footer* pFooter = GetFooter();
+ pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
+ pFooter->SetBackButton();
+
+ SetFormBackEventListener(this);
+ __pThumbnailManager = ThumbnailManager::GetInstance();
+ TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
+
+ ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
+
+ __searchBarMode = SEARCH_BAR_MODE_INPUT;
+
+ __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));
+ TryCatch(__pSearchBar != null, , "__pSearchBar is Null");
+
+ __pSearchBar->AddSearchBarEventListener(*this);
+ __pSearchBar->AddTextEventListener(*this);
+ __pSearchBar->AddKeypadEventListener(*this);
+ __pSearchBar->SetShowState(true);
+
+ __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
+ TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");
+ __pFolderEntryPM->Construct();
+
+ __pSearchPopup = new (std::nothrow) Popup();
+ TryCatch(__pSearchPopup != null, , "Failed to allocate memory to __pSearchPopup");
+
+ r = __pSearchPopup->Construct(L"IDL_SEARCH_POPUP");
+ TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");
+
+ __pPopUpSearching = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_SEARCHING"));
+ TryCatch(__pPopUpSearching != null, , "Failed to get __pPopUpSearching");
+
+ __pDividerLabel = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_FOLDER"));
+ TryCatch(__pDividerLabel != null, r = GetLastResult(), "Failed to get __pPopUpSearching");
+
+ __pCancelSearch = static_cast<Button*> (__pSearchPopup->GetControl(L"IDC_BUTTON_CANCEL"));
+ TryCatch(__pCancelSearch != null, , "Failed to get __pCancelSearch");
+
+ __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);
+ __pCancelSearch->AddActionEventListener(*this);
+
+ __pSearchPopup->SetShowState(false);
+
+
+ __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);
+
+ __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));
+ TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");
+
+ __pListView->SetItemProvider(*this);
+ __pListView->AddListViewItemEventListener(*this);
+
+ __pSearchModel = new (std::nothrow) SearchPresentationModel();
+ TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");
+
+ r = __pSearchModel->Initialize();
+ TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));
+
+ __pSearchedContentList = new (std::nothrow) ArrayList();
+ TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");
+
+ r = __pSearchedContentList->Construct();
+ TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");
+
+ __pItemContext = new (std::nothrow) ListContextItem();
+
+ r = __pItemContext->Construct();
+ TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");
+
+ __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);
+ __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);
+
+ __pItemContext->AddElement(IDA_CONTEXT_DELETE,
+ deleteButtonText,
+ *pDeleteNormalBmp,
+ *pDeletePressBmp,
+ null,
+ true);
+
+ __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
+ __previouFormTab = FolderNavigationPresentationModel::GetStorageType();
+ pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();
+ if (pSceneList != null)
+ {
+ __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
+ }
+
+ GetFolderName();
+
+ if (pDeleteNormalBmp != null)
+ {
+ delete pDeleteNormalBmp;
+ pDeleteNormalBmp = null;
+ }
+ if (pDeletePressBmp != null)
+ {
+ delete pDeletePressBmp;
+ pDeletePressBmp = null;
+ }
+
+ if (pMainLabelBg != null)
+ {
+ delete pMainLabelBg;
+ pMainLabelBg = null;
+ }
+ AppLogDebug("Exit");
+ return r;
+
+CATCH:
+
+ if (__pSearchBar != null)
+ {
+ delete __pSearchBar;
+ }
+ if (__pListView != null)
+ {
+ delete __pListView;
+ }
+ if (__pSearchModel != null)
+ {
+ delete __pSearchModel;
+ }
+
+ delete pDeleteNormalBmp;
+
+ delete pDeletePressBmp;
+
+ delete pMainLabelBg;
+
+ AppLogDebug("EXIT::SearchForm::OnInitializing");
+ return r;
+}
+
+result
+SearchForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
+
+ if (__pFolderBitmap)
+ delete __pFolderBitmap;
+
+ if (__pDummyImage)
+ delete __pDummyImage;
+ return r;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+// Call-back functions
+////////////////////////////////////////////////////////////////////////
+
+void
+SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+ const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
+{
+ AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
+
+ ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
+
+ DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+#if 0
+ DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
+#endif
+
+ SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
+
+ if (pArgs != null)
+ {
+ __bCheckArgsNull = true;
+
+ __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
+ __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
+
+ if (__pFolderEntryPM != null)
+ {
+ __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
+ if (__currentSearchDirectoryPath.IsEmpty() == false)
+ {
+ __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
+ __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
+ TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
+ }
+ }
+ __isSearchCompleted = false;
+ __isSearchStarted = false;
+
+ String topLevelPath = L"";
+
+
+ if (__SelectedTab == MEMORY_TYPE_PHONE)
+ {
+ topLevelPath = __pFolderEntryPM->GetMediaPath();
+ }
+ else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
+ {
+ topLevelPath = __pFolderEntryPM->GetSdCardPath();
+ }
+
+ if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
+ {
+ AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
+ __pDividerLabel->SetText(__currentSearchDirectoryPath);
+ }
+
+ pArgs->RemoveAll(false);
+ delete pArgs;
+ pArgs = null;
+
+ }
+ else
+ {
+ __bCheckArgsNull = false;
+ }
+
+ AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
+ return;
+
+ CATCH:
+ AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
+ return;
+
+}
+
+void
+SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
+ const Tizen::Ui::Scenes::SceneId& nextSceneId)
+{
+ DeviceManager::RemoveAllDeviceEventListeners();
+}
+
+void
+SearchForm::OnFormBackRequested(Form& source)
+{
+ TransitionScene();
+}
+
+void
+SearchForm::TransitionScene(void)
+{
+ //String rootMediaPath = BasePresentationModel::GetHomePath();
+ String rootMediaPath = BasePresentationModel::GetMediaPath();
+ SceneManager* pSceneManager = null;
+ pSceneManager = SceneManager::GetInstance();
+
+ if (__isSearchStarted == true && __isSearchCompleted == false)
+ {
+ __pSearchModel->StopSearch();
+ }
+
+ if (__previousFormPath.CompareTo("") != 0)
+ {
+ if (__isCurrentDirectoryRenamed == false)
+ FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
+ FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
+ AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
+ }
+
+ if(__pFileEventManager != null)
+ __pFileEventManager->RemovePath(__currentSearchDirectoryPath);
+
+// pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
+
+ if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
+ {
+ if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
+ {
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
+ }
+ else
+ {
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
+ }
+ }
+ else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+ {
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
+ }
+ else
+ {
+ pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
+ }
+}
+
+void
+SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
+{
+ int modalResult = 0;
+ CustomAppControl* pCustomAppControl = null;
+ String topLevelPath;
+ String emptySearchString;
+
+ DirectoryEntry* pFileDetails = null;
+ MessageBox messageEmptyString;
+
+ AppResource* pAppResource = null;
+
+
+ pAppResource = UiApp::GetInstance()->GetAppResource();
+ TryReturn(pAppResource != null, , "Failed to fetch AppResource");
+
+ pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
+
+ __pathOfSelectedFile = L"";
+
+ if (__isCancelClicked == true)
+ {
+ return;
+ }
+ if (index == __itemCount && __searchedAllFolders == false)
+ {
+ AppLogDebug("SearchPresentationModel::Search:%d", index);
+ messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
+
+ if (__pSearchBar->GetText().IsEmpty())
+ {
+ messageEmptyString.ShowAndWait(modalResult);
+ return;
+ }
+
+ __searchedAllFolders = true;
+
+ __searchItemIndex = INVALID_LIST_INDEX;
+ //Free the content of __pSearchedContentList and Delete the same before searching again
+ if (__pSearchedContentList != null)
+ {
+ __pSearchedContentList->RemoveAll(true);
+ }
+
+ __pListView->UpdateList();
+ __pDividerLabel->SetText(L"");
+ __pSearchPopup->SetShowState(true);
+ __pSearchPopup->Show();
+ __pSearchBar->SetEnabled(false);
+
+ if (__SelectedTab == MEMORY_TYPE_PHONE)
+ {
+ topLevelPath = __pFolderEntryPM->GetMediaPath();
+ }
+ else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
+ {
+ topLevelPath = __pFolderEntryPM->GetSdCardPath();
+ }
+
+ __pSearchModel->SetFolderToSearch(topLevelPath);
+ __pSearchModel->SetStringToSearch(__searchText);
+ __pSearchModel->Start();
+ }
+ else
+ {
+
+ if (__isSearchCompleted == false && __isSearchStarted == false)
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
+ }
+ else
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
+ }
+ TryCatch(pFileDetails != null, , "pFileDetails is Null")
+
+
+ __pathOfSelectedFile = pFileDetails->GetFullFilePath();
+
+ if (pFileDetails->IsDirectory() == true)
+ {
+ String fileName = pFileDetails->GetFileName();
+ String filePath = pFileDetails->GetFullFilePath();
+ LoadSubDirectoryForm(filePath, fileName);
+ }
+ else
+ {
+ //Else launch the corresponding AppControl.
+ if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))
+ {
+ String* pFileUriScheme = new (std::nothrow) String(L"file://");
+ pFileUriScheme->Append(__pathOfSelectedFile);
+
+ AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
+ delete pFileUriScheme;
+ }
+ else
+ {
+ String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
+ String parentDirectoryOfSelectedFile = L"";
+ __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
+
+ pCustomAppControl = CustomAppControl::GetInstance();
+ if (pCustomAppControl != null)
+ {
+ pCustomAppControl->SetAppControlListener(this);
+ __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
+ AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
+ if (pAppControlInUse != null)
+ CustomAppControl::SetAppControlInUse(pAppControlInUse);
+ }
+ }
+ }
+ }
+ return;
+
+ CATCH:
+ return;
+}
+
+void
+SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
+{
+ //Empty Implementation.
+}
+
+void
+SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
+{
+ AppLogDebug("Enter");
+ AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
+
+ String filePath = L"";
+ DirectoryEntry* pFileDetails = null;
+
+ if (__isSearchCompleted == false)
+ {
+ if (__isSearchStarted == true)
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
+ }
+ else
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
+ }
+ }
+ else
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
+ }
+ TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
+
+ filePath.Append(pFileDetails->GetFullFilePath());
+
+ switch (elementId)
+ {
+ case IDA_CONTEXT_DETAIL:
+ {
+ LoadDetailForm(filePath);
+ }
+ break;
+
+ case IDA_CONTEXT_RENAME:
+ {
+ LoadRenameForm(index, pFileDetails);
+ }
+ break;
+
+ case IDA_CONTEXT_DELETE:
+ {
+ __selectedItemIndexForDelete = index;
+ __fileToDelete = pFileDetails->GetFullFilePath();
+
+ ShowDeleteConfirmationPopup();
+
+ }
+ break;
+
+ default:
+ {
+ //Do nothing
+ }
+ break;
+ }
+
+ CATCH:
+
+ AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
+}
+
+int
+SearchForm::GetItemCount(void)
+{
+ AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
+ int count = 0;
+
+ TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
+
+ if (__isSearchCompleted == false)
+ {
+ if (__isSearchStarted == true)
+ count = __pSearchedContentList->GetCount();
+ else
+ {
+ if (__pContentListFromLastView != null)
+ count = __pContentListFromLastView->GetCount();
+ }
+ }
+ else
+ {
+ count = __pSearchedContentList->GetCount();
+ String topLevelPath = L"";
+
+ if (__SelectedTab == MEMORY_TYPE_PHONE)
+ {
+ topLevelPath = defaultPhoneBody;
+ topLevelPath.Append("/");
+ }
+ else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
+ {
+ topLevelPath = defaultSdCardBody;
+ topLevelPath.Append("/");
+ }
+
+ if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
+ {
+ __itemCount = count++;
+ }
+ }
+ AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
+ return count;
+
+ CATCH:
+ AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
+ return count;
+}
+
+ListItemBase*
+SearchForm::CreateItem(int index, int itemWidth)
+{
+ AppLogDebug("ENTER::SearchForm::CreateItem");
+ result r = E_SUCCESS;
+ String filename;
+ String imageIconPath;
+ String strHightlightedText;
+ String filepath;
+ String cacheImagePath;
+
+ Bitmap* pFetchedCacheImage = null;
+ Bitmap* pThumbnailImage = null;
+ HashMap* pCacheList = null;
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+
+ Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
+ Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
+
+ AppResource* pAppResource = null;
+ DirectoryEntry* pFileDetails = null;
+ ContentListItem* pCustomItem = null;
+ ThumbRequest* pThumbReq = null;
+
+ ArrayList* pList = null;
+
+ if (index == __itemCount && __searchedAllFolders == false)
+ {
+ CustomItem* pItem = null;
+ String searchAllFolder = L"";
+ AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
+ pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
+ return pItem;
+ }
+
+ pAppResource = Application::GetInstance()->GetAppResource();
+ TryCatch(pAppResource != null, , "Resource manager not found!");
+
+ if (__isSearchCompleted == false)
+ {
+ if (__isSearchStarted == true)
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
+ }
+ else
+ {
+ if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
+ pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
+ }
+ }
+ else
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
+ }
+ TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
+
+ pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);
+ TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
+
+ filename.Clear();
+ filename.Append(pFileDetails->GetFileName());
+
+ filepath.Clear();
+ filepath.Append(pFileDetails->GetFullFilePath());
+
+ if (pFileDetails->IsDirectory() == false)
+ {
+ filename.Append(".");
+ filename.Append(pFileDetails->GetFileExtension());
+ }
+
+ if (__searchText.GetLength() > 0)
+ strHightlightedText.Append(__searchText);
+
+ pCustomItem->SetTitle(filename, strHightlightedText);
+
+#if 0
+ if (__pThumbnailManager != null)
+ {
+ if (pFileDetails->IsDirectory() == true)
+ {
+ pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
+ AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
+ }
+ else
+ {
+ imageIconPath = pFileDetails->GetFullFilePath();
+ pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
+ }
+ TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
+ }
+#else
+
+ contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
+ pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
+
+ if (pFileDetails->IsDirectory() == true)
+ {
+ pCustomItem->SetThumbnail(__pFolderBitmap);
+ }
+ else
+ {
+ if (pFileDetails->GetBitmap() == null)
+ {
+ if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
+ {
+ if (pFileDetails != null)
+ {
+ cacheImagePath = pFileDetails->GetFullFilePath();
+ AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
+ }
+
+ if ((pCacheList->GetValue(cacheImagePath)) != null)
+ {
+ pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
+ }
+ }
+
+ if (pFetchedCacheImage != null)
+ {
+ AppLogDebug("image taken from cachemanager");
+ pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
+ pCustomItem->SetThumbnail(pThumbnailImage);
+ }
+ else
+ {
+ pCustomItem->SetThumbnail(__pDummyImage);
+
+ pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
+ TryCatch(pThumbReq != null, , "ThumbRequest is null!");
+
+ pThumbReq->iRquestId = index;
+ pThumbReq->FilePath = pFileDetails->GetFullFilePath();
+
+ pList = new (std::nothrow) ArrayList();
+ TryCatch(pList != null, , "Failed to create pList");
+
+ r = pList->Construct();
+ TryCatch(r == E_SUCCESS, , "Failed to construct pList");
+
+ r = pList->Add(pThumbReq);
+ TryCatch(r == E_SUCCESS, , "Failed to add object to pList");
+
+ __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
+ }
+ }
+ else
+ {
+ pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
+ }
+ }
+#endif
+
+ pCustomItem->SetListAnnexStyle(ANNEX_STYLE_NORMAL);
+
+ if (__bIsResultList)
+ {
+ GetParentFolderPath(&filepath);
+ pCustomItem->SetFilepath(filepath);
+ pCustomItem->MakeSearchFormListItem();
+ }
+ else
+ {
+ pCustomItem->Make();
+ } pCustomItem->SetContextItem(__pItemContext);
+
+ AppLogDebug("EXIT::SearchForm::CreateItem");
+ return pCustomItem;
+
+CATCH:
+ if (pCustomItem != null)
+ {
+ delete pCustomItem;
+ }
+ if (pList != null)
+ {
+ delete pList;
+ }
+ if (pThumbReq)
+ {
+ delete pThumbReq;
+ }
+ AppLogDebug("EXIT::SearchForm::CreateItem");
+ return null;
+}
+
+bool
+SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
+{
+ AppLogDebug("ENTER::SearchForm::DeleteItem");
+ if (pItem != null)
+ {
+ delete pItem;
+ pItem = null;
+ }
+ AppLogDebug("EXIT::SearchForm::DeleteItem");
+ return true;
+}
+
+void
+SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
+{
+ AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
+ int modalResult = 0;
+ String emptySearchString;
+
+ MessageBox messageEmptyString;
+ AppResource* pAppResource = null;
+
+ pAppResource = UiApp::GetInstance()->GetAppResource();
+ TryReturn(pAppResource != null, , "Failed to fetch AppResource");
+
+ pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
+
+ messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
+
+
+ if (__pSearchBar->GetText().IsEmpty())
+ {
+ messageEmptyString.ShowAndWait(modalResult);
+ __pSearchBar->ShowKeypad();
+ return;
+ }
+
+ __isCancelClicked = false;
+
+ //Get the text entered in SearchBar
+ __searchText.Clear();
+ __searchText = __pSearchBar->GetText();
+
+ //Start Searching
+ if (__searchText.IsEmpty() == false)
+ StartSearch();
+
+ AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
+}
+void
+SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
+{
+ AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
+
+ __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+ __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+
+ AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
+}
+void
+SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
+{
+ SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+
+ __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+ __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+
+}
+void
+SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
+{
+ //Empty Implementation
+}
+void
+SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ AppLogDebug("ENTER::SearchForm::OnActionPerformed");
+ switch (actionId)
+ {
+ case IDA_BTN_POPUP_SEARCH_CANCEL:
+ {
+ AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
+ __isSearchCompleted = true;
+
+ __pSearchModel->StopSearch();
+
+ __searchBarMode = SEARCH_BAR_MODE_NORMAL;
+ __pSearchBar->SetMode(__searchBarMode);
+ __pSearchBar->HideKeypad();
+
+ __pSearchPopup->SetShowState(false);
+ __pSearchBar->SetEnabled(true);
+
+ SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+ __searchText.Clear();
+
+ }
+ break;
+
+ case IDA_DELETE_FILE:
+ {
+ HideDeleteConfirmationPopup();
+ //Call the DeleteFile Function.
+ DeleteFile(__fileToDelete);
+ }
+ break;
+
+ case IDA_CANCEL_DELETION:
+ {
+ HideDeleteConfirmationPopup();
+ }
+ break;
+
+ default:
+ {
+ //Do nothing
+ }
+ break;
+ }
+ AppLogDebug("EXIT::SearchForm::OnActionPerformed");
+}
+void
+SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
+{
+ AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
+ if (__pSearchPopup->GetShowState() == true)
+ {
+ __pSearchPopup->SetShowState(false);
+ __pSearchBar->SetEnabled(true);
+ }
+}
+
+void
+SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
+{
+ //Empty Implementation.
+}
+
+//SearchBar Control
+void
+SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
+{
+ AppLogDebug("SearchForm::OnSearchBarModeChanged");
+
+ if (mode == SEARCH_BAR_MODE_INPUT)
+ {
+ __searchBarMode = SEARCH_BAR_MODE_INPUT;
+ SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+ }
+ else
+ {
+ __searchBarMode = SEARCH_BAR_MODE_NORMAL;
+ SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+ if (__isSearchStarted == true)
+ {
+ if (__isSearchCompleted == false)
+ {
+ //Stop Search Thread
+ __pSearchModel->StopSearch();
+
+ //Hide keypad of SearchBar
+ __pSearchBar->HideKeypad();
+
+ //Hide popUp
+ if (__pSearchPopup != null)
+ {
+ __pSearchPopup->SetShowState(false);
+ }
+ }
+ }
+ __pListView->UpdateList();
+ }
+
+ __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+ __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
+
+ __pSearchBar->Invalidate(true);
+}
+
+void
+SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
+{
+ CustomAppControl::GetInstance()->SetAppControlInUse(null);
+ ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);
+
+ __pSearchBar->SetMode(__searchBarMode);
+
+ if (GetLastResult() == E_FILE_NOT_FOUND)
+ {
+ __isSearchCompleted = false;
+ if (__searchText.IsEmpty() == false)
+ StartSearch();
+ }
+ else
+ {
+ AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);
+ }
+
+ if (__pListView != null)
+ __pListView->UpdateList();
+}
+
+void
+SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
+{
+ AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
+ result r = E_FAILURE;
+ Integer* pEventType = null;
+ DirectoryEntry* pResultDirEntry = null;
+ HashMap* pCacheList = null;
+ DirectoryEntry* pCurrentEntry = null;
+ bool cacheKeyStatus = false;
+ String cachePath;
+
+ TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
+
+ pEventType = static_cast< Integer* >(pArgs->GetAt(0));
+ TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
+
+ switch (pEventType->ToInt())
+ {
+ case ID_FOLDER_SEARCH_STARTED:
+ {
+ String* pFolderSearchResult = (String*) pArgs->GetAt(1);
+ TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
+
+ String defMediaPath(L"/opt/usr/media");
+ String defSdCardPath(L"/opt/storage/sdcard");
+
+ String displayPhone = defaultPhoneBody;
+ String displaySdCard = defaultSdCardBody;
+
+
+ if (pFolderSearchResult->IsEmpty() == false)
+ {
+ if (pFolderSearchResult->StartsWith(defMediaPath, 0))
+ {
+ pFolderSearchResult->Replace(defMediaPath, displayPhone);
+ }
+ else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
+ {
+ pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
+ }
+
+ __pDividerLabel->SetText(*pFolderSearchResult);
+ __pDividerLabel->Invalidate(true);
+ }
+ }
+ break;
+
+ case ID_SEARCH_COMPLETED:
+ {
+ AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
+ __isSearchCompleted = true;
+
+ __pSearchPopup->SetShowState(false);
+ __pSearchBar->SetEnabled(true);
+
+ __pSearchModel->StopSearch();
+
+ if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
+ {
+ __searchBarMode = SEARCH_BAR_MODE_NORMAL;
+ __pSearchBar->SetMode(__searchBarMode);
+ __pSearchBar->SetText(__searchText);
+ }
+
+ //Scroll the List to top
+ __pListView->ScrollToItem(0);
+ }
+ break;
+
+ case ID_SEARCH_RESULT_FOUND:
+ {
+ AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
+ __isSearchCompleted = false;
+ __searchItemIndex++;
+ AppLogDebug("ItemCount::%d", __searchItemIndex);
+
+ __pSearchBar->SetText(__searchText);
+
+ DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
+ TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
+
+ AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
+
+ pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
+ r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
+
+ AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
+
+ TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
+
+ AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
+
+ __bIsResultList = true;
+
+ result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
+ AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
+ }
+ break;
+
+ case FILE_MANAGING_RESULT_DELETING_SUCCESS:
+ {
+ AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
+ HideFileProgressingPopup();
+ pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
+
+ if (__isSearchCompleted == true || __isSearchStarted == true)
+ {
+ pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
+
+ if (pCurrentEntry != null)
+ {
+ cachePath = pCurrentEntry->GetFullFilePath();
+ }
+
+ if (pCacheList != null)
+ {
+ cacheKeyStatus = pCacheList->ContainsKey(cachePath);
+ if (cacheKeyStatus)
+ {
+ CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
+ }
+ }
+ __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
+ }
+ else
+ {
+ pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
+
+ if (pCurrentEntry != null)
+ {
+ cachePath = pCurrentEntry->GetFullFilePath();
+ }
+
+ if (pCacheList != null)
+ {
+ cacheKeyStatus = pCacheList->ContainsKey(cachePath);
+ if (cacheKeyStatus)
+ {
+ CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
+ }
+ }
+ __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
+ }
+ __pListView->UpdateList();
+
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ pArgs->RemoveAll(true);
+ delete pArgs;
+ pArgs = null;
+
+ AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
+ return;
+
+ CATCH:
+
+ AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
+ return;
+}
+
+void
+SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
+{
+ //Empty Implementation
+}
+
+void
+SearchForm::OnAllFoldersSearchCompleted(void)
+{
+ //Empty Implementation
+}
+
+void
+SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
+{
+ result r = E_SUCCESS;
+ ArrayList* pArg = null;
+ SceneManager* pSceneManager = null;
+ //int storageType = -1;
+
+ if (__SelectedTab == MEMORY_TYPE_PHONE)
+ {
+ FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
+ }
+ else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
+ {
+ FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
+ }
+
+
+ FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
+
+ pArg = new (std::nothrow) ArrayList();
+ TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
+
+ r = pArg->Construct();
+ TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
+
+ pArg->Add(&fileName);
+
+ pSceneManager = SceneManager::GetInstance();
+ TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
+
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
+ return;
+
+CATCH:
+ if (pArg != null)
+ {
+ pArg->RemoveAll(true);
+ delete pArg;
+ pArg = null;
+ }
+ return;
+
+}
+void
+SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
+{
+ //Empty Implementation.
+}
+void
+SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
+{
+ AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
+ ArrayList* pResultList = null;
+ result res = E_SUCCESS;
+ DirectoryEntry* pFileDetails = null;
+
+ TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
+
+ if (pThumbReq != null)
+ {
+ if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
+ {
+ if (pThumbReq->pBitmap != null)
+ {
+ AppLogDebug("This Bitmap is not requested from same form");
+ delete pThumbReq->pBitmap;
+ }
+ return;
+ }
+ }
+
+ if (__isSearchCompleted == false)
+ {
+ if (__isSearchStarted == true)
+ pResultList = __pSearchedContentList;
+ else
+ pResultList = __pContentListFromLastView;
+ }
+ else
+ pResultList = __pSearchedContentList;
+
+ TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
+
+ if (pThumbReq->iRquestId < pResultList->GetCount())
+ {
+ pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
+ TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
+
+ pFileDetails->SetBitmap(pThumbReq->pBitmap);
+ if (__pListView && __pListView->IsVisible())
+ {
+ res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
+ }
+ }
+ else
+ AppLogDebug("Thumbnail Request is not valid");
+
+ AppLogDebug("Exit");
+ return;
+ CATCH:
+ if (pThumbReq != null)
+ {
+ if (pThumbReq->pBitmap != null)
+ delete pThumbReq->pBitmap;
+ }
+ AppLogDebug("Exit");
+ return;
+
+}
+
+void
+SearchForm::LoadDetailForm(String& fullFilePath)
+{
+ AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
+ result r = E_FAILURE;
+
+ SceneManager* pSceneManager = null;
+ ArrayList* pList = null;
+ String* pFullFilePath = null;
+
+ pList = new (std::nothrow) ArrayList();
+ TryCatch(pList != null, , "Failed to create pList");
+
+ r = pList->Construct();
+ TryCatch(r == E_SUCCESS, , "Failed to construct pList");
+
+ pFullFilePath = new (std::nothrow) String(fullFilePath);
+
+ r = pList->Add(pFullFilePath);
+ TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
+
+ pSceneManager = SceneManager::GetInstance();
+ TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
+
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
+ AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
+ return;
+
+ CATCH:
+
+ if (pFullFilePath != null)
+ {
+ delete pFullFilePath;
+ pFullFilePath = null;
+ }
+ if (pList != null)
+ {
+ delete pList;
+ pList = null;
+ }
+ return;
+}
+
+void
+SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
+{
+ AppLogDebug("ENTER");
+ result r = E_SUCCESS;
+
+ ArrayList* pArg = null;
+ Integer* pSourceSelected = null;
+ SceneManager* pSceneManager = null;
+
+ __selectedItemIndexForRename = index;
+
+ if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
+ __isCurrentDirectoryRenamed = true;
+
+ pSceneManager = SceneManager::GetInstance();
+ TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
+
+ pArg = new (std::nothrow) ArrayList;
+ r = pArg->Construct();
+
+ pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
+ r = pArg->Add(pSourceSelected);
+ TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
+
+ r = pArg->Add(pDirectory);
+ TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
+
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
+
+ return;
+
+CATCH:
+ if (pSourceSelected != null)
+ {
+ delete pSourceSelected;
+ }
+
+
+ delete pDirectory;
+
+ if (pArg != null)
+ {
+ delete pArg;
+ pArg = null;
+ }
+ return;
+}
+
+
+void
+SearchForm::DeleteFile(String& filePath)
+{
+ AppLogDebug("ENTER");
+
+ ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
+ ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
+
+ FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
+ if (__pFileManager != null)
+ {
+ __pFileManager->SetFileManagingListener(this);
+ __pFileManager->DeleteFolderEntries(&filePath);
+ }
+
+ AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
+}
+
+
+void
+SearchForm::OnFileManagingStart(void)
+{
+ AppLogDebug("Entry");
+ ShowFileProgressingPopup();
+}
+
+void
+SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
+{
+ //Empty Implementation
+}
+
+void
+SearchForm::ShowFileProgressingPopup(void)
+{
+ CreateFileProgressingPopup();
+
+ if (__pFileProgressingPopup != null)
+ {
+ __pFileProgressingPopup->SetShowState(true);
+ __pFileProgressingPopup->Show();
+ }
+}
+
+void
+SearchForm::HideFileProgressingPopup(void)
+{
+ AppLogDebug("HideFileProgressingPopup:ENTER");
+ if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
+ {
+ __pFileProgressingPopup->SetShowState(false);
+
+ delete __pFileProgressingPopup;
+ __pFileProgressingPopup = null;
+ }
+}
+
+result
+SearchForm::CreateFileProgressingPopup(void)
+{
+ AppLogDebug("ENTER");
+ result r = E_SUCCESS;
+ String deleting;
+
+ AppResource* pAppResource = null;
+ pAppResource = UiApp::GetInstance()->GetAppResource();
+ TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
+
+ pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
+
+ __pFileProgressingPopup = new (std::nothrow) Popup();
+ __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
+
+ __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
+ if (__pFileProgressingCancelButton != null)
+ {
+ __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
+ __pFileProgressingCancelButton->AddActionEventListener(*this);
+ }
+ __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
+ if (__pFileProgressingProgress != null)
+ {
+ __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
+ __pFileProgressingProgress->SetValue(0);
+ }
+ __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
+ if (__pFileProgressingHeaderLabel != null)
+ {
+ __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
+ __pFileProgressingHeaderLabel->SetText(deleting);
+ }
+ __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
+ if (__pFileProgressingLabel != null)
+ {
+ __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
+ }
+
+ return r;
+
+}
+
+result
+SearchForm::CreateDeleteConfirmationPopup(void)
+{
+ result r = E_SUCCESS;
+ Rectangle popupBounds;
+
+ //Create a Delete popup control
+ __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
+ __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
+
+ popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
+
+
+ __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
+ TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
+
+ __pDelete->SetActionId(IDA_DELETE_FILE);
+ __pDelete->AddActionEventListener(*this);
+ __pDelete->SetShowState(true);
+
+ __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
+ TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
+
+ __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
+ __pCancelDeletion->AddActionEventListener(*this);
+ __pCancelDeletion->SetShowState(true);
+
+ return r;
+
+CATCH:
+
+ if (__pDeleteConfirmationPopUp != null)
+ {
+ delete __pDeleteConfirmationPopUp;
+ __pDeleteConfirmationPopUp = null;
+ }
+
+ return r;
+
+}
+
+void
+SearchForm::HideDeleteConfirmationPopup(void)
+{
+ if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
+ {
+ __pDeleteConfirmationPopUp->SetShowState(false);
+
+ delete __pDeleteConfirmationPopUp;
+ __pDeleteConfirmationPopUp = null;
+
+ }
+}
+
+void
+SearchForm::ShowDeleteConfirmationPopup(void)
+{
+ CreateDeleteConfirmationPopup();
+
+ if (__pDeleteConfirmationPopUp != null)
+ {
+ __pDeleteConfirmationPopUp->SetShowState(true);
+ __pDeleteConfirmationPopUp->Show();
+ }
+}
+
+void
+SearchForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
+{
+ bool setMediaPath = false;
+ MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
+ String unmounted = sdCardStatusUnmounted;
+ String removed = usbDeviceStatusRemoved;
+ String currentPath;
+ SceneManager* pSceneManager = null;
+
+ if (state == unmounted || state == removed)
+ {
+ currentPath = FolderNavigationPresentationModel::GetCurrentPath();
+ if (state == unmounted)
+ {
+ if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
+ {
+ FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
+ FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
+ setMediaPath = true;
+ }
+ }
+
+ if (state == removed)
+ {
+ if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
+ {
+ FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
+ FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
+ setMediaPath = true;
+ }
+ }
+
+ if (setMediaPath)
+ {
+ pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager != null)
+ {
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null); }
+ }
+ }
+}
+
+void
+SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
+{
+ ComponentType currentDeviceType;
+ switch (deviceType)
+ {
+ case StorageCard:
+ {
+ currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
+ }
+ break;
+
+ case UsbClient:
+ {
+ currentDeviceType = COMPONENT_TYPE_USB;
+ }
+ break;
+
+ default:
+ {
+ //Do Nothing.
+ }
+ break;
+ }
+ OnDeviceChange(currentDeviceType, state);
+}
+
+void
+SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
+ const Tizen::Ui::Scenes::SceneId ¤tSceneId)
+{
+ SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
+// __pSearchBar->SetText(L"");
+ __pSearchBar->SetMode(__searchBarMode);
+
+
+ if (__pFileEventManager != null)
+ {
+ delete __pFileEventManager;
+ __pFileEventManager = null;
+
+ }
+ __pFileEventManager = new (std::nothrow) FileEventManager();
+ __pFileEventManager->Construct(*this);
+
+ //__pFileEventManager->AddPath(__currentSearchDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );
+
+ if (__bCheckArgsNull)
+ {
+ if (__pListView != null)
+ {
+ __pListView->UpdateList();
+ }
+ }
+ else
+ {
+ if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
+ {
+ __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
+ }
+ }
+}
+
+void
+SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
+ const Tizen::Ui::Scenes::SceneId &nextSceneId)
+{
+ //Empty Implementation.
+}
+
+void
+SearchForm::StartSearch(void)
+{
+ String searchtext;
+ String folderToSearch;
+ String topLevelPath;
+
+ //Hide keypad of Search bar
+ __pSearchBar->HideKeypad();
+ __pSearchBar->SetContentAreaVisible(true);
+ __pSearchBar->SetEnabled(false);
+
+ //Show Popup
+ __pDividerLabel->SetText(folderToSearch);
+ __pSearchPopup->SetShowState(true);
+ __pSearchPopup->Show();
+
+ ///Set Application Notification Listener to current form
+ ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
+
+ if (__SelectedTab == MEMORY_TYPE_PHONE)
+ {
+ //topLevelPath = folderEntryPM.GetMediaPath();
+ topLevelPath = __pFolderEntryPM->GetMediaPath();
+ }
+ else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
+ {
+ //topLevelPath = folderEntryPM.GetSdCardPath();
+ topLevelPath = __pFolderEntryPM->GetSdCardPath();
+ }
+
+ if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
+ {
+ __searchedAllFolders = true;
+ }
+
+ if (__pSearchedContentList != null)
+ {
+ __pSearchedContentList->RemoveAll(true);
+ }
+ __searchItemIndex = INVALID_LIST_INDEX;
+ __isSearchCompleted = false;
+ __isSearchStarted = true;
+
+ __pListView->UpdateList();
+
+ __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
+ __pSearchModel->SetStringToSearch(__searchText);
+ __pSearchModel->Start();
+}
+
+void
+SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
+{
+ if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
+ {
+ __pSearchBar->SetMode(__searchBarMode);
+
+ if (__searchText.IsEmpty() == false)
+ StartSearch();
+
+ if (__pListView != null)
+ __pListView->UpdateList();
+ }
+}
+
+void
+SearchForm::GetFolderName(void)
+{
+ String delim(L"/");
+ String token;
+ String fullPath;
+ String folderName(L"Search ");
+
+ fullPath = FolderNavigationPresentationModel::GetCurrentPath();
+
+ StringTokenizer tokenizer(fullPath, delim);
+
+#if 0
+ DataBindingContext* pContext = null;
+ pContext = GetDataBindingContextN();
+#endif
+
+ int Counter = 3;
+
+ //Use a string tokenizer to get the filepath until it's the last token, break the loop when
+ //it is the last token
+ while (tokenizer.HasMoreTokens())
+ {
+ if (Counter > 0)
+ {
+ Counter--;
+ tokenizer.GetNextToken(token);
+ }
+ else
+ {
+ tokenizer.GetNextToken(token);
+ folderName.Append(token);
+ }
+ }
+
+ if (__pSearchBar != null)
+ {
+ __pSearchBar->SetGuideText(folderName);
+ }
+}
+
+void
+SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
+{
+ String displayPath;
+ String delim(L"/");
+ String token;
+
+ StringTokenizer tokenizer(*filePath, delim);
+
+ filePath->Clear();
+
+ //Use a string tokenizer to get the filepath until it's the last token, break the loop when
+ //it is the last token
+ while (tokenizer.HasMoreTokens())
+ {
+ if (tokenizer.GetTokenCount() != 1)
+ {
+ filePath->Append(L"/");
+ tokenizer.GetNextToken(token);
+ filePath->Append(token);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ filePath->Append(L"/");
+
+ if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
+ {
+ filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
+ }
+ else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
+ {
+ filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);
+ }
+
+}