//
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
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;
FileMoveTimer::FileMoveTimer(String& destDirectory, IList* list, FileListPresentationModel* presentationModel,
IFileOpInvalidateListener* pInvalidate, bool isCopyOperation)
- : GlTimerBase(pInvalidate, FILE_MOVE_ACTION)
+ : GlTimerBase(pInvalidate, FILE_ACTION_MOVE)
, __pMoveIndexList(list)
, __moveToDir(destDirectory)
+ , __isCopyOperation(false)
, __pPresentationModel(presentationModel)
+ , __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;
+ AppLogDebug("EXIT");
}
-IList * FileMoveTimer::TimerStart(void)
+IList *
+FileMoveTimer::TimerStart(void)
{
AppLogDebug("ENTER");
if (&__moveToDir == null || __moveToDir.IsEmpty())
AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
return null;
}
- if(__isCopyOperation == true)
- {
- SetActionMode(FILE_COPY_ACTION);
- }
+
if (__pMoveIndexList->GetCount() > 0)
{
+ __pContentManager = new (std::nothrow) ContentManager();
+ __pContentManager->Construct();
+ if (__isCopyOperation == true)
+ {
+ SetActionMode(FILE_ACTION_COPY);
+ }
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()));
- return __pPresentationModel->GetContentIdListN(*__pMoveIndexList);
+ IList* pCntIdList = __pPresentationModel->GetContentIdListAtIndexN(*__pMoveIndexList);
+ return pCntIdList;
}
else
{
}
}
-result FileMoveTimer::TimerExpired(const ContentId& contentId)
+result
+FileMoveTimer::TimerExpired(const Object* contentId)
+{
+ AppLogDebug("ENTER");
+ const ContentId* cntId = static_cast<const ContentId*>(contentId);
+ if(cntId == null)
+ {
+ return E_FAILURE;
+ }
+ ContentInfo* cntInfo = __pContentManager->GetContentInfoN(*cntId);
+ if (cntInfo)
+ {
+ String filePath = cntInfo->GetContentPath();
+ delete cntInfo;
+ result r = __pPresentationModel->MoveToContentFile(filePath, __moveToDir, __isCopyOperation);
+ if (!IsFailed(r))
+ {
+ if (__isCopyOperation == false)
+ {
+ //For Move operation, add the directory being moved from for scanning
+ String dirPath;
+ int index =0;
+ result r = filePath.LastIndexOf(DIRECTORY_SEPARATOR, filePath.GetLength() - 1, index);
+ TryReturn(r == E_SUCCESS, false, "[%s] Unable to get Dirpath", GetErrorMessage(r));
+ filePath.SubString(0, index, dirPath);
+ if(!__scanDirMap.ContainsKey(dirPath))
+ {
+ __scanDirMap.Add(new String(dirPath), new Integer(0));
+ }
+ }
+ if (!__scanDirMap.ContainsKey(__moveToDir))
+ {
+ __scanDirMap.Add(new String(__moveToDir), new Integer(0));
+ }
+ }
+ return r;
+ }
+ return E_FAILURE;
+}
+
+result
+FileMoveTimer::ScanDirectories(void)
{
AppLogDebug("ENTER");
- return __pPresentationModel->MoveToContentFile(contentId, __moveToDir, __isCopyOperation);
+ RequestId reqId;
+ result r = E_FAILURE;
+ if (__scanDirMap.GetCount() > 0)
+ {
+ AppLogDebug("Print AlbumScanMoveToDirPath 2(%d)", __scanDirMap.GetCount());
+ IMapEnumerator* pMapEnum = __scanDirMap.GetMapEnumeratorN();
+ String* pKey = null;
+ while (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ pKey = static_cast< String* > (pMapEnum->GetKey());
+ r = ContentManager::ScanDirectory(*(pKey), true, null, reqId);
+ }
+ __scanDirMap.RemoveAll();
+ delete pMapEnum;
+ }
+ AppLogDebug("EXIT(%s)", GetErrorMessage(r));
+ return r;
}
-void FileMoveTimer::TimerCancel(int, enum FileActionCancelRes res)
+void
+FileMoveTimer::TimerCancel(int, enum FileActionCancelRes res)
{
AppLogDebug("ENTER");
- if (res == CANCEL_USER)
+ DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+ if (res == CANCEL_USER || (res == CANCEL_SYS_ERROR && GetMovedCount() > 0) )
{
String albumName = __pPresentationModel->ConvertToAlbumName(__moveToDir);
pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
}
}
+ else if (res == CANCEL_SYS_ERROR && GetMovedCount() == 0)
+ {
+ if (__isCopyOperation == true)
+ {
+ MessageBox messageBox;
+ messageBox.Construct(L"", L"Unable to copy files.",
+ MSGBOX_STYLE_NONE, 3000);
+ int modalResult;
+ messageBox.ShowAndWait(modalResult);
+ }
+ }
AppLogDebug("EXIt");
}
-void FileMoveTimer::TimerComplete(int, enum FileActionCompleteRes res)
+int
+FileMoveTimer::GetDirScanCount()
+{
+ AppLogDebug("ENTER");
+ IMapEnumerator* pMapEnum = __scanDirMap.GetMapEnumeratorN();
+ String* pKey = null;
+ while (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ pKey = static_cast< String* > (pMapEnum->GetKey());
+ if (File::IsFileExist(*pKey) == false)
+ {
+ __scanDirMap.Remove(*pKey);
+ }
+ }
+ delete pMapEnum;
+ return __scanDirMap.GetCount();
+}
+
+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)
AppLogDebug("EXIt");
}
-void FileMoveTimer::SetCopy()
+void
+FileMoveTimer::SetCopy(void)
{
__isCopyOperation = true;
}
-void FileMoveTimer::ClearCopy()
+void
+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");
+}