Fixed issue 40979
[apps/osp/Gallery.git] / src / GlAlbumNameEditorForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                GlAlbumNameEditorForm.cpp
19  * @brief               This is the implementation file for AlbumNameEditorForm class.
20  */
21
22 #include <FMedia.h>
23 #include <FText.h>
24
25 #include "GlAlbumInfo.h"
26 #include "GlAlbumListPresentationModel.h"
27 #include "GlAlbumNameEditorForm.h"
28 #include "GlFileListPresentationModel.h"
29 #include "GlFileMoveTimer.h"
30 #include "GlProgressAnimation.h"
31 #include "GlResourceManager.h"
32 #include "GlTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Content;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Io;
42 using namespace Tizen::Media;
43 using namespace Tizen::System;
44 using namespace Tizen::Text;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Controls;
47 using namespace Tizen::Ui::Scenes;
48
49
50 static const Rectangle RECT_NAME_EDIT_FIELD (0, 0, 720, 100);
51 static const unsigned int COLOR_NAME_EDIT_FIELD = Color32<255, 255, 255>::Value;
52 static const int ALBUM_MAX_LENGTH = 255;
53
54 AlbumNameEditorForm::AlbumNameEditorForm(void)
55         : __pNameEditField(null)
56         , __folderIndex(0)
57         , __modalMsgBoxResult(0)
58         , __textLength(0)
59         , __mountState(false)
60         , __albumNameEditorMode(ALBUM_NAME_EDITOR_MODE_RENAME)
61         , __pMessageBox(null)
62         , __pMoveIndexList(null)
63         , __fileActionMode(FILE_ACTION_MOVE)
64         , __pFileMove(null)
65         , __pProgressAnim(null)
66         , __pPresentationModel(null)
67         , __pFilePresentationModel(null)
68 {
69         AppLogDebug("ENTER");
70         _overlayMsg = false;
71         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
72 }
73
74 AlbumNameEditorForm::~AlbumNameEditorForm(void)
75 {
76         AppLogDebug("ENTER");
77         DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
78         delete __pFileMove;
79         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
80 }
81
82 result
83 AlbumNameEditorForm::Initialize(void)
84 {
85         AppLogDebug("ENTER");
86         result r = Construct(FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
87         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
88
89         return r;
90 }
91
92 result
93 AlbumNameEditorForm::OnInitializing(void)
94 {
95         AppLogDebug("ENTER");
96         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97         __pFilePresentationModel = FileListPresentationModel::GetInstance();
98
99         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
100         Header* pHeader = GetHeader();
101
102         pHeader->SetStyle(HEADER_STYLE_TITLE);
103
104         GetFooter()->SetBackButtonEnabled(true);
105         GetFooter()->SetBackButton();
106
107         FooterItem itemSave;
108         itemSave.Construct(IDA_BUTTON_CREATE_NAME_SAVE);
109         itemSave.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
110
111         GetFooter()->AddItem(itemSave);
112         GetFooter()->AddActionEventListener(*this);
113         GetFooter()->Invalidate(true);
114
115         SetFormBackEventListener(this);
116         SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
117
118         __pNameEditField = new (std::nothrow) EditField();
119         __pNameEditField->Construct(RECT_NAME_EDIT_FIELD, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
120                         EDIT_FIELD_TITLE_STYLE_NONE, true, ALBUM_MAX_LENGTH);
121         __pNameEditField->AddTextEventListener(*this);
122         __pNameEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_NAME_EDIT_FIELD);
123         __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
124
125         AddControl(__pNameEditField);
126         __pNameEditField->AddActionEventListener(*this);
127
128         return E_SUCCESS;
129 }
130
131 void
132 AlbumNameEditorForm::OnTextValueChanged(const Control& source)
133 {
134         String currentInput;
135         String currentText;
136         String specialCharacters(L"/");
137         String byteCountForInput;
138         int byteCount = 0;
139         int inputLength = 0;
140         int tempLength = 255;
141         int textToCheck = 0;
142         MessageBox messageBox;
143         Utf8Encoding utf8;
144
145         FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
146
147         result r = E_SUCCESS;
148
149         if (__pNameEditField != null)
150         {
151                 byteCountForInput = __pNameEditField->GetText();
152                 r = utf8.GetByteCount(byteCountForInput, byteCount);
153                 AppLogDebug("result is %s",GetErrorMessage(r));
154                 AppLogDebug("Byte count is %d",byteCount);
155         }
156
157         if (__pNameEditField != null)
158         {
159                 currentText = __pNameEditField->GetText();
160                 textToCheck = currentText.GetLength() - __textLength;
161                 if (currentText.IsEmpty())
162                 {
163                         if (GetFooter() != null)
164                         {
165                                 GetFooter()->SetItemEnabled(0, false);
166                                 GetFooter()->Invalidate(true);
167                         }
168                 }
169                 else
170                 {
171                         if (GetFooter() != null)
172                         {
173                                 GetFooter()->GetItemStatus(0, currentStatus);
174
175                                 if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
176                                 {
177                                         GetFooter()->SetItemEnabled(0,true);
178                                         GetFooter()->Invalidate(true);
179                                 }
180                         }
181                 }
182
183                 if (currentText.StartsWith(".", 0))
184                 {
185                         String invalidCharacterString;
186                         String validString;
187                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
188                         CreateMessage(msg);
189                         validString = __pNameEditField->GetText();
190
191                         if (validString.GetLength() > 1)
192                         {
193                                 validString.Remove(0,1);
194                                 __pNameEditField->SetText(validString);
195                         }
196                         else
197                         {
198                                 __pNameEditField->SetText("");
199
200                                 if (GetFooter() != null)
201                                 {
202                                         GetFooter()->SetItemEnabled(0, false);
203                                         GetFooter()->Invalidate(true);
204                                 }
205                         }
206                         __pNameEditField->ShowKeypad();
207                 }
208
209                 currentInput = __pNameEditField->GetText();
210
211                 if (currentInput.Contains(specialCharacters[0]))
212                 {
213                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
214                         CreateMessage(msg);
215                         currentInput.Replace("/", "");
216                         __pNameEditField->SetText(currentInput);
217                 }
218
219                 inputLength = byteCount;
220                 if (inputLength  >= tempLength)
221                 {
222                         String maxCharacterString;
223                         String currentInputCharacter;
224                         int checkByteCount = 0;
225                         int lengthOfFinalString = 0;
226                         int currentCharacter = 0;
227
228                         String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
229                         CreateMessage(msg);
230                         currentText = __pNameEditField->GetText();
231
232                         for (currentCharacter=0; checkByteCount < tempLength; currentCharacter++)
233                         {
234                                 currentInputCharacter.Clear();
235                                 currentInputCharacter = currentText[currentCharacter];
236                                 r = utf8.GetByteCount(currentInputCharacter, byteCount);
237                                 if (r != E_SUCCESS)
238                                 {
239                                         break;
240                                 }
241                                 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
242                                 checkByteCount = checkByteCount + byteCount;
243                                 lengthOfFinalString++;
244                         }
245
246                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
247                         AppLogDebug("current input is %S", currentInput.GetPointer());
248                         r = __pNameEditField->SetText(currentInput);
249                         __pNameEditField->ShowKeypad();
250                         return;
251                 }
252
253                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
254                 __textLength = byteCount;
255         }
256
257         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
258 }
259
260 void
261 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
262 {
263         AppLogDebug("ENTER");
264         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
265 }
266
267 result
268 AlbumNameEditorForm::OnTerminating(void)
269 {
270         AppLogDebug("ENTER");
271         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
272
273         return E_SUCCESS;
274 }
275
276 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
277 {
278         Invalidate(true);
279 }
280
281 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
282 {
283         _overlayMsg = false;
284         if (res != COMPLETE_SUCCESS)
285         {
286                 __pNameEditField->SetText(__nameEditFieldPreText);
287                 __pNameEditField->HideKeypad();
288                 __pNameEditField->Draw();
289                 SceneManager* pSceneManager = SceneManager::GetInstance();
290                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
291         }
292 }
293
294 void
295 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
296 {
297         AppLogDebug("Rename Album");
298         String path;
299         int index = 0;
300         strOri.Reverse();
301         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
302         strOri.Reverse();
303         strOri.SubString(0, (strOri.GetLength() - index), path);
304         path.Append(__nameEditFieldText);
305
306         //Rename
307         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
308
309         if (IsFailed(r))
310         {
311                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
312                 if (__pMessageBox == null)
313                 {
314                         __pMessageBox = new (std::nothrow) MessageBox();
315                         if (r == E_FILE_ALREADY_EXIST)
316                         {
317                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
318                                                           MSGBOX_STYLE_NONE, 3000);
319                         }
320                         else
321                         {
322                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
323                                                           MSGBOX_STYLE_NONE, 3000);
324                         }
325                         int modalResult = 0;
326                         _overlayMsg = true;
327                         __pMessageBox->ShowAndWait(modalResult);
328                         _overlayMsg = false;
329                         delete __pMessageBox;
330                         __pMessageBox = null;
331                 }
332         }
333         else
334         {
335                 //Add a popup here
336                 Rectangle clientRect= GetClientAreaBounds();
337                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
338                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
339                 __pProgressAnim->Construct(rect);
340                 AddControl(__pProgressAnim);
341                 __pProgressAnim->SetShowState(true);
342                 GetFooter()->SetEnabled(false);
343                 __pProgressAnim->AnimationStart();
344                 __pProgressAnim->Draw();
345                 _overlayMsg = true;
346         }
347 }
348
349 void
350 AlbumNameEditorForm::OnCreateAlbum(void)
351 {
352         String path;
353         __pNameEditField->HideKeypad();
354         __pNameEditField->RequestRedraw();
355         path.Append(Tizen::System::Environment::GetMediaPath());
356         path.Append(__nameEditFieldText);
357
358         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
359         {
360                 Directory::Create(path, true);
361         }
362
363         __nameEditFieldPreText = __nameEditFieldText;
364
365         if (path.IsEmpty())
366         {
367                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
368                 delete __pMoveIndexList;
369                 __pMoveIndexList = null;
370                 return ;
371         }
372
373         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
374         {
375                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
376                 delete __pMoveIndexList;
377                 __pMoveIndexList = null;
378                 return ;
379         }
380
381         delete __pFileMove;
382         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
383         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
384         if (__fileActionMode == FILE_ACTION_COPY)
385         {
386                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
387                 __pFileMove->SetCopy();
388         }
389         else
390         {
391                 __pFileMove->ClearCopy();
392         }
393         result r = __pFileMove->StartTimer();
394
395         if (IsFailed(r))
396         {
397                 delete __pFileMove;
398                 __pFileMove = null;
399                 __pNameEditField->SetText(__nameEditFieldPreText);
400                 __pNameEditField->HideKeypad();
401                 __pNameEditField->Draw();
402                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
403                 SceneManager* pSceneManager = SceneManager::GetInstance();
404                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
405         }
406         else
407         {
408                 AppLogDebug("MoveToContentFileList content in progress");
409                 _overlayMsg = true;
410                 __fileActionMode = FILE_ACTION_MOVE;
411         }
412 }
413
414 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
415 {
416         //Hide popup here..
417         __pProgressAnim->AnimationStop();
418         __pProgressAnim->SetShowState(false);
419         RemoveControl(__pProgressAnim);
420         _overlayMsg = false;
421         GetFooter()->SetEnabled(true);
422         SceneManager* pSceneManager = SceneManager::GetInstance();
423         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
424 }
425
426 void
427 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
428 {
429         AppLogDebug("ENTER");
430         String path;
431         __nameEditFieldText = __pNameEditField->GetText();
432
433         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
434         {
435                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
436                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
437                 path = pAlbumInfo->GetDirectory(0);
438         }
439
440         switch (actionId)
441         {
442         case IDA_BUTTON_CREATE_NAME_SAVE:
443         {
444                 __pNameEditField->SetEnabled(false);
445
446                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
447                 {
448                         OnCreateAlbum();
449                 }
450                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
451                 {
452                         String albumName = __pNameEditField->GetText();
453                         if (__originalText.Equals(albumName , true))
454                         {
455                                 SceneManager* pSceneManager = SceneManager::GetInstance();
456                                 pSceneManager->GoBackward(BackwardSceneTransition());
457                         }
458                         else
459                         {
460                                 OnRenameAlbum(path);
461                         }
462                 }
463                 break;
464         }
465
466         default:
467                 break;
468         }
469         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
470 }
471
472 void
473 AlbumNameEditorForm::OnFormBackRequested(Form& source)
474 {
475         AppLogDebug("ENTER");
476         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
477         {
478                 SceneManager* pSceneManager = SceneManager::GetInstance();
479                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
480         }
481         else
482         {
483                 SceneManager* pSceneManager = SceneManager::GetInstance();
484                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
485         }
486         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
487 }
488
489 void
490 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
491                 const SceneId& currentSceneId, IList* pArgs)
492 {
493         AppLogDebug("ENTER");
494         __pPresentationModel = AlbumListPresentationModel::GetInstance();
495         __previousSceneId = previousSceneId;
496
497         __pPresentationModel->AddContentEventListener(this);
498
499         if (pArgs != null)
500         {
501                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
502                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
503                 {
504                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
505                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
506                 }
507                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
508                 {
509                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
510                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
511                 }
512                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
513         }
514
515         if (pArgs != null)
516         {
517                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
518                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
519                 {
520                         AppLogDebug("Rash: FILE_MOVE_ACTION");
521                         __fileActionMode = FILE_ACTION_MOVE;
522                 }
523                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
524                 {
525                         AppLogDebug("Rash: FILE_COPY_ACTION");
526                         __fileActionMode = FILE_ACTION_COPY;
527                 }
528                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
529         }
530
531         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
532         {
533                 if (pArgs != null)
534                 {
535                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
536                         if (pEnum->MoveNext() == E_SUCCESS)
537                         {
538                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
539                                 if (index != null)
540                                 {
541                                         __folderIndex = index->ToInt();
542                                 }
543                         }
544                         delete pEnum;
545                         delete pArgs;
546                 }
547         }
548
549         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
550                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
551                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
552                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
553         {
554                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
555                 {
556                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
557                 }
558                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
559                 {
560                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
561                 }
562
563                 __callerSceneId = previousSceneId;
564         }
565         else
566         {
567                 __callerSceneId = EMPTY_SPACE;
568         }
569
570         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
571         {
572                 __nameEditFieldText = EMPTY_SPACE;
573                 __nameEditFieldPreText = EMPTY_SPACE;
574                 __pNameEditField->SetText(__nameEditFieldText);
575                 __nameEditFieldTempText = __nameEditFieldText;
576                 __pNameEditField->ShowKeypad();
577                 __pNameEditField->SetFocus();
578
579                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
580                 GetFooter()->SetItemEnabled(0, false);
581                 GetFooter()->Invalidate(true);
582         }
583         else
584         {
585                 int byteCount = 0;
586                 Utf8Encoding utf8;
587                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
588                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
589
590                 String strName = pAlbumInfo->GetAlbumName();
591                 __nameEditFieldText = strName;
592                 __nameEditFieldPreText = strName;
593                 __pNameEditField->SetText(__nameEditFieldText);
594                 __nameEditFieldTempText = __nameEditFieldText;
595                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
596                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
597                 __pNameEditField->ShowKeypad();
598                 __pNameEditField->SetFocus();
599                 __originalText = __pNameEditField->GetText();
600                 utf8.GetByteCount(__nameEditFieldText, byteCount);
601                 __textLength = byteCount;
602                 GetFooter()->SetItemEnabled(0, true);
603                 GetFooter()->Invalidate(true);
604         }
605
606         if (pArgs != NULL)
607         {
608                 __pMoveIndexList = pArgs;
609         }
610
611         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
612 }
613
614 void
615 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
616                 const SceneId& nextSceneId)
617 {
618         AppLogDebug("ENTER");
619         __pPresentationModel->RemoveContentEventListener(*this);
620         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
621 }
622
623 void
624 AlbumNameEditorForm::OnContentUpdated(void)
625 {
626         AppLogDebug("ENTER");
627
628         if ( __mountState == false )
629         {
630                 SceneManager* pSceneManager = SceneManager::GetInstance();
631                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
632                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
633         }
634         else
635         {
636                 __mountState = false;
637         }
638 }
639
640 void
641 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
642 {
643         AppLogDebug("ENTER");
644
645         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
646         {
647                 if ( __pFileMove && __pFileMove->IsStarted() )
648                 {
649                         __pFileMove->Cancel();
650                         delete __pFileMove;
651                         __pFileMove = null;
652                 }
653                 __mountState = false;
654                 SceneManager* pSceneManager = SceneManager::GetInstance();
655                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
656                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
657         }
658         else
659         {
660                 __mountState = true;
661         }
662         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
663 }
664
665 void
666 AlbumNameEditorForm::CreateMessage(String& str)
667 {
668         if (__pMessageBox == null)
669         {
670                 __pMessageBox = new(std::nothrow) MessageBox;
671
672                 if (__pMessageBox != null)
673                 {
674                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
675                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
676
677                         delete __pMessageBox;
678                         __pMessageBox = null;
679                         __modalMsgBoxResult = 0;
680                 }
681         }
682 }