Arrange code
[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*
55 FileUpdateTimer::TimerStart(void)
56 {
57         if (_actionId == FILE_ACTION_DELETE)
58         {
59                 return __pFileUpdateManager->GetContentIdListAtIndexN(*__pUpdateIndexList);
60         }
61         else
62         {
63                 return __pUpdateIndexList;
64         }
65 }
66
67 result
68 FileUpdateTimer::TimerExpired(const Object* contentId)
69 {
70         if (_actionId == FILE_ACTION_DELETE)
71         {
72                 return __pFileUpdateManager->DeleteContentFile(*(static_cast<const ContentId*>(contentId)));
73         }
74         else
75         {
76                 result r = E_SUCCESS;
77                 const Integer* pIndex = static_cast<const Integer*>(contentId);
78                 if (pIndex != null)
79                 {
80                     r = __pFileUpdateManager->RotateImage(pIndex->ToInt(), __rotateMode);
81                     if (r == E_SUCCESS)
82                     {
83                         __pFileUpdateManager->RequestThumbnail(pIndex->ToInt()); // do not request thumbnail for video files
84                     }
85                     else
86                     {
87                         r = E_SUCCESS;    // to skip if file is not rotated, the processing bar should move,rotate next file
88                     }
89                 }
90                 return r;
91         }
92 }