4da5a0a35f5222f9390c5ab373db3e8fae70d90e
[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         FooterItem itemSave;
105         itemSave.Construct(IDA_BUTTON_CREATE_NAME_SAVE);
106         itemSave.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
107
108         GetFooter()->AddItem(itemSave);
109         GetFooter()->AddActionEventListener(*this);
110         GetFooter()->Invalidate(true);
111
112         SetFormBackEventListener(this);
113         SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
114
115         __pNameEditField = new (std::nothrow) EditField();
116         __pNameEditField->Construct(RECT_NAME_EDIT_FIELD, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
117                         EDIT_FIELD_TITLE_STYLE_NONE, true, ALBUM_MAX_LENGTH);
118         __pNameEditField->AddTextEventListener(*this);
119         __pNameEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_NAME_EDIT_FIELD);
120         __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
121
122         AddControl(__pNameEditField);
123         __pNameEditField->AddActionEventListener(*this);
124
125         return E_SUCCESS;
126 }
127
128 void
129 AlbumNameEditorForm::OnTextValueChanged(const Control& source)
130 {
131         String currentInput;
132         String currentText;
133         String specialCharacters(L"/");
134         String byteCountForInput;
135         int byteCount = 0;
136         int inputLength = 0;
137         int tempLength = 255;
138         int textToCheck = 0;
139         MessageBox messageBox;
140         Utf8Encoding utf8;
141
142         FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
143
144         result r = E_SUCCESS;
145
146         if (__pNameEditField != null)
147         {
148                 byteCountForInput = __pNameEditField->GetText();
149                 r = utf8.GetByteCount(byteCountForInput, byteCount);
150                 AppLogDebug("result is %s",GetErrorMessage(r));
151                 AppLogDebug("Byte count is %d",byteCount);
152         }
153
154         if (__pNameEditField != null)
155         {
156                 currentText = __pNameEditField->GetText();
157                 textToCheck = currentText.GetLength() - __textLength;
158                 if (currentText.IsEmpty())
159                 {
160                         if (GetFooter() != null)
161                         {
162                                 GetFooter()->SetItemEnabled(0, false);
163                                 GetFooter()->Invalidate(true);
164                         }
165                 }
166                 else
167                 {
168                         if (GetFooter() != null)
169                         {
170                                 GetFooter()->GetItemStatus(0, currentStatus);
171
172                                 if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
173                                 {
174                                         GetFooter()->SetItemEnabled(0,true);
175                                         GetFooter()->Invalidate(true);
176                                 }
177                         }
178                 }
179
180                 if (currentText.StartsWith(".", 0))
181                 {
182                         String invalidCharacterString;
183                         String validString;
184                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
185                         CreateMessage(msg);
186                         validString = __pNameEditField->GetText();
187
188                         if (validString.GetLength() > 1)
189                         {
190                                 validString.Remove(0,1);
191                                 __pNameEditField->SetText(validString);
192                         }
193                         else
194                         {
195                                 __pNameEditField->SetText("");
196
197                                 if (GetFooter() != null)
198                                 {
199                                         GetFooter()->SetItemEnabled(0, false);
200                                         GetFooter()->Invalidate(true);
201                                 }
202                         }
203                         __pNameEditField->ShowKeypad();
204                 }
205
206                 currentInput = __pNameEditField->GetText();
207
208                 if (currentInput.Contains(specialCharacters[0]))
209                 {
210                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
211                         CreateMessage(msg);
212                         currentInput.Replace("/", "");
213                         __pNameEditField->SetText(currentInput);
214                 }
215
216                 inputLength = byteCount;
217                 if (inputLength  >= tempLength)
218                 {
219                         String maxCharacterString;
220                         String currentInputCharacter;
221                         int checkByteCount = 0;
222                         int lengthOfFinalString = 0;
223                         int currentCharacter = 0;
224
225                         String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
226                         CreateMessage(msg);
227                         currentText = __pNameEditField->GetText();
228
229                         for (currentCharacter=0; checkByteCount < tempLength; currentCharacter++)
230                         {
231                                 currentInputCharacter.Clear();
232                                 currentInputCharacter = currentText[currentCharacter];
233                                 r = utf8.GetByteCount(currentInputCharacter, byteCount);
234                                 if (r != E_SUCCESS)
235                                 {
236                                         break;
237                                 }
238                                 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
239                                 checkByteCount = checkByteCount + byteCount;
240
241                                 if( checkByteCount < tempLength)
242                                 {
243                                         lengthOfFinalString++;
244                                 }
245                         }
246
247                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
248                         AppLogDebug("current input is %S", currentInput.GetPointer());
249                         r = __pNameEditField->SetText(currentInput);
250                         __pNameEditField->ShowKeypad();
251                         return;
252                 }
253
254                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
255                 __textLength = byteCount;
256         }
257
258         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
259 }
260
261 void
262 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
263 {
264         AppLogDebug("ENTER");
265         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
266 }
267
268 result
269 AlbumNameEditorForm::OnTerminating(void)
270 {
271         AppLogDebug("ENTER");
272         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
273
274         return E_SUCCESS;
275 }
276
277 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
278 {
279         Invalidate(true);
280 }
281
282 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
283 {
284         _overlayMsg = false;
285         if (res != COMPLETE_SUCCESS)
286         {
287                 __pNameEditField->SetText(__nameEditFieldPreText);
288                 __pNameEditField->HideKeypad();
289                 __pNameEditField->Draw();
290                 SceneManager* pSceneManager = SceneManager::GetInstance();
291                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
292         }
293 }
294
295 void
296 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
297 {
298         AppLogDebug("Rename Album");
299         String path;
300         int index = 0;
301         strOri.Reverse();
302         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
303         strOri.Reverse();
304         strOri.SubString(0, (strOri.GetLength() - index), path);
305         path.Append(__nameEditFieldText);
306
307         //Rename
308         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
309
310         if (IsFailed(r))
311         {
312                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
313                 if (__pMessageBox == null)
314                 {
315                         __pMessageBox = new (std::nothrow) MessageBox();
316                         if (r == E_FILE_ALREADY_EXIST)
317                         {
318                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
319                                                           MSGBOX_STYLE_NONE, 3000);
320                         }
321                         else
322                         {
323                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
324                                                           MSGBOX_STYLE_NONE, 3000);
325                         }
326                         int modalResult = 0;
327                         _overlayMsg = true;
328                         __pMessageBox->ShowAndWait(modalResult);
329                         _overlayMsg = false;
330                         delete __pMessageBox;
331                         __pMessageBox = null;
332                 }
333         }
334         else
335         {
336                 //Add a popup here
337                 Rectangle clientRect= GetClientAreaBounds();
338                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
339                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
340                 __pProgressAnim->Construct(rect);
341                 AddControl(__pProgressAnim);
342                 __pProgressAnim->SetShowState(true);
343                 GetFooter()->SetEnabled(false);
344                 __pProgressAnim->AnimationStart();
345                 __pProgressAnim->Draw();
346                 _overlayMsg = true;
347         }
348 }
349
350 void
351 AlbumNameEditorForm::OnCreateAlbum(void)
352 {
353         String path;
354         __pNameEditField->HideKeypad();
355         __pNameEditField->RequestRedraw();
356         path.Append(Tizen::System::Environment::GetMediaPath());
357         path.Append(__nameEditFieldText);
358
359         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
360         {
361                 Directory::Create(path, true);
362         }
363
364         __nameEditFieldPreText = __nameEditFieldText;
365
366         if (path.IsEmpty())
367         {
368                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
369                 delete __pMoveIndexList;
370                 __pMoveIndexList = null;
371                 return ;
372         }
373
374         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
375         {
376                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
377                 delete __pMoveIndexList;
378                 __pMoveIndexList = null;
379                 return ;
380         }
381
382         delete __pFileMove;
383         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
384         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
385         if (__fileActionMode == FILE_ACTION_COPY)
386         {
387                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
388                 __pFileMove->SetCopy();
389         }
390         else
391         {
392                 __pFileMove->ClearCopy();
393         }
394         result r = __pFileMove->StartTimer();
395
396         if (IsFailed(r))
397         {
398                 delete __pFileMove;
399                 __pFileMove = null;
400                 __pNameEditField->SetText(__nameEditFieldPreText);
401                 __pNameEditField->HideKeypad();
402                 __pNameEditField->Draw();
403                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
404                 SceneManager* pSceneManager = SceneManager::GetInstance();
405                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
406         }
407         else
408         {
409                 AppLogDebug("MoveToContentFileList content in progress");
410                 _overlayMsg = true;
411                 __fileActionMode = FILE_ACTION_MOVE;
412         }
413 }
414
415 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
416 {
417         //Hide popup here..
418         __pProgressAnim->AnimationStop();
419         __pProgressAnim->SetShowState(false);
420         RemoveControl(__pProgressAnim);
421         _overlayMsg = false;
422         GetFooter()->SetEnabled(true);
423         SceneManager* pSceneManager = SceneManager::GetInstance();
424         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
425 }
426
427 void
428 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
429 {
430         AppLogDebug("ENTER");
431         String path;
432         __nameEditFieldText = __pNameEditField->GetText();
433
434         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
435         {
436                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
437                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
438                 path = pAlbumInfo->GetDirectory(0);
439         }
440
441         switch (actionId)
442         {
443         case IDA_BUTTON_CREATE_NAME_SAVE:
444         {
445                 __pNameEditField->SetEnabled(false);
446
447                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
448                 {
449                         OnCreateAlbum();
450                 }
451                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
452                 {
453                         String albumName = __pNameEditField->GetText();
454                         if (__originalText.Equals(albumName , true))
455                         {
456                                 SceneManager* pSceneManager = SceneManager::GetInstance();
457                                 pSceneManager->GoBackward(BackwardSceneTransition());
458                         }
459                         else
460                         {
461                                 OnRenameAlbum(path);
462                         }
463                 }
464                 break;
465         }
466
467         default:
468                 break;
469         }
470         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
471 }
472
473 void
474 AlbumNameEditorForm::OnFormBackRequested(Form& source)
475 {
476         AppLogDebug("ENTER");
477         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
478         {
479                 SceneManager* pSceneManager = SceneManager::GetInstance();
480                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
481         }
482         else
483         {
484                 SceneManager* pSceneManager = SceneManager::GetInstance();
485                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
486         }
487         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
488 }
489
490 void
491 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
492                 const SceneId& currentSceneId, IList* pArgs)
493 {
494         AppLogDebug("ENTER");
495         __pPresentationModel = AlbumListPresentationModel::GetInstance();
496         __previousSceneId = previousSceneId;
497
498         __pNameEditField->SetEnabled(true);
499         __pPresentationModel->AddContentEventListener(this);
500
501         if (pArgs != null)
502         {
503                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
504                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
505                 {
506                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
507                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
508                 }
509                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
510                 {
511                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
512                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
513                 }
514                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
515         }
516
517         if (pArgs != null)
518         {
519                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
520                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
521                 {
522                         AppLogDebug("Rash: FILE_MOVE_ACTION");
523                         __fileActionMode = FILE_ACTION_MOVE;
524                 }
525                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
526                 {
527                         AppLogDebug("Rash: FILE_COPY_ACTION");
528                         __fileActionMode = FILE_ACTION_COPY;
529                 }
530                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
531         }
532
533         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
534         {
535                 if (pArgs != null)
536                 {
537                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
538                         if (pEnum->MoveNext() == E_SUCCESS)
539                         {
540                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
541                                 if (index != null)
542                                 {
543                                         __folderIndex = index->ToInt();
544                                 }
545                         }
546                         delete pEnum;
547                         delete pArgs;
548                 }
549         }
550
551         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
552                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
553                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
554                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
555         {
556                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
557                 {
558                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
559                 }
560                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
561                 {
562                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
563                 }
564
565                 __callerSceneId = previousSceneId;
566         }
567         else
568         {
569                 __callerSceneId = EMPTY_SPACE;
570         }
571
572         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
573         {
574                 __nameEditFieldText = EMPTY_SPACE;
575                 __nameEditFieldPreText = EMPTY_SPACE;
576                 __pNameEditField->SetText(__nameEditFieldText);
577                 __nameEditFieldTempText = __nameEditFieldText;
578                 __pNameEditField->ShowKeypad();
579                 __pNameEditField->SetFocus();
580
581                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
582                 GetFooter()->SetItemEnabled(0, false);
583                 GetFooter()->Invalidate(true);
584         }
585         else
586         {
587                 int byteCount = 0;
588                 Utf8Encoding utf8;
589                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
590                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
591
592                 String strName = pAlbumInfo->GetAlbumName();
593                 __nameEditFieldText = strName;
594                 __nameEditFieldPreText = strName;
595                 __pNameEditField->SetText(__nameEditFieldText);
596                 __nameEditFieldTempText = __nameEditFieldText;
597                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
598                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
599                 __pNameEditField->ShowKeypad();
600                 __pNameEditField->SetFocus();
601                 __originalText = __pNameEditField->GetText();
602                 utf8.GetByteCount(__nameEditFieldText, byteCount);
603                 __textLength = byteCount;
604                 GetFooter()->SetItemEnabled(0, true);
605                 GetFooter()->Invalidate(true);
606         }
607
608         if (pArgs != NULL)
609         {
610                 __pMoveIndexList = pArgs;
611         }
612
613         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
614 }
615
616 void
617 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
618                 const SceneId& nextSceneId)
619 {
620         AppLogDebug("ENTER");
621         __pPresentationModel->RemoveContentEventListener(*this);
622         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
623 }
624
625 void
626 AlbumNameEditorForm::OnContentUpdated(void)
627 {
628         AppLogDebug("ENTER");
629
630         if ( __mountState == false )
631         {
632                 SceneManager* pSceneManager = SceneManager::GetInstance();
633                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
634                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
635         }
636         else
637         {
638                 __mountState = false;
639         }
640 }
641
642 void
643 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
644 {
645         AppLogDebug("ENTER");
646
647         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
648         {
649                 if ( __pFileMove && __pFileMove->IsStarted() )
650                 {
651                         __pFileMove->Cancel();
652                         delete __pFileMove;
653                         __pFileMove = null;
654                 }
655                 __mountState = false;
656                 SceneManager* pSceneManager = SceneManager::GetInstance();
657                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
658                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
659         }
660         else
661         {
662                 __mountState = true;
663         }
664         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
665 }
666
667 void
668 AlbumNameEditorForm::CreateMessage(String& str)
669 {
670         if (__pMessageBox == null)
671         {
672                 __pMessageBox = new(std::nothrow) MessageBox;
673
674                 if (__pMessageBox != null)
675                 {
676                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
677                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
678
679                         delete __pMessageBox;
680                         __pMessageBox = null;
681                         __modalMsgBoxResult = 0;
682                 }
683         }
684 }