58102763e2b99dd766b28dd1ecb3637ee5ae2e9e
[apps/osp/Gallery.git] / src / GlFileUpdateTimer.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                GlFileUpdateTimer.cpp
19  * @brief               This is the source file for FileUpdateTimer class.
20  */
21
22 #include "GlFileUpdateTimer.h"
23 #include "GlFileListPresentationModel.h"
24
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Base::Utility;
28 using namespace Tizen::Content;
29 using namespace Tizen::Io;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
33
34 FileUpdateTimer::FileUpdateTimer(Tizen::Base::Collection::IList* pDelList
35         , IContentFileUpdateManager* pFDM
36         , IFileOpInvalidateListener* invalidate
37         , FileActionMode actionId
38         , RotateMode rotateMode)
39         : GlTimerBase(invalidate, actionId)
40         , __pUpdateIndexList(pDelList)
41         , __pFileUpdateManager(pFDM)
42         , __rotateMode(rotateMode)
43 {
44 }
45
46 FileUpdateTimer::~FileUpdateTimer(void)
47 {
48         if (_actionId == FILE_ACTION_DELETE)
49         {
50                 delete __pUpdateIndexList;
51         }
52 }
53
54 IList * FileUpdateTimer::TimerStart(void)
55 {
56         if (_actionId == FILE_ACTION_DELETE)
57         {
58                 return __pFileUpdateManager->GetContentIdListAtIndexN(*__pUpdateIndexList);
59         }
60         else
61         {
62                 return __pUpdateIndexList;
63         }
64 }
65
66 result FileUpdateTimer::TimerExpired(const Object* contentId)
67 {
68         if (_actionId == FILE_ACTION_DELETE)
69         {
70                 return __pFileUpdateManager->DeleteContentFile(*(static_cast<const ContentId*>(contentId)));
71         }
72         else
73         {
74                 result r = E_SUCCESS;
75                 const Integer* pIndex = static_cast<const Integer*>(contentId);
76                 if (pIndex != null)
77                 {
78                     r = __pFileUpdateManager->RotateImage(pIndex->ToInt(), __rotateMode);
79                     if ( r == E_SUCCESS )
80                     {
81                         __pFileUpdateManager->RequestThumbnail(pIndex->ToInt()); // do not request thumbnail for video files
82                     }
83                     else
84                     {
85                         r = E_SUCCESS;    // to skip if file is not rotated, the processing bar should move,rotate next file
86                     }
87                 }
88                 return r;
89         }
90 }