46c1a9bfe73a4a3eb43c38ea2a9ff335c54f20ab
[apps/osp/MyFiles.git] / src / MfSearchForm.cpp
1 //\r
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
3 //\r
4 // Licensed under the Flora License, Version 1.0 (the License);\r
5 // you may not use this file except in compliance with the License.\r
6 // You may obtain a copy of the License at\r
7 //\r
8 //     http://floralicense.org/license/\r
9 //\r
10 // Unless required by applicable law or agreed to in writing, software\r
11 // distributed under the License is distributed on an AS IS BASIS,\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 // See the License for the specific language governing permissions and\r
14 // limitations under the License.\r
15 //\r
16 \r
17 /**\r
18  * @file: SearchForm.cpp\r
19  * @brief: This file contains implementation of SearchForm.\r
20  */\r
21 \r
22 #include "MfSearchForm.h"\r
23 \r
24 using namespace Tizen::App;\r
25 using namespace Tizen::App::Package;\r
26 using namespace Tizen::Base;\r
27 using namespace Tizen::Base::Collection;\r
28 using namespace Tizen::Base::Utility;\r
29 using namespace Tizen::Content;\r
30 using namespace Tizen::Graphics;\r
31 using namespace Tizen::Io;\r
32 using namespace Tizen::System;\r
33 using namespace Tizen::Ui;\r
34 using namespace Tizen::Ui::Controls;\r
35 using namespace Tizen::Ui::Scenes;\r
36 \r
37 int SearchForm::searchBackSelected = 0;\r
38 SearchForm::SearchForm(void)\r
39 {\r
40         __pContentListFromLastView = null;\r
41         __pSearchedContentList = null;\r
42 \r
43         __pListView = null;\r
44         __pSearchBar = null;\r
45         __pPopUpPanel = null;\r
46         __pPopUpLabel = null;\r
47         __pCancelSearch = null;\r
48         __pDividerLabel = null;\r
49 \r
50         __pThumbnailManager = null;\r
51         __pSearchModel = null;\r
52 \r
53         __searchText = L"";\r
54         __currentSearchDirectoryPath = L"";\r
55         __bIsResultList = false;\r
56 \r
57         __searchedAllFolders = false;\r
58         __isSearchCompleted = false;\r
59         __isCancelClicked = false;\r
60         __isSearchStarted = false;\r
61         __bCheckArgsNull = false;\r
62         __isCurrentDirectoryRenamed = false;\r
63 \r
64         __itemCount = -1;\r
65         __searchItemIndex = INVALID_LIST_INDEX;\r
66 \r
67         __pFolderBitmap = null;\r
68         __pDummyImage = null;\r
69 \r
70         __pDeleteConfirmationPopUp = null;\r
71 \r
72         __selectedItemIndexForRename = 0;\r
73         __selectedItemIndexForDelete = 0;\r
74         __SelectedTab = MEMORY_TYPE_NONE;\r
75         __previouFormTab = MEMORY_TYPE_NONE;\r
76 \r
77         __pCancelDeletion = null;\r
78         __pDelete = null;\r
79         __pFileProgressingCancelButton = null;\r
80         __pFileProgressingHeaderLabel = null;\r
81         __pItemContext = null;\r
82         __pFileProgressingPopup = null;\r
83         __pFileProgressingProgress = null;\r
84         __pFileEventManager = null;\r
85 }\r
86 \r
87 SearchForm::~SearchForm(void)\r
88 {\r
89         AppLogDebug("Entry");\r
90 \r
91         if (__pSearchedContentList != null)\r
92         {\r
93                 __pSearchedContentList->RemoveAll(true);\r
94                 delete __pSearchedContentList;\r
95         }\r
96 \r
97         if (__pSearchModel != null)\r
98         {\r
99                 delete __pSearchModel;\r
100         }\r
101 \r
102         if (__pItemContext != null)\r
103         {\r
104                 delete __pItemContext;\r
105         }\r
106 \r
107         if (__pDeleteConfirmationPopUp != null)\r
108         {\r
109                 delete __pDeleteConfirmationPopUp;\r
110         }\r
111         if(__pFolderEntryPM != null)\r
112         {\r
113                 delete __pFolderEntryPM;\r
114         }\r
115         if (__pFileEventManager != null)\r
116         {\r
117                 delete __pFileEventManager;\r
118         }\r
119 \r
120 }\r
121 \r
122 SearchForm&\r
123 SearchForm::operator =(const SearchForm& pSearchForm)\r
124 {\r
125         return *this;\r
126 }\r
127 \r
128 SearchForm::SearchForm(const SearchForm& pSearchForm)\r
129 {\r
130         __pContentListFromLastView = pSearchForm.__pContentListFromLastView;\r
131         __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;\r
132 }\r
133 \r
134 \r
135 bool\r
136 SearchForm::Initialize(void)\r
137 {\r
138         result r = Form::Construct(L"IDL_SEARCH");\r
139         if (r != E_SUCCESS)\r
140         {\r
141                 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));\r
142                 return false;\r
143         }\r
144         return true;\r
145 }\r
146 \r
147 result\r
148 SearchForm::OnInitializing(void)\r
149 {\r
150         AppLogDebug("ENTER::SearchForm::OnInitializing");\r
151         result r = E_SUCCESS;\r
152         String cancelButton(L"");\r
153 \r
154         Bitmap* pMainLabelBg = null;\r
155         Bitmap* pDeleteNormalBmp = null;\r
156         Bitmap* pDeletePressBmp = null;\r
157         Label* pSearchPopUpMainlabel = null;\r
158         Label* pSearchPopUpBottomlabel = null;\r
159         String renameButtonText;\r
160         String detailButtonText;\r
161         String deleteButtonText;\r
162         String strSearching ;\r
163         IListT< SceneId >* pSceneList = null;\r
164 \r
165         __SelectedTab = MEMORY_TYPE_NONE;\r
166 \r
167         __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);\r
168         __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);\r
169         AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);\r
170         AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);\r
171         AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);\r
172 \r
173         pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);\r
174         pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);\r
175 \r
176         Footer* pFooter = GetFooter();\r
177         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);\r
178         pFooter->SetBackButton();\r
179 \r
180         SetFormBackEventListener(this);\r
181         __pThumbnailManager = ThumbnailManager::GetInstance();\r
182         TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));\r
183 \r
184         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
185 \r
186         __searchBarMode = SEARCH_BAR_MODE_INPUT;\r
187 \r
188         __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));\r
189         TryCatch(__pSearchBar != null, , "__pSearchBar is Null");\r
190 \r
191         __pSearchBar->AddSearchBarEventListener(*this);\r
192         __pSearchBar->AddTextEventListener(*this);\r
193         __pSearchBar->AddKeypadEventListener(*this);\r
194         __pSearchBar->SetShowState(true);\r
195 \r
196         __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();\r
197         TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");\r
198         __pFolderEntryPM->Construct();\r
199         __pPopUpPanel = new (std::nothrow) Panel();\r
200         TryCatch(__pPopUpPanel != null, , "Failed to allocate memory to __pPopUpPanel");\r
201 \r
202         r = __pPopUpPanel->Construct(Rectangle(X_POPUP_SEARCH, Y_POPUP_SEARCH, W_MAX_POPUP, H_POPUP_SEARCH));\r
203         TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");\r
204 \r
205 \r
206         pSearchPopUpMainlabel = new (std::nothrow) Label();\r
207         TryCatch(pSearchPopUpMainlabel != null, , "Failed to allocate memory to _pSearchPopUpMainlabel");\r
208 \r
209         r = pSearchPopUpMainlabel->Construct(Rectangle(X_DEFAULT, Y_DEFAULT, __pPopUpPanel->GetWidth(), __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL), L"");\r
210         TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
211 \r
212         pMainLabelBg = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pSearchPopUpMainlabel->GetWidth(), pSearchPopUpMainlabel->GetHeight());\r
213 \r
214         if (pMainLabelBg != null)\r
215         {\r
216                 pSearchPopUpMainlabel->SetBackgroundBitmap(*pMainLabelBg);\r
217         }\r
218         __pPopUpPanel->AddControl(*pSearchPopUpMainlabel);\r
219         __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpMainlabel, true);\r
220 \r
221         pSearchPopUpBottomlabel = new (std::nothrow) Label();\r
222         TryCatch(pSearchPopUpBottomlabel != null, , "Failed to allocate memory to _pSearchPopUpBottomlabel");\r
223 \r
224         r = pSearchPopUpBottomlabel->Construct(Rectangle(X_DEFAULT, __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL, __pPopUpPanel->GetWidth(), H_BOTTOM_PANEL), L"");\r
225         TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
226 \r
227         __pPopUpPanel->AddControl(*pSearchPopUpBottomlabel);\r
228         __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpBottomlabel, true);\r
229 \r
230         __pPopUpLabel = new (std::nothrow) Label();\r
231         TryCatch(__pPopUpLabel != null, , "Failed to allocate memory to __pPopUpLabel");\r
232 \r
233         AppResource::GetInstance()->GetString(L"IDS_COM_POP_SEARCHING", strSearching);\r
234         r = __pPopUpLabel->Construct(Rectangle(20, 30, __pPopUpPanel->GetWidth() - 40, 60), strSearching);\r
235         TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");\r
236 \r
237         __pPopUpLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);\r
238         __pPopUpPanel->AddControl(*__pPopUpLabel);\r
239 \r
240         __pDividerLabel = new (std::nothrow) Label();\r
241         TryCatch(__pDividerLabel != null, r = GetLastResult(), "Failed to allocate memory to __pDividerLabel");\r
242 \r
243         r = __pDividerLabel->Construct(Rectangle(20, 30 + 40, __pPopUpPanel->GetWidth() - 40, 60), L"");\r
244         TryCatch(r == E_SUCCESS, , "failed to construct __pDividerLabel");\r
245 \r
246         __pDividerLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);\r
247 \r
248         __pPopUpPanel->AddControl(*__pDividerLabel);\r
249 \r
250         //The cancel button inside the popup, hides the popup  and stops search thread, when clicked.\r
251         AppResource::GetInstance()->GetString(L"IDS_COM_POP_CANCEL", cancelButton);\r
252         __pCancelSearch = new (std::nothrow) Button();\r
253         TryCatch(__pCancelSearch != null, , "MfMyFilesApp::Button For Popup not created!");\r
254 \r
255         r = __pCancelSearch->Construct(Rectangle(110, __pPopUpPanel->GetHeight() - 84, __pPopUpPanel->GetBounds().width - 220, H_DEFAULT_BUTTON), cancelButton);\r
256         TryCatch(r == E_SUCCESS, , "failed to construct __pButtonPopPUP");\r
257 \r
258         AddControl(*__pPopUpPanel);\r
259         __pPopUpPanel->AddControl(*__pCancelSearch);\r
260 \r
261         __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);\r
262         __pCancelSearch->AddActionEventListener(*this);\r
263 \r
264         SetControlAlwaysOnTop(*__pPopUpPanel, true);\r
265         __pPopUpPanel->SetControlAlwaysOnTop(*__pCancelSearch, true);\r
266 \r
267         __pPopUpPanel->SetShowState(false);\r
268 \r
269 \r
270         __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);\r
271 \r
272         __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));\r
273         TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");\r
274 \r
275         __pListView->SetItemProvider(*this);\r
276         __pListView->AddListViewItemEventListener(*this);\r
277 \r
278         __pSearchModel = new (std::nothrow) SearchPresentationModel();\r
279         TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");\r
280 \r
281         r = __pSearchModel->Initialize();\r
282         TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));\r
283 \r
284         __pSearchedContentList = new (std::nothrow) ArrayList();\r
285         TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");\r
286 \r
287         r = __pSearchedContentList->Construct();\r
288         TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");\r
289 \r
290         __pItemContext = new (std::nothrow) ListContextItem();\r
291 \r
292         r = __pItemContext->Construct();\r
293         TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");\r
294 \r
295         __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);\r
296         __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);\r
297 \r
298         __pItemContext->AddElement(IDA_CONTEXT_DELETE,\r
299                         deleteButtonText,\r
300                         *pDeleteNormalBmp,\r
301                         *pDeletePressBmp,\r
302                         null,\r
303                         true);\r
304 \r
305         __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();\r
306         __previouFormTab = FolderNavigationPresentationModel::GetStorageType();\r
307         pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();\r
308         if (pSceneList != null)\r
309         {\r
310                 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();\r
311         }\r
312 \r
313         GetFolderName();\r
314 \r
315         AppLogDebug("Exit");\r
316 \r
317         if (pDeleteNormalBmp != null)\r
318         {\r
319                 delete pDeleteNormalBmp;\r
320                 pDeleteNormalBmp = null;\r
321         }\r
322         if (pDeletePressBmp != null)\r
323         {\r
324                 delete pDeletePressBmp;\r
325                 pDeletePressBmp = null;\r
326         }\r
327 \r
328         if (pMainLabelBg != null)\r
329         {\r
330                 delete pMainLabelBg;\r
331                 pMainLabelBg = null;\r
332         }\r
333 \r
334         return r;\r
335 \r
336         CATCH:\r
337         if (__pDividerLabel != null)\r
338         {\r
339                 delete __pDividerLabel;\r
340         }\r
341         if (__pPopUpPanel != null)\r
342         {\r
343                 delete __pPopUpPanel;\r
344         }\r
345         if (__pSearchBar != null)\r
346         {\r
347                 delete __pSearchBar;\r
348         }\r
349         if (__pListView != null)\r
350         {\r
351                 delete __pListView;\r
352         }\r
353         if (__pSearchModel != null)\r
354         {\r
355                 delete __pSearchModel;\r
356         }\r
357 \r
358         delete pDeleteNormalBmp;\r
359 \r
360         delete pDeletePressBmp;\r
361 \r
362         delete pMainLabelBg;\r
363 \r
364         AppLogDebug("EXIT::SearchForm::OnInitializing");\r
365         return r;\r
366 }\r
367 \r
368 result\r
369 SearchForm::OnTerminating(void)\r
370 {\r
371         result r = E_SUCCESS;\r
372         //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);\r
373 \r
374         if (__pFolderBitmap)\r
375                 delete __pFolderBitmap;\r
376 \r
377         if (__pDummyImage)\r
378                 delete __pDummyImage;\r
379         return r;\r
380 }\r
381 \r
382 \r
383 ////////////////////////////////////////////////////////////////////////\r
384 // Call-back functions\r
385 ////////////////////////////////////////////////////////////////////////\r
386 \r
387 void\r
388 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,\r
389                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)\r
390 {\r
391         AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));\r
392 \r
393         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
394 \r
395         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);\r
396 #if 0\r
397         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);\r
398 #endif\r
399 \r
400         SceneManager::GetInstance()->AddSceneManagerEventListener(*this);\r
401 \r
402         if (pArgs != null)\r
403         {\r
404                 __bCheckArgsNull = true;\r
405 \r
406                 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();\r
407                 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();\r
408 \r
409                 if (__pFolderEntryPM != null)\r
410                 {\r
411                         __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);\r
412                         if (__currentSearchDirectoryPath.IsEmpty() == false)\r
413                         {\r
414                                 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);\r
415                                 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();\r
416                                 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");\r
417                         }\r
418                 }\r
419                 __isSearchCompleted = false;\r
420                 __isSearchStarted = false;\r
421 \r
422                 String topLevelPath = L"";\r
423 \r
424 \r
425                 if (__SelectedTab == MEMORY_TYPE_PHONE)\r
426                 {\r
427                         topLevelPath = __pFolderEntryPM->GetMediaPath();\r
428                 }\r
429                 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
430                 {\r
431                         topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
432                 }\r
433 \r
434                 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)\r
435                 {\r
436                         AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());\r
437                         __pDividerLabel->SetText(__currentSearchDirectoryPath);\r
438                 }\r
439 \r
440                 pArgs->RemoveAll(false);\r
441                 delete pArgs;\r
442                 pArgs = null;\r
443 \r
444         }\r
445         else\r
446         {\r
447                 __bCheckArgsNull = false;\r
448         }\r
449 \r
450         AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");\r
451         return;\r
452 \r
453         CATCH:\r
454         AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");\r
455         return;\r
456 \r
457 }\r
458 \r
459 void\r
460 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,\r
461                 const Tizen::Ui::Scenes::SceneId& nextSceneId)\r
462 {\r
463         DeviceManager::RemoveAllDeviceEventListeners();\r
464 }\r
465 \r
466 void\r
467 SearchForm::OnFormBackRequested(Form& source)\r
468 {\r
469         TransitionScene();\r
470 }\r
471 \r
472 void\r
473 SearchForm::TransitionScene(void)\r
474 {\r
475         //String rootMediaPath = BasePresentationModel::GetHomePath();\r
476         String rootMediaPath = BasePresentationModel::GetMediaPath();\r
477         SceneManager* pSceneManager = null;\r
478         pSceneManager = SceneManager::GetInstance();\r
479 \r
480         if (__isSearchStarted == true && __isSearchCompleted == false)\r
481         {\r
482                 __pSearchModel->StopSearch();\r
483         }\r
484 \r
485         if (__previousFormPath.CompareTo("") != 0)\r
486         {\r
487                 if (__isCurrentDirectoryRenamed == false)\r
488                         FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);\r
489                 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);\r
490                 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());\r
491         }\r
492 \r
493         if(__pFileEventManager != null)\r
494                 __pFileEventManager->RemovePath(__currentSearchDirectoryPath);\r
495 \r
496 //      pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
497 \r
498         if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)\r
499         {\r
500                 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())\r
501                 {\r
502                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
503                 }\r
504                 else\r
505                 {\r
506                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
507                 }\r
508         }\r
509         else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM ||  __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)\r
510         {\r
511                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
512         }\r
513         else\r
514         {\r
515                 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);\r
516         }\r
517 }\r
518 \r
519 void\r
520 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)\r
521 {\r
522         int modalResult = 0;\r
523         CustomAppControl* pCustomAppControl = null;\r
524         String topLevelPath;\r
525         String emptySearchString;\r
526 \r
527         DirectoryEntry* pFileDetails = null;\r
528         MessageBox messageEmptyString;\r
529 \r
530         AppResource* pAppResource = null;\r
531 \r
532 \r
533         pAppResource = UiApp::GetInstance()->GetAppResource();\r
534         TryReturn(pAppResource != null, , "Failed to fetch AppResource");\r
535 \r
536         pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);\r
537 \r
538         __pathOfSelectedFile = L"";\r
539 \r
540         if (__isCancelClicked == true)\r
541         {\r
542                 return;\r
543         }\r
544         if (index == __itemCount && __searchedAllFolders == false)\r
545         {\r
546                 AppLogDebug("SearchPresentationModel::Search:%d", index);\r
547                 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);\r
548 \r
549                 if (__pSearchBar->GetText().IsEmpty())\r
550                 {\r
551                         messageEmptyString.ShowAndWait(modalResult);\r
552                         return;\r
553                 }\r
554 \r
555                 __searchedAllFolders = true;\r
556 \r
557                 __searchItemIndex = INVALID_LIST_INDEX;\r
558                 //Free the content of  __pSearchedContentList and Delete the same before searching again\r
559                 if (__pSearchedContentList != null)\r
560                 {\r
561                         __pSearchedContentList->RemoveAll(true);\r
562                 }\r
563 \r
564                 __pListView->UpdateList();\r
565                 __pDividerLabel->SetText(L"");\r
566                 __pPopUpPanel->SetShowState(true);\r
567                 __pPopUpPanel->Draw();\r
568                 __pSearchBar->SetEnabled(false);\r
569 \r
570                 if (__SelectedTab == MEMORY_TYPE_PHONE)\r
571                 {\r
572                         topLevelPath = __pFolderEntryPM->GetMediaPath();\r
573                 }\r
574                 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
575                 {\r
576                         topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
577                 }\r
578 \r
579                 __pSearchModel->SetFolderToSearch(topLevelPath);\r
580                 __pSearchModel->SetStringToSearch(__searchText);\r
581                 __pSearchModel->Start();\r
582         }\r
583         else\r
584         {\r
585 \r
586                 if (__isSearchCompleted == false && __isSearchStarted == false)\r
587                 {\r
588                         pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
589                 }\r
590                 else\r
591                 {\r
592                         pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
593                 }\r
594                 TryCatch(pFileDetails != null, , "pFileDetails is Null")\r
595 \r
596 \r
597                 __pathOfSelectedFile = pFileDetails->GetFullFilePath();\r
598 \r
599                 if (pFileDetails->IsDirectory() == true)\r
600                 {\r
601                         String fileName = pFileDetails->GetFileName();\r
602                         String filePath = pFileDetails->GetFullFilePath();\r
603                         LoadSubDirectoryForm(filePath, fileName);\r
604                 }\r
605                 else\r
606                 {\r
607                         //Else launch the corresponding AppControl.\r
608                         if (__pathOfSelectedFile.EndsWith(L".tpk"))\r
609                         {\r
610                                 String* pFileUriScheme = new (std::nothrow) String(L"file://");\r
611                                 pFileUriScheme->Append(__pathOfSelectedFile);\r
612                                 AppControl* pAc = null;\r
613                                 pAc = AppManager::FindAppControlN(L"D7eOJquGtL.Installer", L"http://tizen.org/appcontrol/operation/install");\r
614                                 if(pAc != null)\r
615                                 {\r
616                                         pAc->Start(pFileUriScheme, null, null, null);\r
617                                 }\r
618                                 delete pFileUriScheme;\r
619                         }\r
620                         else\r
621                         {\r
622                                 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();\r
623                                 String parentDirectoryOfSelectedFile = L"";\r
624                                 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);\r
625 \r
626                                 pCustomAppControl = CustomAppControl::GetInstance();\r
627                                 if (pCustomAppControl != null)\r
628                                 {\r
629                                         pCustomAppControl->SetAppControlListener(this);\r
630                                         __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );\r
631                                         AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);\r
632                                         if (pAppControlInUse != null)\r
633                                                 CustomAppControl::SetAppControlInUse(pAppControlInUse);\r
634                                 }\r
635                         }\r
636                 }\r
637         }\r
638         return;\r
639 \r
640         CATCH:\r
641         return;\r
642 }\r
643 \r
644 void\r
645 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)\r
646 {\r
647         //Empty Implementation.\r
648 }\r
649 \r
650 void\r
651 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)\r
652 {\r
653         AppLogDebug("Enter");\r
654         AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);\r
655 \r
656         String filePath = L"";\r
657         DirectoryEntry* pFileDetails = null;\r
658 \r
659         if (__isSearchCompleted == false)\r
660         {\r
661                 if (__isSearchStarted == true)\r
662                 {\r
663                         pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
664                 }\r
665                 else\r
666                 {\r
667                         pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
668                 }\r
669         }\r
670         else\r
671         {\r
672                 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
673         }\r
674         TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");\r
675 \r
676         filePath.Append(pFileDetails->GetFullFilePath());\r
677 \r
678         switch (elementId)\r
679         {\r
680         case IDA_CONTEXT_DETAIL:\r
681         {\r
682                 LoadDetailForm(filePath);\r
683         }\r
684         break;\r
685 \r
686         case IDA_CONTEXT_RENAME:\r
687         {\r
688                 LoadRenameForm(index, pFileDetails);\r
689         }\r
690         break;\r
691 \r
692         case IDA_CONTEXT_DELETE:\r
693         {\r
694                 __selectedItemIndexForDelete = index;\r
695                 __fileToDelete = pFileDetails->GetFullFilePath();\r
696 \r
697                 ShowDeleteConfirmationPopup();\r
698 \r
699         }\r
700         break;\r
701 \r
702         default:\r
703         {\r
704                 //Do nothing\r
705         }\r
706         break;\r
707         }\r
708 \r
709         CATCH:\r
710 \r
711         AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");\r
712 }\r
713 \r
714 int\r
715 SearchForm::GetItemCount(void)\r
716 {\r
717         AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);\r
718         int count = 0;\r
719 \r
720         TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")\r
721 \r
722         if (__isSearchCompleted == false)\r
723         {\r
724                 if (__isSearchStarted == true)\r
725                         count = __pSearchedContentList->GetCount();\r
726                 else\r
727                 {\r
728                         if (__pContentListFromLastView != null)\r
729                                 count = __pContentListFromLastView->GetCount();\r
730                 }\r
731         }\r
732         else\r
733         {\r
734                 count = __pSearchedContentList->GetCount();\r
735                 String topLevelPath = L"";\r
736 \r
737                 if (__SelectedTab == MEMORY_TYPE_PHONE)\r
738                 {\r
739                         topLevelPath = defaultPhoneBody;\r
740                         topLevelPath.Append("/");\r
741                 }\r
742                 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
743                 {\r
744                         topLevelPath = defaultSdCardBody;\r
745                         topLevelPath.Append("/");\r
746                 }\r
747 \r
748                 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)\r
749                 {\r
750                         __itemCount = count++;\r
751                 }\r
752         }\r
753         AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);\r
754         return count;\r
755 \r
756         CATCH:\r
757         AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);\r
758         return count;\r
759 }\r
760 \r
761 ListItemBase*\r
762 SearchForm::CreateItem(int index, int itemWidth)\r
763 {\r
764         AppLogDebug("ENTER::SearchForm::CreateItem");\r
765         result r = E_SUCCESS;\r
766         String filename;\r
767         String imageIconPath;\r
768         String strHightlightedText;\r
769         String filepath;\r
770         String cacheImagePath;\r
771 \r
772         Bitmap* pFetchedCacheImage = null;\r
773         Bitmap* pThumbnailImage = null;\r
774         HashMap* pCacheList = null;\r
775         ContentType contentType = CONTENT_TYPE_UNKNOWN;\r
776 \r
777         Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);\r
778         Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);\r
779 \r
780         AppResource* pAppResource = null;\r
781         DirectoryEntry* pFileDetails = null;\r
782         ContentListItem* pCustomItem = null;\r
783         ThumbRequest* pThumbReq = null;\r
784 \r
785         ArrayList* pList = null;\r
786 \r
787         if (index == __itemCount && __searchedAllFolders == false)\r
788         {\r
789                 CustomItem* pItem = null;\r
790                 String searchAllFolder = L"";\r
791                 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);\r
792                 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);\r
793                 return pItem;\r
794         }\r
795 \r
796         pAppResource = Application::GetInstance()->GetAppResource();\r
797         TryCatch(pAppResource != null, , "Resource manager not found!");\r
798 \r
799         if (__isSearchCompleted == false)\r
800         {\r
801                 if (__isSearchStarted == true)\r
802                 {\r
803                         pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
804                 }\r
805                 else\r
806                 {\r
807                         if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)\r
808                                 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));\r
809                 }\r
810         }\r
811         else\r
812         {\r
813                 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));\r
814         }\r
815         TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");\r
816 \r
817         pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);\r
818         TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");\r
819 \r
820         filename.Clear();\r
821         filename.Append(pFileDetails->GetFileName());\r
822 \r
823         filepath.Clear();\r
824         filepath.Append(pFileDetails->GetFullFilePath());\r
825 \r
826         if (pFileDetails->IsDirectory() == false)\r
827         {\r
828                 filename.Append(".");\r
829                 filename.Append(pFileDetails->GetFileExtension());\r
830         }\r
831 \r
832         if (__searchText.GetLength() > 0)\r
833                 strHightlightedText.Append(__searchText);\r
834 \r
835         pCustomItem->SetTitle(filename, strHightlightedText);\r
836 \r
837 #if 0\r
838         if (__pThumbnailManager != null)\r
839         {\r
840                 if (pFileDetails->IsDirectory() == true)\r
841                 {\r
842                         pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);\r
843                         AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));\r
844                 }\r
845                 else\r
846                 {\r
847                         imageIconPath = pFileDetails->GetFullFilePath();\r
848                         pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);\r
849                 }\r
850                 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");\r
851         }\r
852 #else\r
853 \r
854         contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());\r
855                         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();\r
856 \r
857         if (pFileDetails->IsDirectory() == true)\r
858         {\r
859                 pCustomItem->SetThumbnail(__pFolderBitmap);\r
860         }\r
861         else\r
862         {\r
863                 if (pFileDetails->GetBitmap() == null)\r
864                 {\r
865                         if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))\r
866                         {\r
867                                 if (pFileDetails != null)\r
868                                 {\r
869                                         cacheImagePath = pFileDetails->GetFullFilePath();\r
870                                         AppLogDebug("cache path is %S",cacheImagePath.GetPointer());\r
871                                 }\r
872 \r
873                                 if ((pCacheList->GetValue(cacheImagePath)) != null)\r
874                                 {\r
875                                         pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));\r
876                                 }\r
877                         }\r
878 \r
879                         if (pFetchedCacheImage != null)\r
880                         {\r
881                                 AppLogDebug("image taken from cachemanager");\r
882                                 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);\r
883                                 pCustomItem->SetThumbnail(pThumbnailImage);\r
884                         }\r
885                         else\r
886                         {\r
887                         pCustomItem->SetThumbnail(__pDummyImage);\r
888 \r
889                         pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);\r
890                         TryCatch(pThumbReq != null, , "ThumbRequest is null!");\r
891 \r
892                         pThumbReq->iRquestId = index;\r
893                         pThumbReq->FilePath = pFileDetails->GetFullFilePath();\r
894 \r
895                         pList = new (std::nothrow) ArrayList();\r
896                         TryCatch(pList != null, , "Failed to create pList");\r
897 \r
898                         r = pList->Construct();\r
899                         TryCatch(r == E_SUCCESS, , "Failed to construct pList");\r
900 \r
901                         r = pList->Add(pThumbReq);\r
902                         TryCatch(r == E_SUCCESS, , "Failed to add object to  pList");\r
903 \r
904                         __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);\r
905                         }\r
906                 }\r
907                 else\r
908                 {\r
909                         pCustomItem->SetThumbnail(pFileDetails->GetBitmap());\r
910                 }\r
911         }\r
912 #endif\r
913         if (__bIsResultList)\r
914         {\r
915                 GetParentFolderPath(&filepath);\r
916                 pCustomItem->SetFilepath(filepath);\r
917                 pCustomItem->MakeSearchFormListItem();\r
918         }\r
919         else\r
920         {\r
921                 pCustomItem->Make();\r
922         }       pCustomItem->SetContextItem(__pItemContext);\r
923 \r
924         AppLogDebug("EXIT::SearchForm::CreateItem");\r
925         return pCustomItem;\r
926 \r
927 CATCH:\r
928         if (pCustomItem != null)\r
929         {\r
930                 delete pCustomItem;\r
931         }\r
932         if (pList != null)\r
933         {\r
934                 delete pList;\r
935         }\r
936         if (pThumbReq)\r
937         {\r
938                 delete pThumbReq;\r
939         }\r
940         AppLogDebug("EXIT::SearchForm::CreateItem");\r
941         return null;\r
942 }\r
943 \r
944 bool\r
945 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)\r
946 {\r
947         AppLogDebug("ENTER::SearchForm::DeleteItem");\r
948         if (pItem != null)\r
949         {\r
950                 delete pItem;\r
951                 pItem = null;\r
952         }\r
953         AppLogDebug("EXIT::SearchForm::DeleteItem");\r
954         return true;\r
955 }\r
956 \r
957 void\r
958 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)\r
959 {\r
960         AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");\r
961         int modalResult = 0;\r
962         String emptySearchString;\r
963 \r
964         MessageBox messageEmptyString;\r
965         AppResource* pAppResource = null;\r
966 \r
967         pAppResource = UiApp::GetInstance()->GetAppResource();\r
968         TryReturn(pAppResource != null, , "Failed to fetch AppResource");\r
969 \r
970         pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);\r
971 \r
972         messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);\r
973 \r
974 \r
975         if (__pSearchBar->GetText().IsEmpty())\r
976         {\r
977                 messageEmptyString.ShowAndWait(modalResult);\r
978                 __pSearchBar->ShowKeypad();\r
979                 return;\r
980         }\r
981 \r
982         __isCancelClicked = false;\r
983 \r
984         //Get the text entered in SearchBar\r
985         __searchText.Clear();\r
986         __searchText = __pSearchBar->GetText();\r
987 \r
988         //Start Searching\r
989         if (__searchText.IsEmpty() == false)\r
990                 StartSearch();\r
991 \r
992         AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");\r
993 }\r
994 void\r
995 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)\r
996 {\r
997         AppLogDebug("ENTER::SearchForm::OnKeypadClosed");\r
998 \r
999         __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1000         __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1001 \r
1002         AppLogDebug("EXIT::SearchForm::OnKeypadClosed");\r
1003 }\r
1004 void\r
1005 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)\r
1006 {\r
1007         SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
1008 \r
1009         __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1010         __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1011 \r
1012 }\r
1013 void\r
1014 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)\r
1015 {\r
1016         //Empty Implementation\r
1017 }\r
1018 void\r
1019 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)\r
1020 {\r
1021         AppLogDebug("ENTER::SearchForm::OnActionPerformed");\r
1022         switch (actionId)\r
1023         {\r
1024         case IDA_BTN_POPUP_SEARCH_CANCEL:\r
1025         {\r
1026                 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");\r
1027                 __isSearchCompleted = true;\r
1028 \r
1029                 __pSearchModel->StopSearch();\r
1030 \r
1031                 __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
1032                 __pSearchBar->SetMode(__searchBarMode);\r
1033                 __pSearchBar->HideKeypad();\r
1034 \r
1035                 __pPopUpPanel->SetShowState(false);\r
1036                 __pSearchBar->SetEnabled(true);\r
1037 \r
1038                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
1039                 __searchText.Clear();\r
1040 \r
1041         }\r
1042         break;\r
1043 \r
1044         case IDA_DELETE_FILE:\r
1045         {\r
1046                 HideDeleteConfirmationPopup();\r
1047                 //Call the DeleteFile Function.\r
1048                 DeleteFile(__fileToDelete);\r
1049         }\r
1050         break;\r
1051 \r
1052         case IDA_CANCEL_DELETION:\r
1053         {\r
1054                 HideDeleteConfirmationPopup();\r
1055         }\r
1056         break;\r
1057 \r
1058         default:\r
1059         {\r
1060                 //Do nothing\r
1061         }\r
1062         break;\r
1063         }\r
1064         AppLogDebug("EXIT::SearchForm::OnActionPerformed");\r
1065 }\r
1066 void\r
1067 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)\r
1068 {\r
1069         AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");\r
1070         if (__pPopUpPanel->GetShowState() == true)\r
1071         {\r
1072                 __pPopUpPanel->SetShowState(false);\r
1073                 __pPopUpPanel->Invalidate(true);\r
1074                 __pSearchBar->SetEnabled(true);\r
1075         }\r
1076 }\r
1077 \r
1078 void\r
1079 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)\r
1080 {\r
1081         //Empty Implementation.\r
1082 }\r
1083 \r
1084 //SearchBar Control\r
1085 void\r
1086 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)\r
1087 {\r
1088         AppLogDebug("SearchForm::OnSearchBarModeChanged");\r
1089 \r
1090         if (mode == SEARCH_BAR_MODE_INPUT)\r
1091         {\r
1092                 __searchBarMode = SEARCH_BAR_MODE_INPUT;\r
1093                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
1094         }\r
1095         else\r
1096         {\r
1097                 __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
1098                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);\r
1099                 if (__isSearchStarted == true)\r
1100                 {\r
1101                         if (__isSearchCompleted == false)\r
1102                         {\r
1103                                 //Stop Search Thread\r
1104                                 __pSearchModel->StopSearch();\r
1105 \r
1106                                 //Hide keypad of SearchBar\r
1107                                 __pSearchBar->HideKeypad();\r
1108 \r
1109                                 //Hide popUp\r
1110                                 if (__pPopUpPanel != null)\r
1111                                 {\r
1112                                         __pPopUpPanel->SetShowState(false);\r
1113                                         __pPopUpPanel->Invalidate(true);\r
1114                                 }\r
1115                         }\r
1116                 }\r
1117                 __pListView->UpdateList();\r
1118         }\r
1119 \r
1120         __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1121         __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));\r
1122 \r
1123         __pSearchBar->Invalidate(true);\r
1124 }\r
1125 \r
1126 void\r
1127 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)\r
1128 {\r
1129         CustomAppControl::GetInstance()->SetAppControlInUse(null);\r
1130         ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);\r
1131 \r
1132         __pSearchBar->SetMode(__searchBarMode);\r
1133 \r
1134         if (GetLastResult() == E_FILE_NOT_FOUND)\r
1135         {\r
1136                 __isSearchCompleted = false;\r
1137                 if (__searchText.IsEmpty() == false)\r
1138                         StartSearch();\r
1139         }\r
1140         else\r
1141         {\r
1142                 AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);\r
1143         }\r
1144 \r
1145         if (__pListView != null)\r
1146                 __pListView->UpdateList();\r
1147 }\r
1148 \r
1149 void\r
1150 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)\r
1151 {\r
1152         AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");\r
1153         result r = E_FAILURE;\r
1154         Integer* pEventType = null;\r
1155         DirectoryEntry* pResultDirEntry = null;\r
1156         HashMap* pCacheList = null;\r
1157         DirectoryEntry* pCurrentEntry = null;\r
1158         bool cacheKeyStatus = false;\r
1159         String cachePath;\r
1160 \r
1161         TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");\r
1162 \r
1163         pEventType = static_cast< Integer* >(pArgs->GetAt(0));\r
1164         TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");\r
1165 \r
1166         switch (pEventType->ToInt())\r
1167         {\r
1168         case ID_FOLDER_SEARCH_STARTED:\r
1169         {\r
1170                 String* pFolderSearchResult = (String*) pArgs->GetAt(1);\r
1171                 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");\r
1172 \r
1173                 String defMediaPath(L"/opt/usr/media");\r
1174                 String defSdCardPath(L"/opt/storage/sdcard");\r
1175 \r
1176                 String displayPhone = defaultPhoneBody;\r
1177                 String displaySdCard = defaultSdCardBody;\r
1178 \r
1179 \r
1180                 if (pFolderSearchResult->IsEmpty() == false)\r
1181                 {\r
1182                         if (pFolderSearchResult->StartsWith(defMediaPath, 0))\r
1183                         {\r
1184                                 pFolderSearchResult->Replace(defMediaPath, displayPhone);\r
1185                         }\r
1186                         else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))\r
1187                         {\r
1188                                 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);\r
1189                         }\r
1190 \r
1191                         __pDividerLabel->SetText(*pFolderSearchResult);\r
1192                         __pDividerLabel->Invalidate(true);\r
1193                 }\r
1194         }\r
1195         break;\r
1196 \r
1197         case ID_SEARCH_COMPLETED:\r
1198         {\r
1199                 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");\r
1200                 __isSearchCompleted = true;\r
1201 \r
1202                 __pPopUpPanel->SetShowState(false);\r
1203                 __pPopUpPanel->Invalidate(true);\r
1204                 __pSearchBar->SetEnabled(true);\r
1205 \r
1206                 __pSearchModel->StopSearch();\r
1207 \r
1208                 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)\r
1209                 {\r
1210                         __searchBarMode = SEARCH_BAR_MODE_NORMAL;\r
1211                         __pSearchBar->SetMode(__searchBarMode);\r
1212                         __pSearchBar->SetText(__searchText);\r
1213                 }\r
1214 \r
1215                 //Scroll the List to top\r
1216                 __pListView->ScrollToItem(0);\r
1217         }\r
1218         break;\r
1219 \r
1220         case ID_SEARCH_RESULT_FOUND:\r
1221         {\r
1222                 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");\r
1223                 __isSearchCompleted = false;\r
1224                 __searchItemIndex++;\r
1225                 AppLogDebug("ItemCount::%d", __searchItemIndex);\r
1226 \r
1227                 __pSearchBar->SetText(__searchText);\r
1228 \r
1229                 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));\r
1230                 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");\r
1231 \r
1232                 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());\r
1233 \r
1234                 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);\r
1235                 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);\r
1236 \r
1237                 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));\r
1238 \r
1239                 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to  __pSearchedContentList");\r
1240 \r
1241                 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);\r
1242 \r
1243                 __bIsResultList = true;\r
1244 \r
1245                 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);\r
1246                 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));\r
1247         }\r
1248         break;\r
1249 \r
1250         case FILE_MANAGING_RESULT_DELETING_SUCCESS:\r
1251         {\r
1252                 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");\r
1253                 HideFileProgressingPopup();\r
1254                 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();\r
1255 \r
1256                 if (__isSearchCompleted == true || __isSearchStarted == true)\r
1257                 {\r
1258                         pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));\r
1259 \r
1260                         if (pCurrentEntry != null)\r
1261                         {\r
1262                                 cachePath = pCurrentEntry->GetFullFilePath();\r
1263                         }\r
1264 \r
1265                         if (pCacheList != null)\r
1266                         {\r
1267                                 cacheKeyStatus = pCacheList->ContainsKey(cachePath);\r
1268                                 if (cacheKeyStatus)\r
1269                                 {\r
1270                                         CacheManager::GetInstance()->RemoveCacheEntry(cachePath);\r
1271                                 }\r
1272                         }\r
1273                         __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);\r
1274                 }\r
1275                 else\r
1276                 {\r
1277                         pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));\r
1278 \r
1279                         if (pCurrentEntry != null)\r
1280                         {\r
1281                                 cachePath = pCurrentEntry->GetFullFilePath();\r
1282                         }\r
1283 \r
1284                         if (pCacheList != null)\r
1285                         {\r
1286                                 cacheKeyStatus = pCacheList->ContainsKey(cachePath);\r
1287                                 if (cacheKeyStatus)\r
1288                                 {\r
1289                                         CacheManager::GetInstance()->RemoveCacheEntry(cachePath);\r
1290                                 }\r
1291                         }\r
1292                         __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);\r
1293                 }\r
1294                 __pListView->UpdateList();\r
1295 \r
1296         }\r
1297         break;\r
1298 \r
1299         default:\r
1300                 break;\r
1301         }\r
1302 \r
1303         pArgs->RemoveAll(true);\r
1304         delete pArgs;\r
1305         pArgs = null;\r
1306 \r
1307         AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");\r
1308         return;\r
1309 \r
1310         CATCH:\r
1311 \r
1312         AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");\r
1313         return;\r
1314 }\r
1315 \r
1316 void\r
1317 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)\r
1318 {\r
1319         //Empty Implementation\r
1320 }\r
1321 \r
1322 void\r
1323 SearchForm::OnAllFoldersSearchCompleted(void)\r
1324 {\r
1325         //Empty Implementation\r
1326 }\r
1327 \r
1328 void\r
1329 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)\r
1330 {\r
1331         result r = E_SUCCESS;\r
1332         ArrayList* pArg = null;\r
1333         SceneManager* pSceneManager = null;\r
1334         //int storageType = -1;\r
1335 \r
1336         if (__SelectedTab == MEMORY_TYPE_PHONE)\r
1337         {\r
1338                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);\r
1339         }\r
1340         else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
1341         {\r
1342                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);\r
1343         }\r
1344 \r
1345 \r
1346         FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);\r
1347 \r
1348         pArg = new (std::nothrow) ArrayList();\r
1349         TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");\r
1350 \r
1351         r = pArg->Construct();\r
1352         TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");\r
1353 \r
1354         pArg->Add(&fileName);\r
1355 \r
1356         pSceneManager = SceneManager::GetInstance();\r
1357         TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));\r
1358 \r
1359         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);\r
1360         return;\r
1361 \r
1362 CATCH:\r
1363         if (pArg != null)\r
1364         {\r
1365                 pArg->RemoveAll(true);\r
1366                 delete pArg;\r
1367                 pArg = null;\r
1368         }\r
1369         return;\r
1370 \r
1371 }\r
1372 void\r
1373 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)\r
1374 {\r
1375         //Empty Implementation.\r
1376 }\r
1377 void\r
1378 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)\r
1379 {\r
1380         AppLogDebug("Enter:SearchForm::OnThumbnailReceived");\r
1381         ArrayList* pResultList = null;\r
1382         result res = E_SUCCESS;\r
1383         DirectoryEntry* pFileDetails = null;\r
1384 \r
1385         TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");\r
1386 \r
1387         if (pThumbReq != null)\r
1388         {\r
1389                 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())\r
1390                 {\r
1391                         if (pThumbReq->pBitmap != null)\r
1392                         {\r
1393                                 AppLogDebug("This Bitmap is not requested from same form");\r
1394                                 delete pThumbReq->pBitmap;\r
1395                         }\r
1396                         return;\r
1397                 }\r
1398         }\r
1399 \r
1400         if (__isSearchCompleted == false)\r
1401         {\r
1402                 if (__isSearchStarted == true)\r
1403                         pResultList = __pSearchedContentList;\r
1404                 else\r
1405                         pResultList = __pContentListFromLastView;\r
1406         }\r
1407         else\r
1408                 pResultList = __pSearchedContentList;\r
1409 \r
1410         TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");\r
1411 \r
1412         if (pThumbReq->iRquestId < pResultList->GetCount())\r
1413         {\r
1414                 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));\r
1415                 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");\r
1416 \r
1417                 pFileDetails->SetBitmap(pThumbReq->pBitmap);\r
1418                 if (__pListView && __pListView->IsVisible())\r
1419                 {\r
1420                         res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);\r
1421                 }\r
1422         }\r
1423         else\r
1424                 AppLogDebug("Thumbnail Request is not valid");\r
1425 \r
1426         AppLogDebug("Exit");\r
1427         return;\r
1428         CATCH:\r
1429         if (pThumbReq != null)\r
1430         {\r
1431                 if (pThumbReq->pBitmap != null)\r
1432                         delete pThumbReq->pBitmap;\r
1433         }\r
1434         AppLogDebug("Exit");\r
1435         return;\r
1436 \r
1437 }\r
1438 \r
1439 void\r
1440 SearchForm::LoadDetailForm(String& fullFilePath)\r
1441 {\r
1442         AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());\r
1443         result r = E_FAILURE;\r
1444 \r
1445         SceneManager* pSceneManager = null;\r
1446         ArrayList* pList = null;\r
1447         String* pFullFilePath = null;\r
1448 \r
1449         pList = new (std::nothrow) ArrayList();\r
1450         TryCatch(pList != null, , "Failed to create pList");\r
1451 \r
1452         r = pList->Construct();\r
1453         TryCatch(r == E_SUCCESS, , "Failed to construct pList");\r
1454 \r
1455         pFullFilePath = new (std::nothrow) String(fullFilePath);\r
1456 \r
1457         r = pList->Add(pFullFilePath);\r
1458         TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");\r
1459 \r
1460         pSceneManager = SceneManager::GetInstance();\r
1461         TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");\r
1462 \r
1463         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);\r
1464         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));\r
1465         return;\r
1466 \r
1467         CATCH:\r
1468 \r
1469         if (pFullFilePath != null)\r
1470         {\r
1471                 delete pFullFilePath;\r
1472                 pFullFilePath = null;\r
1473         }\r
1474         if (pList != null)\r
1475         {\r
1476                 delete pList;\r
1477                 pList = null;\r
1478         }\r
1479         return;\r
1480 }\r
1481 \r
1482 void\r
1483 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)\r
1484 {\r
1485         AppLogDebug("ENTER");\r
1486         result r = E_SUCCESS;\r
1487 \r
1488         ArrayList* pArg = null;\r
1489         Integer* pSourceSelected = null;\r
1490         SceneManager* pSceneManager = null;\r
1491 \r
1492         __selectedItemIndexForRename = index;\r
1493 \r
1494         if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))\r
1495                 __isCurrentDirectoryRenamed = true;\r
1496 \r
1497         pSceneManager = SceneManager::GetInstance();\r
1498         TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");\r
1499 \r
1500         pArg = new (std::nothrow) ArrayList;\r
1501         r = pArg->Construct();\r
1502 \r
1503         pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);\r
1504         r = pArg->Add(pSourceSelected);\r
1505         TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");\r
1506 \r
1507         r = pArg->Add(pDirectory);\r
1508         TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");\r
1509 \r
1510         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);\r
1511 \r
1512         return;\r
1513 \r
1514 CATCH:\r
1515         if (pSourceSelected != null)\r
1516         {\r
1517                 delete pSourceSelected;\r
1518         }\r
1519 \r
1520 \r
1521         delete pDirectory;\r
1522 \r
1523         if (pArg != null)\r
1524         {\r
1525                 delete pArg;\r
1526                 pArg = null;\r
1527         }\r
1528         return;\r
1529 }\r
1530 \r
1531 \r
1532 void\r
1533 SearchForm::DeleteFile(String& filePath)\r
1534 {\r
1535         AppLogDebug("ENTER");\r
1536 \r
1537         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);\r
1538         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);\r
1539 \r
1540         FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();\r
1541         if (__pFileManager != null)\r
1542         {\r
1543                 __pFileManager->SetFileManagingListener(this);\r
1544                 __pFileManager->DeleteFolderEntries(&filePath);\r
1545         }\r
1546 \r
1547         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));\r
1548 }\r
1549 \r
1550 \r
1551 void\r
1552 SearchForm::OnFileManagingStart(void)\r
1553 {\r
1554         AppLogDebug("Entry");\r
1555         ShowFileProgressingPopup();\r
1556 }\r
1557 \r
1558 void\r
1559 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)\r
1560 {\r
1561         //Empty Implementation\r
1562 }\r
1563 \r
1564 void\r
1565 SearchForm::ShowFileProgressingPopup(void)\r
1566 {\r
1567         CreateFileProgressingPopup();\r
1568 \r
1569         if (__pFileProgressingPopup != null)\r
1570         {\r
1571                 __pFileProgressingPopup->SetShowState(true);\r
1572                 __pFileProgressingPopup->Show();\r
1573         }\r
1574 }\r
1575 \r
1576 void\r
1577 SearchForm::HideFileProgressingPopup(void)\r
1578 {\r
1579         AppLogDebug("HideFileProgressingPopup:ENTER");\r
1580         if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())\r
1581         {\r
1582                 __pFileProgressingPopup->SetShowState(false);\r
1583 \r
1584                 delete __pFileProgressingPopup;\r
1585                 __pFileProgressingPopup = null;\r
1586         }\r
1587 }\r
1588 \r
1589 result\r
1590 SearchForm::CreateFileProgressingPopup(void)\r
1591 {\r
1592         AppLogDebug("ENTER");\r
1593         result r = E_SUCCESS;\r
1594         String deleting;\r
1595 \r
1596         AppResource* pAppResource = null;\r
1597         pAppResource = UiApp::GetInstance()->GetAppResource();\r
1598         TryReturn(pAppResource != null, r, "Failed to fetch AppResource");\r
1599 \r
1600         pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);\r
1601 \r
1602         __pFileProgressingPopup = new (std::nothrow) Popup();\r
1603         __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");\r
1604 \r
1605         __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));\r
1606         if (__pFileProgressingCancelButton != null)\r
1607         {\r
1608                 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);\r
1609                 __pFileProgressingCancelButton->AddActionEventListener(*this);\r
1610         }\r
1611         __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));\r
1612         if (__pFileProgressingProgress != null)\r
1613         {\r
1614                 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");\r
1615                 __pFileProgressingProgress->SetValue(0);\r
1616         }\r
1617         __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));\r
1618         if (__pFileProgressingHeaderLabel != null)\r
1619         {\r
1620                 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");\r
1621                 __pFileProgressingHeaderLabel->SetText(deleting);\r
1622         }\r
1623         __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));\r
1624         if (__pFileProgressingLabel != null)\r
1625         {\r
1626                 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");\r
1627         }\r
1628 \r
1629         return r;\r
1630 \r
1631 }\r
1632 \r
1633 result\r
1634 SearchForm::CreateDeleteConfirmationPopup(void)\r
1635 {\r
1636         result r = E_SUCCESS;\r
1637         Rectangle popupBounds;\r
1638 \r
1639         //Create a Delete popup control\r
1640         __pDeleteConfirmationPopUp = new (std::nothrow) Popup();\r
1641         __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");\r
1642 \r
1643         popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();\r
1644 \r
1645 \r
1646         __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));\r
1647         TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");\r
1648 \r
1649         __pDelete->SetActionId(IDA_DELETE_FILE);\r
1650         __pDelete->AddActionEventListener(*this);\r
1651         __pDelete->SetShowState(true);\r
1652 \r
1653         __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));\r
1654         TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");\r
1655 \r
1656         __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);\r
1657         __pCancelDeletion->AddActionEventListener(*this);\r
1658         __pCancelDeletion->SetShowState(true);\r
1659 \r
1660         return r;\r
1661 \r
1662 CATCH:\r
1663 \r
1664         if (__pDeleteConfirmationPopUp != null)\r
1665         {\r
1666                 delete __pDeleteConfirmationPopUp;\r
1667                 __pDeleteConfirmationPopUp = null;\r
1668         }\r
1669 \r
1670         return r;\r
1671 \r
1672 }\r
1673 \r
1674 void\r
1675 SearchForm::HideDeleteConfirmationPopup(void)\r
1676 {\r
1677         if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())\r
1678         {\r
1679                 __pDeleteConfirmationPopUp->SetShowState(false);\r
1680 \r
1681                 delete __pDeleteConfirmationPopUp;\r
1682                 __pDeleteConfirmationPopUp = null;\r
1683 \r
1684         }\r
1685 }\r
1686 \r
1687 void\r
1688 SearchForm::ShowDeleteConfirmationPopup(void)\r
1689 {\r
1690         CreateDeleteConfirmationPopup();\r
1691 \r
1692         if (__pDeleteConfirmationPopUp != null)\r
1693         {\r
1694                 __pDeleteConfirmationPopUp->SetShowState(true);\r
1695                 __pDeleteConfirmationPopUp->Show();\r
1696         }\r
1697 }\r
1698 \r
1699 void\r
1700 SearchForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)\r
1701 {\r
1702         bool setMediaPath = false;\r
1703         MemoryType currentMemoryType = MEMORY_TYPE_PHONE;\r
1704         String unmounted = sdCardStatusUnmounted;\r
1705         String removed = usbDeviceStatusRemoved;\r
1706         String currentPath;\r
1707         SceneManager* pSceneManager = null;\r
1708 \r
1709         if (state == unmounted || state == removed)\r
1710         {\r
1711                 currentPath = FolderNavigationPresentationModel::GetCurrentPath();\r
1712                 if (state == unmounted)\r
1713                 {\r
1714                         if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))\r
1715                         {\r
1716                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
1717                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
1718                                 setMediaPath = true;\r
1719                         }\r
1720                 }\r
1721 \r
1722                 if (state == removed)\r
1723                 {\r
1724                         if (currentPath.Contains(BasePresentationModel::GetUsbPath()))\r
1725                         {\r
1726                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
1727                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
1728                                 setMediaPath = true;\r
1729                         }\r
1730                 }\r
1731 \r
1732                 if (setMediaPath)\r
1733                 {\r
1734                         pSceneManager = SceneManager::GetInstance();\r
1735                         if (pSceneManager != null)\r
1736                         {\r
1737                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);                 }\r
1738                 }\r
1739         }\r
1740 }\r
1741 \r
1742 void\r
1743 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)\r
1744 {\r
1745         ComponentType currentDeviceType;\r
1746         switch (deviceType)\r
1747         {\r
1748         case StorageCard:\r
1749         {\r
1750                 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;\r
1751         }\r
1752         break;\r
1753 \r
1754         case UsbClient:\r
1755         {\r
1756                 currentDeviceType = COMPONENT_TYPE_USB;\r
1757         }\r
1758         break;\r
1759 \r
1760         default:\r
1761         {\r
1762                 //Do Nothing.\r
1763         }\r
1764         break;\r
1765         }\r
1766         OnDeviceChange(currentDeviceType, state);\r
1767 }\r
1768 \r
1769 void\r
1770 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,\r
1771                 const Tizen::Ui::Scenes::SceneId &currentSceneId)\r
1772 {\r
1773         SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);\r
1774 //      __pSearchBar->SetText(L"");\r
1775         __pSearchBar->SetMode(__searchBarMode);\r
1776 \r
1777 \r
1778         if (__pFileEventManager != null)\r
1779         {\r
1780                 delete __pFileEventManager;\r
1781                 __pFileEventManager = null;\r
1782 \r
1783         }\r
1784         __pFileEventManager = new (std::nothrow) FileEventManager();\r
1785         __pFileEventManager->Construct(*this);\r
1786 \r
1787         //__pFileEventManager->AddPath(__currentSearchDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );\r
1788 \r
1789         if (__bCheckArgsNull)\r
1790         {\r
1791                 if (__pListView != null)\r
1792                 {\r
1793                         __pListView->UpdateList();\r
1794                 }\r
1795         }\r
1796         else\r
1797         {\r
1798                 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)\r
1799                 {\r
1800                         __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);\r
1801                 }\r
1802         }\r
1803 }\r
1804 \r
1805 void\r
1806 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId &currentSceneId,\r
1807                 const Tizen::Ui::Scenes::SceneId &nextSceneId)\r
1808 {\r
1809         //Empty Implementation.\r
1810 }\r
1811 \r
1812 void\r
1813 SearchForm::StartSearch(void)\r
1814 {\r
1815         String searchtext;\r
1816         String folderToSearch;\r
1817         String topLevelPath;\r
1818 \r
1819         //Hide keypad of Search bar\r
1820         __pSearchBar->HideKeypad();\r
1821         __pSearchBar->SetContentAreaVisible(true);\r
1822         __pSearchBar->SetEnabled(false);\r
1823 \r
1824         //Show Popup\r
1825         __pDividerLabel->SetText(folderToSearch);\r
1826         __pPopUpPanel->SetShowState(true);\r
1827         __pPopUpPanel->Invalidate(true);\r
1828 \r
1829         ///Set Application Notification Listener to current form\r
1830         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);\r
1831 \r
1832         if (__SelectedTab == MEMORY_TYPE_PHONE)\r
1833         {\r
1834                 //topLevelPath = folderEntryPM.GetMediaPath();\r
1835                 topLevelPath = __pFolderEntryPM->GetMediaPath();\r
1836         }\r
1837         else if (__SelectedTab == MEMORY_TYPE_SD_CARD)\r
1838         {\r
1839                 //topLevelPath = folderEntryPM.GetSdCardPath();\r
1840                 topLevelPath = __pFolderEntryPM->GetSdCardPath();\r
1841         }\r
1842 \r
1843         if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))\r
1844         {\r
1845                 __searchedAllFolders = true;\r
1846         }\r
1847 \r
1848         if (__pSearchedContentList != null)\r
1849         {\r
1850                 __pSearchedContentList->RemoveAll(true);\r
1851         }\r
1852         __searchItemIndex = INVALID_LIST_INDEX;\r
1853         __isSearchCompleted = false;\r
1854         __isSearchStarted = true;\r
1855 \r
1856         __pListView->UpdateList();\r
1857 \r
1858         __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);\r
1859         __pSearchModel->SetStringToSearch(__searchText);\r
1860         __pSearchModel->Start();\r
1861 }\r
1862 \r
1863 void\r
1864 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int eventId)\r
1865 {\r
1866         if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))\r
1867         {\r
1868                 __pSearchBar->SetMode(__searchBarMode);\r
1869 \r
1870                 if (__searchText.IsEmpty() == false)\r
1871                         StartSearch();\r
1872 \r
1873                 if (__pListView != null)\r
1874                         __pListView->UpdateList();\r
1875         }\r
1876 }\r
1877 \r
1878 void\r
1879 SearchForm::GetFolderName(void)\r
1880 {\r
1881         String delim(L"/");\r
1882         String token;\r
1883         String fullPath;\r
1884         String folderName(L"Search ");\r
1885 \r
1886         fullPath = FolderNavigationPresentationModel::GetCurrentPath();\r
1887 \r
1888         StringTokenizer tokenizer(fullPath, delim);\r
1889 \r
1890 #if 0\r
1891         DataBindingContext* pContext = null;\r
1892         pContext = GetDataBindingContextN();\r
1893 #endif\r
1894 \r
1895         int Counter = 3;\r
1896 \r
1897         //Use a string tokenizer to get the filepath until it's the last token, break the loop when\r
1898         //it is the last token\r
1899         while (tokenizer.HasMoreTokens())\r
1900         {\r
1901                 if (Counter > 0)\r
1902                 {\r
1903                         Counter--;\r
1904                         tokenizer.GetNextToken(token);\r
1905                 }\r
1906                 else\r
1907                 {\r
1908                         tokenizer.GetNextToken(token);\r
1909                         folderName.Append(token);\r
1910                 }\r
1911         }\r
1912 \r
1913         if (__pSearchBar != null)\r
1914         {\r
1915                 __pSearchBar->SetGuideText(folderName);\r
1916         }\r
1917 }\r
1918 \r
1919 void\r
1920 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)\r
1921 {\r
1922         String displayPath;\r
1923         String delim(L"/");\r
1924         String token;\r
1925 \r
1926         StringTokenizer tokenizer(*filePath, delim);\r
1927 \r
1928         filePath->Clear();\r
1929 \r
1930         //Use a string tokenizer to get the filepath until it's the last token, break the loop when\r
1931         //it is the last token\r
1932         while (tokenizer.HasMoreTokens())\r
1933         {\r
1934                 if (tokenizer.GetTokenCount() != 1)\r
1935                 {\r
1936                         filePath->Append(L"/");\r
1937                         tokenizer.GetNextToken(token);\r
1938                         filePath->Append(token);\r
1939                 }\r
1940                 else\r
1941                 {\r
1942                         break;\r
1943                 }\r
1944         }\r
1945 \r
1946         filePath->Append(L"/");\r
1947 \r
1948         if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))\r
1949         {\r
1950                 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);\r
1951         }\r
1952         else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))\r
1953         {\r
1954                 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);\r
1955         }\r
1956 \r
1957 }\r