Fixed multiple messageBox problem
[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
244                                 if( checkByteCount < tempLength)
245                                 {
246                                         lengthOfFinalString++;
247                                 }
248                         }
249
250                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
251                         AppLogDebug("current input is %S", currentInput.GetPointer());
252                         r = __pNameEditField->SetText(currentInput);
253                         __pNameEditField->ShowKeypad();
254                         return;
255                 }
256
257                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
258                 __textLength = byteCount;
259         }
260
261         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
262 }
263
264 void
265 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
266 {
267         AppLogDebug("ENTER");
268         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
269 }
270
271 result
272 AlbumNameEditorForm::OnTerminating(void)
273 {
274         AppLogDebug("ENTER");
275         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
276
277         return E_SUCCESS;
278 }
279
280 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
281 {
282         Invalidate(true);
283 }
284
285 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
286 {
287         _overlayMsg = false;
288         if (res != COMPLETE_SUCCESS)
289         {
290                 __pNameEditField->SetText(__nameEditFieldPreText);
291                 __pNameEditField->HideKeypad();
292                 __pNameEditField->Draw();
293                 SceneManager* pSceneManager = SceneManager::GetInstance();
294                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
295         }
296 }
297
298 void
299 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
300 {
301         AppLogDebug("Rename Album");
302         String path;
303         int index = 0;
304         strOri.Reverse();
305         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
306         strOri.Reverse();
307         strOri.SubString(0, (strOri.GetLength() - index), path);
308         path.Append(__nameEditFieldText);
309
310         //Rename
311         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
312
313         if (IsFailed(r))
314         {
315                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
316                 if (__pMessageBox == null)
317                 {
318                         __pMessageBox = new (std::nothrow) MessageBox();
319                         if (r == E_FILE_ALREADY_EXIST)
320                         {
321                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
322                                                           MSGBOX_STYLE_NONE, 3000);
323                         }
324                         else
325                         {
326                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
327                                                           MSGBOX_STYLE_NONE, 3000);
328                         }
329                         int modalResult = 0;
330                         _overlayMsg = true;
331                         __pMessageBox->ShowAndWait(modalResult);
332                         _overlayMsg = false;
333                         delete __pMessageBox;
334                         __pMessageBox = null;
335                 }
336         }
337         else
338         {
339                 //Add a popup here
340                 Rectangle clientRect= GetClientAreaBounds();
341                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
342                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
343                 __pProgressAnim->Construct(rect);
344                 AddControl(__pProgressAnim);
345                 __pProgressAnim->SetShowState(true);
346                 GetFooter()->SetEnabled(false);
347                 __pProgressAnim->AnimationStart();
348                 __pProgressAnim->Draw();
349                 _overlayMsg = true;
350         }
351 }
352
353 void
354 AlbumNameEditorForm::OnCreateAlbum(void)
355 {
356         String path;
357         __pNameEditField->HideKeypad();
358         __pNameEditField->RequestRedraw();
359         path.Append(Tizen::System::Environment::GetMediaPath());
360         path.Append(__nameEditFieldText);
361
362         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
363         {
364                 Directory::Create(path, true);
365         }
366
367         __nameEditFieldPreText = __nameEditFieldText;
368
369         if (path.IsEmpty())
370         {
371                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
372                 delete __pMoveIndexList;
373                 __pMoveIndexList = null;
374                 return ;
375         }
376
377         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
378         {
379                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
380                 delete __pMoveIndexList;
381                 __pMoveIndexList = null;
382                 return ;
383         }
384
385         delete __pFileMove;
386         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
387         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
388         if (__fileActionMode == FILE_ACTION_COPY)
389         {
390                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
391                 __pFileMove->SetCopy();
392         }
393         else
394         {
395                 __pFileMove->ClearCopy();
396         }
397         result r = __pFileMove->StartTimer();
398
399         if (IsFailed(r))
400         {
401                 delete __pFileMove;
402                 __pFileMove = null;
403                 __pNameEditField->SetText(__nameEditFieldPreText);
404                 __pNameEditField->HideKeypad();
405                 __pNameEditField->Draw();
406                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
407                 SceneManager* pSceneManager = SceneManager::GetInstance();
408                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
409         }
410         else
411         {
412                 AppLogDebug("MoveToContentFileList content in progress");
413                 _overlayMsg = true;
414                 __fileActionMode = FILE_ACTION_MOVE;
415         }
416 }
417
418 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
419 {
420         //Hide popup here..
421         __pProgressAnim->AnimationStop();
422         __pProgressAnim->SetShowState(false);
423         RemoveControl(__pProgressAnim);
424         _overlayMsg = false;
425         GetFooter()->SetEnabled(true);
426         SceneManager* pSceneManager = SceneManager::GetInstance();
427         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
428 }
429
430 void
431 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
432 {
433         AppLogDebug("ENTER");
434         String path;
435         __nameEditFieldText = __pNameEditField->GetText();
436
437         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
438         {
439                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
440                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
441                 path = pAlbumInfo->GetDirectory(0);
442         }
443
444         switch (actionId)
445         {
446         case IDA_BUTTON_CREATE_NAME_SAVE:
447         {
448                 __pNameEditField->SetEnabled(false);
449
450                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
451                 {
452                         OnCreateAlbum();
453                 }
454                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
455                 {
456                         String albumName = __pNameEditField->GetText();
457                         if (__originalText.Equals(albumName , true))
458                         {
459                                 SceneManager* pSceneManager = SceneManager::GetInstance();
460                                 pSceneManager->GoBackward(BackwardSceneTransition());
461                         }
462                         else
463                         {
464                                 OnRenameAlbum(path);
465                         }
466                 }
467                 break;
468         }
469
470         default:
471                 break;
472         }
473         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
474 }
475
476 void
477 AlbumNameEditorForm::OnFormBackRequested(Form& source)
478 {
479         AppLogDebug("ENTER");
480         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
481         {
482                 SceneManager* pSceneManager = SceneManager::GetInstance();
483                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
484         }
485         else
486         {
487                 SceneManager* pSceneManager = SceneManager::GetInstance();
488                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
489         }
490         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
491 }
492
493 void
494 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
495                 const SceneId& currentSceneId, IList* pArgs)
496 {
497         AppLogDebug("ENTER");
498         __pPresentationModel = AlbumListPresentationModel::GetInstance();
499         __previousSceneId = previousSceneId;
500
501         __pNameEditField->SetEnabled(true);
502         __pPresentationModel->AddContentEventListener(this);
503
504         if (pArgs != null)
505         {
506                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
507                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
508                 {
509                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
510                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
511                 }
512                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
513                 {
514                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
515                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
516                 }
517                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
518         }
519
520         if (pArgs != null)
521         {
522                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
523                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
524                 {
525                         AppLogDebug("Rash: FILE_MOVE_ACTION");
526                         __fileActionMode = FILE_ACTION_MOVE;
527                 }
528                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
529                 {
530                         AppLogDebug("Rash: FILE_COPY_ACTION");
531                         __fileActionMode = FILE_ACTION_COPY;
532                 }
533                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
534         }
535
536         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
537         {
538                 if (pArgs != null)
539                 {
540                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
541                         if (pEnum->MoveNext() == E_SUCCESS)
542                         {
543                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
544                                 if (index != null)
545                                 {
546                                         __folderIndex = index->ToInt();
547                                 }
548                         }
549                         delete pEnum;
550                         delete pArgs;
551                 }
552         }
553
554         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
555                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
556                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
557                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
558         {
559                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
560                 {
561                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
562                 }
563                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
564                 {
565                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
566                 }
567
568                 __callerSceneId = previousSceneId;
569         }
570         else
571         {
572                 __callerSceneId = EMPTY_SPACE;
573         }
574
575         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
576         {
577                 __nameEditFieldText = EMPTY_SPACE;
578                 __nameEditFieldPreText = EMPTY_SPACE;
579                 __pNameEditField->SetText(__nameEditFieldText);
580                 __nameEditFieldTempText = __nameEditFieldText;
581                 __pNameEditField->ShowKeypad();
582                 __pNameEditField->SetFocus();
583
584                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
585                 GetFooter()->SetItemEnabled(0, false);
586                 GetFooter()->Invalidate(true);
587         }
588         else
589         {
590                 int byteCount = 0;
591                 Utf8Encoding utf8;
592                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
593                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
594
595                 String strName = pAlbumInfo->GetAlbumName();
596                 __nameEditFieldText = strName;
597                 __nameEditFieldPreText = strName;
598                 __pNameEditField->SetText(__nameEditFieldText);
599                 __nameEditFieldTempText = __nameEditFieldText;
600                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
601                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
602                 __pNameEditField->ShowKeypad();
603                 __pNameEditField->SetFocus();
604                 __originalText = __pNameEditField->GetText();
605                 utf8.GetByteCount(__nameEditFieldText, byteCount);
606                 __textLength = byteCount;
607                 GetFooter()->SetItemEnabled(0, true);
608                 GetFooter()->Invalidate(true);
609         }
610
611         if (pArgs != NULL)
612         {
613                 __pMoveIndexList = pArgs;
614         }
615
616         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
617 }
618
619 void
620 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
621                 const SceneId& nextSceneId)
622 {
623         AppLogDebug("ENTER");
624         __pPresentationModel->RemoveContentEventListener(*this);
625         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
626 }
627
628 void
629 AlbumNameEditorForm::OnContentUpdated(void)
630 {
631         AppLogDebug("ENTER");
632
633         if ( __mountState == false )
634         {
635                 SceneManager* pSceneManager = SceneManager::GetInstance();
636                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
637                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
638         }
639         else
640         {
641                 __mountState = false;
642         }
643 }
644
645 void
646 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
647 {
648         AppLogDebug("ENTER");
649
650         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
651         {
652                 if ( __pFileMove && __pFileMove->IsStarted() )
653                 {
654                         __pFileMove->Cancel();
655                         delete __pFileMove;
656                         __pFileMove = null;
657                 }
658                 __mountState = false;
659                 SceneManager* pSceneManager = SceneManager::GetInstance();
660                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
661                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
662         }
663         else
664         {
665                 __mountState = true;
666         }
667         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
668 }
669
670 void
671 AlbumNameEditorForm::CreateMessage(String& str)
672 {
673         if (__pMessageBox == null)
674         {
675                 __pMessageBox = new(std::nothrow) MessageBox;
676
677                 if (__pMessageBox != null)
678                 {
679                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
680                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
681
682                         delete __pMessageBox;
683                         __pMessageBox = null;
684                         __modalMsgBoxResult = 0;
685                 }
686         }
687 }