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