Fix for 54030, 54776, 54585
authorsanthosh <santhosh.ic@samsung.com>
Wed, 9 Oct 2013 10:41:10 +0000 (16:11 +0530)
committersanthosh <santhosh.ic@samsung.com>
Wed, 9 Oct 2013 10:41:10 +0000 (16:11 +0530)
Change-Id: Ie89fc4e050cc4b428469f8594b18bf19e76b5002
Signed-off-by: santhosh <santhosh.ic@samsung.com>
inc/GlFileMoveTimer.h
inc/GlFileUpdateTimer.h
inc/GlTimerBase.h
src/GlAlbumListEditorForm.cpp
src/GlAlbumListPresentationModel.cpp
src/GlAlbumNameEditorForm.cpp
src/GlFileListEditorForm.cpp
src/GlFileListPresentationModel.cpp
src/GlFileMoveTimer.cpp
src/GlFileUpdateTimer.cpp
src/GlTimerBase.cpp

index 041bb7a..b7e1dd1 100644 (file)
@@ -45,6 +45,7 @@ private:
        virtual void TimerComplete(int, enum FileActionCompleteRes res);
        result ScanDirectories(void);
        virtual int GetDirScanCount() const;
+       void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
 
 private :
        Tizen::Base::Collection::IList* __pMoveIndexList;
index dee3461..37b52c0 100644 (file)
@@ -37,10 +37,11 @@ public:
 private:
        virtual Tizen::Base::Collection::IList * TimerStart(void);
        virtual result TimerExpired(const Tizen::Base::Object* contentId);
-       virtual void TimerCancel(int, enum FileActionCancelRes res) {}
-       virtual void TimerComplete(int, enum FileActionCompleteRes res) {}
        virtual result ScanDirectories(void);
        virtual int GetDirScanCount() const;
+       void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
+       virtual void TimerCancel(int, enum FileActionCancelRes res);
+       virtual void TimerComplete(int, enum FileActionCompleteRes res);
 
 private :
        Tizen::Base::Collection::IList* __pUpdateIndexList;
index e7b1f13..aae331e 100644 (file)
 #define _GL_TIMER_BASE_H_
 
 #include <FUi.h>
+#include <FSystem.h>
 #include "GlFileOpInvalidateListener.h"
 #include "GlTimerScanDirListener.h"
+#include "GlTypes.h"
 
 class GlProgressBar;
 
@@ -33,6 +35,7 @@ class GlTimerBase
        , public Tizen::Base::Runtime::ITimerEventListener
        , public ITimerScanDirListener
        , public Tizen::Ui::IPropagatedKeyEventListener
+       , public Tizen::System::IDeviceEventListener
 {
 public:
 
@@ -66,6 +69,7 @@ protected:
        virtual result ScanDirectories(void) = 0;
        virtual int GetDirScanCount() const = 0;
        int GetMovedCount() const;
+       virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state) = 0;
 
 private:
        void OnOpComplete(enum FileActionCompleteRes);
index bcdb964..5b90aac 100644 (file)
@@ -73,6 +73,7 @@ AlbumListEditorForm::AlbumListEditorForm(void)
        , __isScanProgress(false)
 {
        AppLogDebug("ENTER");
+       _pProgressAnim = null;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -151,6 +152,7 @@ AlbumListEditorForm::ShowAnimation(void)
        _pProgressAnim = new (std::nothrow) ProgressAnimation;
        _pProgressAnim->Construct(rect);
        AddControl(_pProgressAnim);
+       SetControlAlwaysOnTop(*_pProgressAnim,true);
        _pProgressAnim->SetShowState(true);
        GetFooter()->SetEnabled(false);
        _pProgressAnim->AnimationStart();
@@ -1132,4 +1134,10 @@ AlbumListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tize
                __pEditorFolderIconList->SetItemChecked(index, true);
                __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
        }
+
+       if (_pProgressAnim != null)
+       {
+               _pProgressAnim->ChangeOrientation(Form::GetBounds());
+               _pProgressAnim->Invalidate(true);
+       }
 }
index 2543093..477d0a3 100644 (file)
@@ -1195,14 +1195,17 @@ void
 AlbumListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
 {
        AppLogDebug("ENTER");
-       IFormContentUpdateEventListener* pInterface = null;
-       IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
-       while (pEventEnum->MoveNext() == E_SUCCESS)
+       if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
        {
-               pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
-               pInterface->OnContentUpdated();
+               IFormContentUpdateEventListener* pInterface = null;
+               IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+               while (pEventEnum->MoveNext() == E_SUCCESS)
+               {
+                       pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+                       pInterface->OnContentUpdated();
+               }
+               delete pEventEnum;
        }
-       delete pEventEnum;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
index 7e897ff..fcbb168 100644 (file)
@@ -223,7 +223,14 @@ AlbumNameEditorForm::OnTextValueChanged(const Control& source)
                byteCountForInput = __pNameEditField->GetText();
                r = utf8.GetByteCount(byteCountForInput, inputLength);
 
-               if (inputLength  >= tempLength)
+               if ( inputLength  == tempLength )
+               {
+                       String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
+                       CreateMessage(msg);
+                       __pNameEditField->ShowKeypad();
+                       return;
+               }
+               else if (inputLength  > tempLength)
                {
                        String maxCharacterString;
                        String currentInputCharacter;
@@ -419,7 +426,6 @@ AlbumNameEditorForm::OnCreateAlbum(void)
        }
 
        delete __pFileMove;
-       GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
        __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
        if (__fileActionMode == FILE_ACTION_COPY)
        {
index a437f9f..39929ca 100644 (file)
@@ -761,11 +761,9 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
-                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
                                                        __pFileMove->SetCopy();
                                                }
 
@@ -806,11 +804,9 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
-                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
                                                        __pFileMove->SetCopy();
                                                }
                                                result r = __pFileMove->StartTimer();
index 4ce3add..048343e 100644 (file)
@@ -1029,9 +1029,25 @@ FileListPresentationModel::MoveToContentFile(const String& filePath, const Strin
                return E_SUCCESS;
        }
 
-       if (File::IsFileExist(destPath) == true)
+       while (File::IsFileExist(destPath) == true)
        {
-               File::Remove(destPath);
+               int index = 0;
+               r = destPath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
+               if (!IsFailed(r))
+               {
+                       if (index < 0)
+                       {
+                               return E_FAILURE;
+                       }
+                       else
+                       {
+                               destPath.Insert(Math::Rand()%10, index);
+                       }
+               }
+               else
+               {
+                       return E_FAILURE;
+               }
        }
 
        r = File::Copy(filePath, destPath, false);
index d46013e..d4d28fe 100644 (file)
@@ -33,6 +33,7 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Content;
 using namespace Tizen::Io;
+using namespace Tizen::System;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
@@ -47,12 +48,16 @@ FileMoveTimer::FileMoveTimer(String& destDirectory, IList* list, FileListPresent
        , __scanDirMap(SingleObjectDeleter)
        , __pContentManager(null)
 {
+       AppLogDebug("ENTER");
        __scanDirMap.Construct();
+       DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+       AppLogDebug("EXIT");
 }
 
 FileMoveTimer::~FileMoveTimer(void)
 {
        AppLogDebug("ENTER");
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
        ScanDirectories();
        delete __pMoveIndexList;
        delete __pContentManager;
@@ -85,7 +90,14 @@ FileMoveTimer::TimerStart(void)
                }
                if (File::IsFileExist(__moveToDir) == false)
                {
-                       Directory::Create(__moveToDir, true);
+                       result r = Directory::Create(__moveToDir, true);
+                       AppLog("The directory create result is 2(%s)", GetErrorMessage(r));
+
+                       if ( r == E_STORAGE_FULL)
+                       {
+                               return null;
+                       }
+
                }
                AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
                IList* pCntIdList = __pPresentationModel->GetContentIdListAtIndexN(*__pMoveIndexList);
@@ -164,6 +176,7 @@ void
 FileMoveTimer::TimerCancel(int, enum FileActionCancelRes res)
 {
        AppLogDebug("ENTER");
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
        if (res == CANCEL_USER || (res == CANCEL_SYS_ERROR && GetMovedCount() > 0) )
        {
                String albumName = __pPresentationModel->ConvertToAlbumName(__moveToDir);
@@ -205,6 +218,7 @@ void
 FileMoveTimer::TimerComplete(int, enum FileActionCompleteRes res)
 {
        AppLogDebug("ENTER");
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
        String albumName = __pPresentationModel->ConvertToAlbumName(__moveToDir);
 
        if (albumName != EMPTY_SPACE)
@@ -232,3 +246,26 @@ FileMoveTimer::ClearCopy(void)
 {
        __isCopyOperation = false;
 }
+
+
+void
+FileMoveTimer::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
+{
+       AppLogDebug("ENTER");
+       if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
+       {
+               String sdcPath = Environment::GetExternalStoragePath();
+               IMapEnumerator* pMapEnum = __scanDirMap.GetMapEnumeratorN();
+               String* pKey = null;
+               while (pMapEnum->MoveNext() == E_SUCCESS)
+               {
+                       pKey = static_cast< String* > (pMapEnum->GetKey());
+                       if (pKey->StartsWith(sdcPath, 0))
+                       {
+                               __scanDirMap.Remove(*pKey);
+                       }
+               }
+               delete pMapEnum;
+       }
+       AppLogDebug("EXIT");
+}
index 6261555..500e815 100644 (file)
@@ -27,6 +27,7 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Content;
 using namespace Tizen::Io;
+using namespace Tizen::System;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
@@ -44,28 +45,34 @@ FileUpdateTimer::FileUpdateTimer(Tizen::Base::Collection::IList* pDelList
        , __pContentManager(null)
 {
        __scanDirMap.Construct();
+       DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
 }
 
 FileUpdateTimer::~FileUpdateTimer(void)
 {
+       AppLogDebug("ENTER");
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
        ScanDirectories();
        delete __pUpdateIndexList;
        delete __pContentManager;
+       AppLogDebug("EXIT");
 }
 
 IList *
 FileUpdateTimer::TimerStart(void)
 {
+       AppLogDebug("ENTER");
        __pContentManager = new (std::nothrow) ContentManager();
        __pContentManager->Construct();
        IList* pCntIdList = __pFileUpdateManager->GetContentIdListAtIndexN(*__pUpdateIndexList);
+       AppLogDebug("EXIT");
        return pCntIdList;
 }
 
 result
 FileUpdateTimer::TimerExpired(const Object* contentId)
 {
-
+       AppLogDebug("ENTER");
        if (_actionId == FILE_ACTION_DELETE)
        {
                const ContentId* cntId = static_cast<const ContentId*>(contentId);
@@ -111,11 +118,12 @@ FileUpdateTimer::TimerExpired(const Object* contentId)
                    }
                    else
                    {
-                       return r;
+                       r = E_FAILURE;
                    }
                }
                return r;
        }
+       AppLogDebug("EXIT");
 }
 
 result
@@ -155,3 +163,36 @@ FileUpdateTimer::GetDirScanCount() const
        return __scanDirMap.GetCount();
 }
 
+void
+FileUpdateTimer::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
+{
+       AppLogDebug("ENTER");
+       if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED &&
+                       _actionId == FILE_ACTION_DELETE)
+       {
+               String sdcPath = Environment::GetExternalStoragePath();
+               IMapEnumerator* pMapEnum = __scanDirMap.GetMapEnumeratorN();
+               String* pKey = null;
+               while (pMapEnum->MoveNext() == E_SUCCESS)
+               {
+                       pKey = static_cast< String* > (pMapEnum->GetKey());
+                       if (pKey->StartsWith(sdcPath, 0))
+                       {
+                               __scanDirMap.Remove(*pKey);
+                       }
+               }
+               delete pMapEnum;
+       }
+       AppLogDebug("EXIT");
+}
+
+void
+FileUpdateTimer::TimerCancel(int, enum FileActionCancelRes res)
+{
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+}
+void
+FileUpdateTimer::TimerComplete(int, enum FileActionCompleteRes res)
+{
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+}
index e8f2beb..26db9e1 100644 (file)
@@ -67,7 +67,7 @@ GlTimerBase::~GlTimerBase(void)
                __pMoveProBar->HideFileProgressingPopup();
                delete __pMoveProBar;
        }
-       AppLogDebug("ENTER");
+       AppLogDebug("EXIT");
 }
 
 bool
@@ -101,8 +101,7 @@ GlTimerBase::CancelTimer(void)
        __moveTimer.Cancel();
        __pMoveProBar->HideFileProgressingPopup();
        int scanCount = GetDirScanCount();
-       if ( (scanCount > 0 && _actionId != FILE_ACTION_MOVE ) ||
-                       (scanCount > 1 && _actionId == FILE_ACTION_MOVE ))
+       if (scanCount > 0)
        {
                AlbumListPresentationModel::GetInstance()->AddTimerScanListener(this, scanCount);
                ScanDirectories();
@@ -171,8 +170,7 @@ GlTimerBase::OnTimerExpired(Timer& timer)
                                                __timerRes = CANCEL_SYS;
                                                __pMoveProBar->HideFileProgressingPopup();
                                                int scanCount = GetDirScanCount();
-                                               if ( (scanCount > 0 && _actionId != FILE_ACTION_MOVE ) ||
-                                                               (scanCount > 1 && _actionId == FILE_ACTION_MOVE ))
+                                               if ( scanCount > 0)
                                                {
                                                        AlbumListPresentationModel::GetInstance()->AddTimerScanListener(this, scanCount);
                                                        ScanDirectories();
@@ -209,7 +207,7 @@ GlTimerBase::OnTimerExpired(Timer& timer)
                        __moveTimer.Cancel();
                        __pMoveProBar->HideFileProgressingPopup();
                        int scanCount = GetDirScanCount();
-                       if (scanCount == 0 && _actionId == FILE_ACTION_ROTATE)
+                       if (scanCount == 0)
                        {
                                __moveToCount = 0;
                                __isStarted = false;
@@ -217,15 +215,11 @@ GlTimerBase::OnTimerExpired(Timer& timer)
                                OnOpComplete(COMPLETE_SUCCESS);
                                return;
                        }
-                       if ((scanCount > 0 && _actionId != FILE_ACTION_MOVE ) ||
-                                       (scanCount > 1 && _actionId == FILE_ACTION_MOVE ))
-                       {
-                               AlbumListPresentationModel::GetInstance()->AddTimerScanListener(this, scanCount);
-                               ScanDirectories();
-                               __pInvalidate->OnScanDirStart();
-                               FileListPresentationModel::GetInstance()->ShowAnimation();
-                               AlbumListPresentationModel::GetInstance()->ShowAnimation();
-                       }
+                       AlbumListPresentationModel::GetInstance()->AddTimerScanListener(this, scanCount);
+                       ScanDirectories();
+                       __pInvalidate->OnScanDirStart();
+                       FileListPresentationModel::GetInstance()->ShowAnimation();
+                       AlbumListPresentationModel::GetInstance()->ShowAnimation();
                        __isStarted = false;
                        __timerRes = TIMER_COMPLETE;
                        __moveToCount = 0;
@@ -341,8 +335,7 @@ GlTimerBase::Cancel(void)
                __isStarted = false;
 
                int scanCount = GetDirScanCount();
-               if ((scanCount > 0 && _actionId != FILE_ACTION_MOVE ) ||
-                               (scanCount > 1 && _actionId == FILE_ACTION_MOVE ))
+               if (scanCount > 0)
                {
                        AlbumListPresentationModel::GetInstance()->AddTimerScanListener(this, scanCount);
                        ScanDirectories();