From: chitta.rs Date: Fri, 5 Apr 2013 12:13:10 +0000 (+0530) Subject: NABI_SE issues resolved X-Git-Tag: accepted/tizen_2.1/20130425.024242~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa8396a3b17cac23882f25f286f65760ce6d61f9;p=apps%2Fosp%2FMyFiles.git NABI_SE issues resolved Change-Id: Ib953783ea7cf9d40f33fb29dedd5326964a8d6e2 --- diff --git a/inc/AppResourceId.h b/inc/AppResourceId.h new file mode 100644 index 0000000..4df562b --- /dev/null +++ b/inc/AppResourceId.h @@ -0,0 +1,20 @@ +#ifndef _APPRESOURCEID_H_ +#define _APPRESOURCEID_H_ + +extern const wchar_t* IDL_BASE_FORM; +extern const wchar_t* IDL_CATEGORY_SEARCH; +extern const wchar_t* IDL_CREATE_FOLDER; +extern const wchar_t* IDL_DETAIL_FORM; +extern const wchar_t* IDL_EDIT; +extern const wchar_t* IDL_MAIN_FORM; +extern const wchar_t* IDL_ROOT_DIRECTORY; +extern const wchar_t* IDL_SPLIT_PANEL; +extern const wchar_t* IDL_SPLIT_PANEL_FILE_MANAGER; +extern const wchar_t* IDL_SUB_DIRECTORY; +extern const wchar_t* IDL_SUB_FOLDER_FILE_SELECTION; +extern const wchar_t* IDL_SUB_FOLDER_MOVE_COPY; +extern const wchar_t* IDL_TOP_LEVEL_DIRECTORY_COPY_MOVE; +extern const wchar_t* IDL_TOP_MOST_FILE_SELECTION; +extern const wchar_t* IDL_TOP_MOST_MOVE_COPY; + +#endif // _APPRESOURCEID_H_ diff --git a/inc/MfMyFilesApp.h b/inc/MfMyFilesApp.h index 350906b..81b470a 100644 --- a/inc/MfMyFilesApp.h +++ b/inc/MfMyFilesApp.h @@ -36,6 +36,7 @@ class MyFilesApp : public Tizen::App::IAppControlProviderEventListener , public Tizen::App::UiApp , public Tizen::System::IScreenEventListener + , public Tizen::System::ISettingEventListener { public: //! Constructor of the class. @@ -120,6 +121,7 @@ public: virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData); + virtual void OnSettingChanged(Tizen::Base::String& key) ; void InitializeListeners(void); public: /** @@ -130,6 +132,7 @@ public: private: bool __bAppControlEnabled; bool __bImgAppControlLaunched; + Tizen::Base::String __currentDisplayLanguage; RequestId __currentRequestId; Tizen::App::AppCtrlResult __currentAppControlResult; diff --git a/inc/MfSearchPresentationModel.h b/inc/MfSearchPresentationModel.h index 8bec894..d957480 100644 --- a/inc/MfSearchPresentationModel.h +++ b/inc/MfSearchPresentationModel.h @@ -95,6 +95,7 @@ private: private: bool __searchToStop; + bool __isSDCardSearchedAlready; Tizen::Base::Collection::ArrayList* __pFolderSearchStartedMessage; Tizen::Base::String __folderToSearch; diff --git a/inc/ResourceAfx.h b/inc/ResourceAfx.h new file mode 100644 index 0000000..3d05479 --- /dev/null +++ b/inc/ResourceAfx.h @@ -0,0 +1,7 @@ +#ifndef _RESOURCEAFX_H_ +#define _RESOURCEAFX_H_ + +//static const wchar_t* IDC_LISTVIEW_TOP_LEVEL_DIR_COPY_MOVE = L"IDC_LISTVIEW_TOP_LEVEL_DIR_COPY_MOVE"; +//static const wchar_t* IDC_LISTVIEW_TEMP_FORM = L"IDC_LISTVIEW_TEMP_FORM"; + +#endif // _RESOURCEAFX_H_ diff --git a/src/AppResourceId.cpp b/src/AppResourceId.cpp new file mode 100644 index 0000000..1cc70d3 --- /dev/null +++ b/src/AppResourceId.cpp @@ -0,0 +1,17 @@ +#include "AppResourceId.h" + +const wchar_t* IDL_BASE_FORM = L"IDL_BASE_FORM"; +const wchar_t* IDL_CATEGORY_SEARCH = L"IDL_CATEGORY_SEARCH"; +const wchar_t* IDL_CREATE_FOLDER = L"IDL_CREATE_FOLDER"; +const wchar_t* IDL_DETAIL_FORM = L"IDL_DETAIL_FORM"; +const wchar_t* IDL_EDIT = L"IDL_EDIT"; +const wchar_t* IDL_MAIN_FORM = L"IDL_MAIN_FORM"; +const wchar_t* IDL_ROOT_DIRECTORY = L"IDL_ROOT_DIRECTORY"; +const wchar_t* IDL_SPLIT_PANEL = L"IDL_SPLIT_PANEL"; +const wchar_t* IDL_SPLIT_PANEL_FILE_MANAGER = L"IDL_SPLIT_PANEL_FILE_MANAGER"; +const wchar_t* IDL_SUB_DIRECTORY = L"IDL_SUB_DIRECTORY"; +const wchar_t* IDL_SUB_FOLDER_FILE_SELECTION = L"IDL_SUB_FOLDER_FILE_SELECTION"; +const wchar_t* IDL_SUB_FOLDER_MOVE_COPY = L"IDL_SUB_FOLDER_MOVE_COPY"; +const wchar_t* IDL_TOP_LEVEL_DIRECTORY_COPY_MOVE = L"IDL_TOP_LEVEL_DIRECTORY_COPY_MOVE"; +const wchar_t* IDL_TOP_MOST_FILE_SELECTION = L"IDL_TOP_MOST_FILE_SELECTION"; +const wchar_t* IDL_TOP_MOST_MOVE_COPY = L"IDL_TOP_MOST_MOVE_COPY"; diff --git a/src/MfContentListItem.cpp b/src/MfContentListItem.cpp index 1f55fa9..e4793e9 100644 --- a/src/MfContentListItem.cpp +++ b/src/MfContentListItem.cpp @@ -149,53 +149,9 @@ ContentListItem::Refresh(void) if (__pFtTitle == null) return; - if (__isSearchedTextPresent && __searchedText.GetLength() > 0) - { - String tempTitleString = __contentTitle; - tempTitleString.ToLowerCase(); - bool found = false; - __searchedText.ToLowerCase(); - String temp1 = L"", temp2 = L"", temp3 = L""; - - if (tempTitleString.StartsWith(__searchedText, 0)) - { - found = true; - __contentTitle.SubString(0, __searchedText.GetLength(), temp1); - __contentTitle.SubString(__searchedText.GetLength(), __contentTitle.GetLength() - __searchedText.GetLength(), temp2); + __pFtTitle->SetTextWrap(TEXT_WRAP_NONE); + __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE); - Color titleColor = Color(42, 137, 194); - __pFtTitle->AddText(temp1, FONT_MAIN, titleColor); - __pFtTitle->AddText(temp2, FONT_MAIN, COLOR_TITLE); - } - else - { - int index = -1; - tempTitleString.IndexOf(__searchedText, 0, index); - if (index > -1) - { - __contentTitle.SubString(0, index, temp1); - __contentTitle.SubString(index, __searchedText.GetLength(), temp2); - __contentTitle.SubString(index + __searchedText.GetLength(), tempTitleString.GetLength() - __searchedText.GetLength() - index, temp3); - } - else - { - __contentTitle.SubString(0, tempTitleString.GetLength(), temp1); - } - __pFtTitle->SetTextWrap(TEXT_WRAP_NONE); - Color titleColor = Color(42, 137, 194); - if (temp1.GetLength() > 0) - __pFtTitle->AddText(temp1, FONT_MAIN, COLOR_TITLE); - if (temp2.GetLength() > 0) - __pFtTitle->AddText(temp2, FONT_MAIN, titleColor); - if (temp3.GetLength() > 0) - __pFtTitle->AddText(temp3, FONT_MAIN, COLOR_TITLE); - } - } - else - { - __pFtTitle->SetTextWrap(TEXT_WRAP_NONE); - __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE); - } AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle); AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); } @@ -898,7 +854,52 @@ ContentListItem::RefreshSearchFormListItem(void) __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth); if (__pFtTitle == null) return; + if (__searchedText.GetLength() > 0) + { + String tempTitleString = __contentTitle; + tempTitleString.ToLowerCase(); + bool found = false; + __searchedText.ToLowerCase(); + String temp1 = L"", temp2 = L"", temp3 = L""; + + if (tempTitleString.StartsWith(__searchedText, 0)) + { + found = true; + __contentTitle.SubString(0, __searchedText.GetLength(), temp1); + __contentTitle.SubString(__searchedText.GetLength(), __contentTitle.GetLength() - __searchedText.GetLength(), temp2); + + Color titleColor = Color(42, 137, 194); + __pFtTitle->AddText(temp1, FONT_MAIN, titleColor); + __pFtTitle->AddText(temp2, FONT_MAIN, COLOR_TITLE); + } + else + { + int index = -1; + tempTitleString.IndexOf(__searchedText, 0, index); + if (index > -1) + { + __contentTitle.SubString(0, index, temp1); + __contentTitle.SubString(index, __searchedText.GetLength(), temp2); + __contentTitle.SubString(index + __searchedText.GetLength(), tempTitleString.GetLength() - __searchedText.GetLength() - index, temp3); + } + else + { + __contentTitle.SubString(0, tempTitleString.GetLength(), temp1); + } + __pFtTitle->SetTextWrap(TEXT_WRAP_NONE); + Color titleColor = Color(42, 137, 194); + if (temp1.GetLength() > 0) + __pFtTitle->AddText(temp1, FONT_MAIN, COLOR_TITLE); + if (temp2.GetLength() > 0) + __pFtTitle->AddText(temp2, FONT_MAIN, titleColor); + if (temp3.GetLength() > 0) + __pFtTitle->AddText(temp3, FONT_MAIN, COLOR_TITLE); + } + } + else + { __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE); + } AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle); __pFtFilepath = new (std::nothrow) FormatedText(nMultiTextWidth); diff --git a/src/MfDirectoryEntry.cpp b/src/MfDirectoryEntry.cpp index 527fa0c..903a854 100644 --- a/src/MfDirectoryEntry.cpp +++ b/src/MfDirectoryEntry.cpp @@ -64,6 +64,7 @@ DirectoryEntry::DirectoryEntry(const DirectoryEntry& content) __bLoadBitmap = true; //__DummyImage= content.__DummyImage; __DummyImage= true; + creationDate = content.creationDate; #if 0 __pEntryBitmap = content.__pEntryBitmap; @@ -102,6 +103,7 @@ DirectoryEntry::operator =(const DirectoryEntry& source) this->__fileExtension = source.__fileExtension; //this->__DummyImage = source.__DummyImage; this->__DummyImage = true; + this->creationDate = source.creationDate; #if 0 this->__pEntryBitmap = source.__pEntryBitmap; diff --git a/src/MfFileManageWorkerThread.cpp b/src/MfFileManageWorkerThread.cpp index 0b8fbfe..c283447 100644 --- a/src/MfFileManageWorkerThread.cpp +++ b/src/MfFileManageWorkerThread.cpp @@ -2010,23 +2010,12 @@ FileManageWorkerThread::RenameFolderEntry(void) __isRenamingActive = true; - /*r = CopyFile(__filePath,__renameFilePath); - TryCatch(r == E_SUCCESS,,"copy failed"); + bool isScanFailed = false; - r = DeleteFileContentDB(__filePath); + r = Directory::Rename(__filePath,__renameFilePath); + TryCatch(r == E_SUCCESS,,"Rename file failed"); File::GetAttributes(__renameFilePath, fileAttrib); - if(fileAttrib.IsDirectory()) - { - __renameFilePath.Append(L"/"); - }*/ - - //result r = E_SUCCESS; - //FileAttributes fileAttrib; - //__renameFilePath.Append(L"/"); - - Directory::Rename(__filePath,__renameFilePath); - File::GetAttributes(__renameFilePath, fileAttrib); AppLogDebug("file path is %ls", __renameFilePath.GetPointer()); //RequestId reqId; //r = ContentManager::ScanDirectory(__renameFilePath,true,this,reqId); @@ -2034,6 +2023,8 @@ FileManageWorkerThread::RenameFolderEntry(void) if (fileAttrib.IsDirectory()) { + isScanFailed = true; + RequestId reqId; r = ContentManager::ScanDirectory(__renameFilePath,true,this,reqId); AppLogDebug("Scan dir result %s",GetErrorMessage(r)); @@ -2046,12 +2037,14 @@ FileManageWorkerThread::RenameFolderEntry(void) } else { + isScanFailed = true; + r = ContentManager::ScanFile(__renameFilePath); AppLogDebug("scan file result %s",GetErrorMessage(r)); TryCatch(r == E_SUCCESS,,"scan file failed"); r = ContentManager::ScanFile(__filePath); - AppLogDebug("scan file result %s",GetErrorMessage(r)); + AppLogDebug("scan file result %s",GetErrorMessage(r)); TryCatch(r == E_SUCCESS,,"scan file failed"); } //return r; @@ -2063,7 +2056,14 @@ CATCH: //r = DeleteFile(__renameFilePath); __fileManagingingResult = FILE_MANAGING_RENAME_FAILED; AppLogDebug("catch result is %s",GetErrorMessage(r)); - return r; + if(isScanFailed) + { + return E_SUCCESS; + } + else + { + return r; + } } result diff --git a/src/MfFolderEntryPresentationModel.cpp b/src/MfFolderEntryPresentationModel.cpp index ff5a25e..87807ab 100644 --- a/src/MfFolderEntryPresentationModel.cpp +++ b/src/MfFolderEntryPresentationModel.cpp @@ -1332,26 +1332,40 @@ FolderEntryPresentationModel::CreateTraversalTree(void) { DirEntry currentDirEntry = pCurrentDirectoryEnum->GetCurrentDirEntry(); String directoryName = currentDirEntry.GetName(); + + DirectoryEntry* pCurrentFolderEntry = new (std::nothrow) DirectoryEntry(); + String fullPath = *currentDirectoryPath+directoryName; + pCurrentFolderEntry->SetFileExtension(File::GetFileExtension(fullPath)); + fileExtensionResult = GetLastResult(); + fileExtensionLength = pCurrentFolderEntry->GetFileExtension().GetLength(); + if(fileExtensionLength != 0) + { + directoryName.Remove(directoryName.GetLength() - fileExtensionLength - 1, fileExtensionLength + 1); + } + pCurrentFolderEntry->SetFullFilePath(fullPath); + pCurrentFolderEntry->SetFileName(directoryName); + pCurrentFolderEntry->SetCheckDirectory(false); + if(currentDirEntry.IsDirectory() && directoryName != "." && directoryName != "..") { + AppLogDebug("SearchPresentationModel::Search::"); + if (__sourceForm == CREATE_ITEM_SOURCE_SEARCH_FORM) + { + AppLogDebug("SearchPresentationModel::Search::%S", pCurrentFolderEntry->GetFullFilePath().GetPointer()); + pCurrentFolderEntry->SetCheckDirectory(true); + __pFolderEntries->Add(pCurrentFolderEntry); + } + else + { + delete pCurrentFolderEntry; + pCurrentFolderEntry = null; + } String pathtoPush = *currentDirectoryPath + directoryName + "/"; r = __pFolderEntryStack->Push(new (std::nothrow) String(pathtoPush)); TryCatch(r == E_SUCCESS, ,"push failed"); } else if (!(directoryName.StartsWith(L".", 0)) && !currentDirEntry.IsHidden()) { - DirectoryEntry* pCurrentFolderEntry = new (std::nothrow) DirectoryEntry(); - String fullPath = *currentDirectoryPath+directoryName; - pCurrentFolderEntry->SetFileExtension(File::GetFileExtension(fullPath)); - fileExtensionResult = GetLastResult(); - fileExtensionLength = pCurrentFolderEntry->GetFileExtension().GetLength(); - if(fileExtensionLength != 0) - { - directoryName.Remove(directoryName.GetLength() - fileExtensionLength - 1, fileExtensionLength + 1); - } - pCurrentFolderEntry->SetFullFilePath(fullPath); - pCurrentFolderEntry->SetFileName(directoryName); - pCurrentFolderEntry->SetCheckDirectory(false); contentType = ContentManagerUtil::CheckContentType(fullPath); r = GetLastResult(); fileExtension = pCurrentFolderEntry->GetFileExtension(); diff --git a/src/MfMyFilesApp.cpp b/src/MfMyFilesApp.cpp index 91735a0..5dd35c0 100644 --- a/src/MfMyFilesApp.cpp +++ b/src/MfMyFilesApp.cpp @@ -90,6 +90,7 @@ MyFilesApp::OnAppInitialized(void) SceneManager* pSceneManager = null; MfMainFrame* pMyFileMainFrame = null; MessageBox messageBox; + String languageKey = L"http://tizen.org/setting/locale.language"; // Create a Frame pMyFileMainFrame = new (std::nothrow) MfMainFrame(); @@ -164,6 +165,12 @@ MyFilesApp::OnAppInitialized(void) pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TEMP_FORM)); } } + + + //Setting Application setting change event listener. + SettingInfo::GetValue(languageKey, __currentDisplayLanguage); + SettingInfo::AddSettingEventListener(*this); + //Ends return true; CATCH: return false; //Returning false changes app state to TERMINATING and app's OnAppTerminating function will be called. @@ -226,7 +233,6 @@ MyFilesApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) const HashMap* pResultHash = null; IMapEnumerator* pResultMapEnum = null; DirectoryEntry* pDirStr = null; - int Count=0; pResultHash = FolderEntryEditorPresentationModel::GetInstance()->GetCheckedList(); @@ -648,3 +654,21 @@ MyFilesApp::InitializeListeners(void) __pCurrentListToUpdate = null; __pNotificationListener = null; } +void +MyFilesApp::OnSettingChanged(Tizen::Base::String& key) +{ + String languageSettingKey = L"http://tizen.org/setting/locale.language"; + String languageSelected; + + AppLogDebug("SettingChanged++"); + if ( key.CompareTo(languageSettingKey) == 0 ) + { + SettingInfo::GetValue(languageSettingKey, languageSelected); + + if ( __currentDisplayLanguage.CompareTo(languageSelected) !=0) + { + Application::Terminate(); + } + } + AppLogDebug("SettingChanged--"); +} diff --git a/src/MfSearchForm.cpp b/src/MfSearchForm.cpp index f6fcc84..89bfc88 100644 --- a/src/MfSearchForm.cpp +++ b/src/MfSearchForm.cpp @@ -440,12 +440,14 @@ SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, if (__pFolderEntryPM != null) { - __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath); - __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList(); - TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView"); - __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM); + __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; @@ -502,7 +504,8 @@ SearchForm::OnFormBackRequested(Form& source) void SearchForm::TransitionScene(void) { - String rootMediaPath = BasePresentationModel::GetHomePath(); + //String rootMediaPath = BasePresentationModel::GetHomePath(); + String rootMediaPath = BasePresentationModel::GetMediaPath(); SceneManager* pSceneManager = null; pSceneManager = SceneManager::GetInstance(); @@ -743,14 +746,16 @@ SearchForm::GetItemCount(void) int count = 0; TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!") - TryCatch(__pContentListFromLastView != null, , "__pContentListFromLastView is null!") if (__isSearchCompleted == false) { if (__isSearchStarted == true) count = __pSearchedContentList->GetCount(); else - count = __pContentListFromLastView->GetCount(); + { + if (__pContentListFromLastView != null) + count = __pContentListFromLastView->GetCount(); + } } else { @@ -816,9 +821,6 @@ SearchForm::CreateItem(int index, int itemWidth) return pItem; } - TryCatch(__pContentListFromLastView != null, , "__pContentListFromLastView is NULL!"); - TryCatch(__pContentListFromLastView->GetCount() != 0, , "__pContentListFromLastView count is Zero!"); - pAppResource = Application::GetInstance()->GetAppResource(); TryCatch(pAppResource != null, , "Resource manager not found!"); @@ -830,7 +832,8 @@ SearchForm::CreateItem(int index, int itemWidth) } else { - pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index)); + if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0) + pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index)); } } else @@ -1195,14 +1198,12 @@ SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs) String* pFolderSearchResult = (String*) pArgs->GetAt(1); TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null"); - String defMediaPath = FolderNavigationPresentationModel::GetMediaPath(); - String defSdCardPath = FolderNavigationPresentationModel::GetSdCardPath(); + String defMediaPath(L"/opt/usr/media"); + String defSdCardPath(L"/opt/storage/sdcard"); String displayPhone = defaultPhoneBody; String displaySdCard = defaultSdCardBody; - displayPhone.Append("/"); - displaySdCard.Append("/"); if (pFolderSearchResult->IsEmpty() == false) { @@ -1269,17 +1270,8 @@ SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs) __bIsResultList = true; - if(__searchItemIndex == 0) - { - __pListView->UpdateList(); - } - else - { - result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD); - AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res)); - } - - + result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD); + AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res)); } break; @@ -1984,7 +1976,7 @@ SearchForm::StartSearch(void) topLevelPath = __pFolderEntryPM->GetSdCardPath(); } - if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath) + if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true)) { __searchedAllFolders = true; } diff --git a/src/MfSearchPresentationModel.cpp b/src/MfSearchPresentationModel.cpp index 5d35011..2d0abdd 100644 --- a/src/MfSearchPresentationModel.cpp +++ b/src/MfSearchPresentationModel.cpp @@ -1,247 +1,283 @@ -// -// 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: MfSearchPresentationModel.cpp - * @brief: This file contains implementation of SearchPresentationModel class. - */ - -#include "MfSearchPresentationModel.h" - -using namespace Tizen::App; -using namespace Tizen::Base; -using namespace Tizen::Base::Collection; -using namespace Tizen::Base::Runtime; -using namespace Tizen::Content; -using namespace Tizen::Io; - -SearchPresentationModel::SearchPresentationModel(void) -{ - __pFolderSearchStartedMessage = null; - __pFolderEntryPM = null; - __searchToStop = false; -} - -SearchPresentationModel::~SearchPresentationModel(void) -{ - //Empty Implementation. -} - - -result -SearchPresentationModel::Initialize(void) -{ - result r = E_FAILURE; - r = Construct(THREAD_TYPE_WORKER); - return r; -} - -void -SearchPresentationModel::SetFolderToSearch(const String& foldername) -{ - __folderToSearch = foldername; -} - -void -SearchPresentationModel::SetStringToSearch(const String& searchString) -{ - __searchKeyword = searchString; -} - - -Tizen::Base::Object* -SearchPresentationModel::Run(void) -{ - AppLogDebug("Enter:SearchPresentationModel::Run"); - __searchToStop = false; - - if (__folderToSearch.IsEmpty() == false) - { - Search(); - } - return null; - -} -bool -SearchPresentationModel::OnStart(void) -{ - AppLogDebug("Enter:SearchPresentationModel::OnStart"); - return true; -} - -void -SearchPresentationModel::OnStop(void) -{ - AppLogDebug("Enter:SearchPresentationModel::OnStop"); - result r = E_FAILURE; - Tizen::Base::Collection::ArrayList* pSearchCompleteMessage = null; - if (!IsFailed(GetLastResult())) - { - pSearchCompleteMessage = new (std::nothrow) ArrayList(); - TryCatch(pSearchCompleteMessage != null, , "SearchPresentationModel::Run::Failed to allocate Memory to pSearchCompleteMessage"); - - r = pSearchCompleteMessage->Construct(); - TryCatch(r == E_SUCCESS, , "SearchPresentationModel::Run::Failed to Construct pFinalListToBeSent"); - - pSearchCompleteMessage->Add(new (std::nothrow) Integer(ID_SEARCH_COMPLETED)); - - Application::GetInstance()->SendUserEvent(ID_SEARCH_COMPLETED, pSearchCompleteMessage); - - } - AppLogDebug("Exit:SearchPresentationModel::OnStop"); - return; - -CATCH: - if (pSearchCompleteMessage) - { - delete pSearchCompleteMessage; - } - AppLogDebug("SearchPresentationModel::OnStop--"); - return; - -} - -void -SearchPresentationModel::StopSearch(void) -{ - AppLogDebug("Enter:SearchPresentationModel::StopSearch"); - __searchToStop = true; -} - -void -SearchPresentationModel::Search(void) -{ - String* pCurrentDirectoryPath = null; - ArrayList* pDirectoryEntryList = null; - int directoryEntryCount = 0; - result r = E_FAILURE; - - AppLogDebug("SearchPresentationModel::Search"); - - __pFolderEntryStack = new (std::nothrow) Stack(); - TryCatch(__pFolderEntryStack != null, , "Stack is null"); - - pCurrentDirectoryPath = new (std::nothrow) String(__folderToSearch); - TryCatch(pCurrentDirectoryPath != null, , "pCurrentDirectoryPath is null"); - - r = __pFolderEntryStack->Push(new String(*pCurrentDirectoryPath)); - TryCatch(r == E_SUCCESS, ,"push failed"); - - __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel(); - TryCatch(__pFolderEntryPM != null, , "SearchPresentationModel::Search::Failed to allocate Memory to __pFolderEntryPM"); - __pFolderEntryPM->Construct(); - - do - { - AppLogDebug("SearchPresentationModel::Search:%S", pCurrentDirectoryPath->GetPointer()); - - if (__searchToStop == true) - { - break; - } - __pFolderSearchStartedMessage = new (std::nothrow) ArrayList(); - if (__pFolderSearchStartedMessage != null) - { - __pFolderSearchStartedMessage->Construct(); - __pFolderSearchStartedMessage->Add(new (std::nothrow) Integer(ID_FOLDER_SEARCH_STARTED)); - __pFolderSearchStartedMessage->Add(new (std::nothrow) String(*pCurrentDirectoryPath)); - } - Application::GetInstance()->SendUserEvent(ID_FOLDER_SEARCH_STARTED, __pFolderSearchStartedMessage); - - __pFolderEntryPM->SetFolderEntryPath(*pCurrentDirectoryPath); - pDirectoryEntryList = __pFolderEntryPM->GetFolderEntryList(); - - while(directoryEntryCount < pDirectoryEntryList->GetCount()) - { - if (__searchToStop == true) - { - break; - } - DirectoryEntry* pdirStructure = static_cast< DirectoryEntry* >(pDirectoryEntryList->GetAt(directoryEntryCount)); - TryCatch(pdirStructure != null, , "SearchPresentationModel::Search::pdirStructure is null"); - - if(pdirStructure->IsDirectory() == true) - { - String directoryFullPath = pdirStructure->GetFullFilePath(); - r = __pFolderEntryStack->Push(new (std::nothrow) String(directoryFullPath)); - TryCatch(r == E_SUCCESS, ,"push failed"); - - String filename; - filename = pdirStructure->GetFileName(); - - if (filename.IsEmpty() == false && __searchKeyword.IsEmpty() == false) - { - int index = -1; - filename.ToLowerCase(); - __searchKeyword.ToLowerCase(); - filename.IndexOf(__searchKeyword, 0, index); - if (index >= 0) - { - //__pSearchedResult->Add(*new (std::nothrow) DirectoryEntry(*pdirStructure)); - ArrayList* pListToBeSent = new (std::nothrow) ArrayList(); - if (pListToBeSent != null) - { - pListToBeSent->Construct(); - pListToBeSent->Add(new (std::nothrow) Integer(ID_SEARCH_RESULT_FOUND)); - pListToBeSent->Add(new (std::nothrow) DirectoryEntry(*pdirStructure)); - } - AppLogDebug("Exit:SearchPresentationModel::Search::Result:%S", filename.GetPointer()); - Application::GetInstance()->SendUserEvent(ID_SEARCH_RESULT_FOUND, pListToBeSent); - } - } - } - else - { - String filename; - filename = pdirStructure->GetFullFilePath(); - - if (filename.IsEmpty() == false && __searchKeyword.IsEmpty() == false) - { - int index = -1; - filename.ToLowerCase(); - __searchKeyword.ToLowerCase(); - filename.IndexOf(__searchKeyword, 0, index); - if (index >= 0) - { - //__pSearchedResult->Add(*new (std::nothrow) DirectoryEntry(*pdirStructure)); - ArrayList* pListToBeSent = new (std::nothrow) ArrayList(); - if (pListToBeSent != null) - { - pListToBeSent->Construct(); - pListToBeSent->Add(new (std::nothrow) Integer(ID_SEARCH_RESULT_FOUND)); - pListToBeSent->Add(new (std::nothrow) DirectoryEntry(*pdirStructure)); - } - AppLogDebug("Exit:SearchPresentationModel::Search::Result:%S", filename.GetPointer()); - Application::GetInstance()->SendUserEvent(ID_SEARCH_RESULT_FOUND, pListToBeSent); - } - } - } - directoryEntryCount++; - } - directoryEntryCount = 0; - pCurrentDirectoryPath = static_cast(__pFolderEntryStack->Pop()); - TryCatch(pCurrentDirectoryPath !=null, , "Pop Failed"); - } - while (__pFolderEntryStack->GetCount() > 0); - - return; -CATCH: - - if (__pFolderEntryStack != null) - { - __pFolderEntryStack->RemoveAll(true); - } -} +// +// 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: MfSearchPresentationModel.cpp + * @brief: This file contains implementation of SearchPresentationModel class. + */ + +#include "MfSearchPresentationModel.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Content; +using namespace Tizen::Io; +using namespace Tizen::System; + +SearchPresentationModel::SearchPresentationModel(void) +{ + __pFolderSearchStartedMessage = null; + __pFolderEntryPM = null; + __searchToStop = false; + __isSDCardSearchedAlready = false; +} + +SearchPresentationModel::~SearchPresentationModel(void) +{ + //Empty Implementation. +} + + +result +SearchPresentationModel::Initialize(void) +{ + result r = E_FAILURE; + r = Construct(THREAD_TYPE_WORKER); + return r; +} + +void +SearchPresentationModel::SetFolderToSearch(const String& foldername) +{ + __folderToSearch = foldername; +} + +void +SearchPresentationModel::SetStringToSearch(const String& searchString) +{ + __searchKeyword = searchString; +} + + +Tizen::Base::Object* +SearchPresentationModel::Run(void) +{ + AppLogDebug("Enter:SearchPresentationModel::Run"); + __searchToStop = false; + + Search(); + + return null; + +} +bool +SearchPresentationModel::OnStart(void) +{ + AppLogDebug("Enter:SearchPresentationModel::OnStart"); + return true; +} + +void +SearchPresentationModel::OnStop(void) +{ + AppLogDebug("Enter:SearchPresentationModel::OnStop"); + result r = E_FAILURE; + Tizen::Base::Collection::ArrayList* pSearchCompleteMessage = null; + if (!IsFailed(GetLastResult())) + { + pSearchCompleteMessage = new (std::nothrow) ArrayList(); + TryCatch(pSearchCompleteMessage != null, , "SearchPresentationModel::Run::Failed to allocate Memory to pSearchCompleteMessage"); + + r = pSearchCompleteMessage->Construct(); + TryCatch(r == E_SUCCESS, , "SearchPresentationModel::Run::Failed to Construct pFinalListToBeSent"); + + pSearchCompleteMessage->Add(new (std::nothrow) Integer(ID_SEARCH_COMPLETED)); + + Application::GetInstance()->SendUserEvent(ID_SEARCH_COMPLETED, pSearchCompleteMessage); + + } + AppLogDebug("Exit:SearchPresentationModel::OnStop"); + return; + +CATCH: + if (pSearchCompleteMessage) + { + delete pSearchCompleteMessage; + } + AppLogDebug("SearchPresentationModel::OnStop--"); + return; + +} + +void +SearchPresentationModel::StopSearch(void) +{ + AppLogDebug("Enter:SearchPresentationModel::StopSearch"); + __searchToStop = true; +} + +void +SearchPresentationModel::Search(void) +{ + AppLogDebug("SearchPresentationModel::Search"); + + String* pCurrentDirectoryPath = null; + ArrayList* pDirectoryEntryList = null; + int directoryEntryCount = 0; + result r = E_FAILURE; + String defMediaPath(L"/opt/usr/media/"); + + __pFolderEntryStack = new (std::nothrow) Stack(); + TryCatch(__pFolderEntryStack != null, , "Stack is null"); + + + //If Current Folder Path is Empty , Set DefaultMediaPath as CurrentPath + //as default starting point for search + if (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true) + pCurrentDirectoryPath = new (std::nothrow) String(defMediaPath); + else + pCurrentDirectoryPath = new (std::nothrow) String(__folderToSearch); + + TryCatch(pCurrentDirectoryPath != null, , "pCurrentDirectoryPath is null"); + + r = __pFolderEntryStack->Push(new String(*pCurrentDirectoryPath)); + TryCatch(r == E_SUCCESS, ,"push failed"); + + __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel(); + TryCatch(__pFolderEntryPM != null, , "SearchPresentationModel::Search::Failed to allocate Memory to __pFolderEntryPM"); + __pFolderEntryPM->Construct(); + + do + { + AppLogDebug("SearchPresentationModel::Search:%S", pCurrentDirectoryPath->GetPointer()); + + if (__searchToStop == true) + { + break; + } + __pFolderSearchStartedMessage = new (std::nothrow) ArrayList(); + if (__pFolderSearchStartedMessage != null) + { + __pFolderSearchStartedMessage->Construct(); + __pFolderSearchStartedMessage->Add(new (std::nothrow) Integer(ID_FOLDER_SEARCH_STARTED)); + __pFolderSearchStartedMessage->Add(new (std::nothrow) String(*pCurrentDirectoryPath)); + } + Application::GetInstance()->SendUserEvent(ID_FOLDER_SEARCH_STARTED, __pFolderSearchStartedMessage); + + __pFolderEntryPM->SetFolderEntryPath(*pCurrentDirectoryPath); + pDirectoryEntryList = __pFolderEntryPM->GetFolderEntryList(); + + while(directoryEntryCount < pDirectoryEntryList->GetCount()) + { + if (__searchToStop == true) + { + break; + } + DirectoryEntry* pdirStructure = static_cast< DirectoryEntry* >(pDirectoryEntryList->GetAt(directoryEntryCount)); + TryCatch(pdirStructure != null, , "SearchPresentationModel::Search::pdirStructure is null"); + + if(pdirStructure->IsDirectory() == true) + { + String directoryFullPath = pdirStructure->GetFullFilePath(); + + AppLogDebug("SearchPresentationModel::Search::%S", directoryFullPath.GetPointer()); + + r = __pFolderEntryStack->Push(new (std::nothrow) String(directoryFullPath)); + TryCatch(r == E_SUCCESS, ,"push failed"); + + String filename; + filename = pdirStructure->GetFileName(); + + if (filename.IsEmpty() == false && __searchKeyword.IsEmpty() == false) + { + AppLogDebug("SearchPresentationModel::Search::%S", filename.GetPointer(), __searchKeyword.GetPointer()); + int index = -1; + filename.ToLowerCase(); + __searchKeyword.ToLowerCase(); + filename.IndexOf(__searchKeyword, 0, index); + if (index >= 0) + { + //__pSearchedResult->Add(*new (std::nothrow) DirectoryEntry(*pdirStructure)); + ArrayList* pListToBeSent = new (std::nothrow) ArrayList(); + if (pListToBeSent != null) + { + pListToBeSent->Construct(); + pListToBeSent->Add(new (std::nothrow) Integer(ID_SEARCH_RESULT_FOUND)); + pListToBeSent->Add(new (std::nothrow) DirectoryEntry(*pdirStructure)); + } + AppLogDebug("Exit:SearchPresentationModel::Search::Result:%S", filename.GetPointer()); + Application::GetInstance()->SendUserEvent(ID_SEARCH_RESULT_FOUND, pListToBeSent); + } + } + } + else + { + String filename; + filename = pdirStructure->GetFileName(); + AppLogDebug("SearchPresentationModel::Search::%S %S", filename.GetPointer(), __searchKeyword.GetPointer()); + + if (filename.IsEmpty() == false && __searchKeyword.IsEmpty() == false) + { + int index = -1; + filename.ToLowerCase(); + __searchKeyword.ToLowerCase(); + filename.IndexOf(__searchKeyword, 0, index); + if (index >= 0) + { + //__pSearchedResult->Add(*new (std::nothrow) DirectoryEntry(*pdirStructure)); + ArrayList* pListToBeSent = new (std::nothrow) ArrayList(); + if (pListToBeSent != null) + { + pListToBeSent->Construct(); + pListToBeSent->Add(new (std::nothrow) Integer(ID_SEARCH_RESULT_FOUND)); + pListToBeSent->Add(new (std::nothrow) DirectoryEntry(*pdirStructure)); + } + AppLogDebug("Exit:SearchPresentationModel::Search::Result:%S", filename.GetPointer()); + Application::GetInstance()->SendUserEvent(ID_SEARCH_RESULT_FOUND, pListToBeSent); + } + } + } + directoryEntryCount++; + } + directoryEntryCount = 0; + pCurrentDirectoryPath = static_cast(__pFolderEntryStack->Pop()); + + if (pCurrentDirectoryPath->CompareTo(L"/opt/usr/media/")==0 || + pCurrentDirectoryPath->CompareTo(L"/opt/storage/sdcard/") ==0) + { + if (__folderToSearch.IsEmpty() == true && __isSDCardSearchedAlready == false ) + { + String deviceSateSdCard; + String defaultSDCardPath; + DeviceManager::GetState(StorageCard, deviceSateSdCard); + if (deviceSateSdCard == sdCardStatusMounted && pCurrentDirectoryPath->CompareTo(L"/opt/usr/media/") ==0) + { + String defSdCardPath(L"/opt/storage/sdcard/"); + pCurrentDirectoryPath = new (std::nothrow) String(defSdCardPath); + __isSDCardSearchedAlready = true; + + r = __pFolderEntryStack->Push(new String(*pCurrentDirectoryPath)); + TryCatch(r == E_SUCCESS, ,"push failed"); + } + } + else + break; + } + + TryCatch(pCurrentDirectoryPath !=null, , "Pop Failed"); + } + while (__pFolderEntryStack->GetCount() > 0); + + return; +CATCH: + + if (__pFolderEntryStack != null) + { + __pFolderEntryStack->RemoveAll(true); + } +} diff --git a/src/MfTopLevelFolderFileListForm.cpp b/src/MfTopLevelFolderFileListForm.cpp index 5fb07c3..994e5f6 100644 --- a/src/MfTopLevelFolderFileListForm.cpp +++ b/src/MfTopLevelFolderFileListForm.cpp @@ -763,7 +763,7 @@ TopLevelFolderFileListForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes:: #endif pAppResource->GetString(L"IDS_MF_SK3_SEARCH", buttonSearch); } - + FolderNavigationPresentationModel::SetCurrentFilePath(L""); __listItemCount = __pFolderList->GetCount(); if (deviceSateSdCard == mounted && __listItemCount < 2)