2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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
8 // http://floralicense.org/license/
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.
18 * @file: MfFolderEntryPresentationModel.h
19 * @brief: This model is responsible for getting the details of any Directory/File entries in the
20 * file system. Constructs the structure which contains basic information of these entries.
21 * Acts as Content browser for any given file path or directory path.
24 #ifndef _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_
25 #define _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_
30 #include <FSysEnvironment.h>
34 #include "MfBasePresentationModel.h"
35 #include "MfCacheManager.h"
36 #include "MfDirectoryEntry.h"
37 #include "MfIFileEventNotification.h"
38 #include "MfIListViewStateChangeListener.h"
39 #include "MfThumbnailManager.h"
42 class FolderEntryPresentationModel;
44 class IFolderEntryProviderListener
47 virtual ~IFolderEntryProviderListener(void);
49 //! IFolderEntryProviderListener
50 /*! A public virtual member function of IFolderEntryProviderListener returning a pointer to the FolderEntryPresentationModel.
51 * @fn GetFolderEntryPresentationModel(void)
52 * @brief Used to get the pointer to the FileListPresentationModel Class.
53 * @param No parameters taken.
54 * @return [FolderEntryPresentationModel*] A pointer to the FolderEntryPresentationModel model.
56 virtual FolderEntryPresentationModel* GetFolderEntryPresentationModel(void) = 0;
59 class FolderEntryPresentationModel
60 : public BasePresentationModel
63 //!This is the constructor for the class
65 * @fn FileListPresentationModel()
66 * @param Takes no parameters
67 * @return No value returned
69 FolderEntryPresentationModel(void);
71 //!This is the Destructor for the class
72 /*!@fn ~FileListPresentationModel()
73 * @param Takes no parameters
74 * @return No value returned
76 virtual ~FolderEntryPresentationModel(void);
78 //!This is the Construct method for the class in which memory will be allocated for member variables
80 * @param Takes no parameters
81 * @return result value
83 result Construct(void);
85 /*!@fn UpdateEntryCount()
86 * @params [string, int, int] filepath for which structure is constructed,
87 * currentDirectoryCount which will be updated with number of directories present in the given filepath
88 * currentFileCount which will be updated with number of files present in the given filepath
89 * Returns no parameters
91 void GetFolderEntryCount(const Tizen::Base::String& filePath, int& currentDirectoryCount, int& currentFileCount);
93 void GetSortFolderEntryCount(int& currentDirectoryCount, int& currentFileCount);
94 /*!@fn GetDirectoryEntryList()
95 * @param Takes no parameters
96 * @return[ArrayList] Returns an arraylist containing the directory entries
98 Tizen::Base::Collection::ArrayList* GetFolderEntryList(void);
100 /*!@fnGetSourceForm(void)
101 * @brief Used to get the parent form which invoked FolderEntryPesentationModel.
102 * @params No Parameters taken
103 * @return [CreateItemSource], source form which invoked FolderEntryPesentationModel
105 CreateItemSource GetSourceForm(void);
107 /*!@fn InitThumbnailManager
108 * This function is a public member of this model and called by views for generating thumbnails
109 * @param taken integer value index as a parameter for of the list view item for which it is suppose to genetrate thumbnail.
112 result InitThumbnailManager(void);
113 //result InitThumbnailManager(int iItemIndex);
116 /*!@fn void setFileEventListener(IFileEventNotification *pIFileEventNotification,Tizen::Base::String& currentFilePath)
117 * used to set listeners for the respective view if some file addition or delete activity take place
118 * @param Takes filenotification listener and path
119 * Returns no parameters
121 void SetFileEventListener(IFolderEntryEventListener* pIFileEventNotification);
123 /*!@fn SetFolderEntryPath()
124 * @param Takes a string as a parameter. This is the filepath from which structure is constructed.
125 * Returns no parameters
127 void SetFolderEntryPath(const Tizen::Base::String& filePath);
129 /*!@fn AddFolderEntryList()
130 * @param string filepath: new path that has to be added to the directory entry list
131 * @param int index: index where the list has to be added
132 * Returns no parameters
134 void AddFolderEntryList(const Tizen::Base::String& filePath, int index);
136 int GetDirectoryTreeIndex(const Tizen::Base::String& filePath, int index);
138 /*!@fn RemoveFolderEntryList()
139 * @param string filepath: path of directories that has to be removed from the directory entry list
140 * @param int index: index where the list has to be added
141 * Returns no parameters
143 void RemoveFolderEntryList(int index);
145 /*!@fn void SetType(FileType currentType)
146 * used to set the type of file
147 * @param FileType enum
148 * Returns no parameters
150 void SetFolderEntryType(FileType currentType);
152 void SetViewType(AppControlView currentView);
156 * @brief: This method determines whether the directory entries have to be sorted or not
158 * @return No Return Value
160 void SetSortEnabled(bool enableFlag);
162 /*!@fn SetSourceForm(CreateItemSource currentSource)
163 * @brief Used to set the parent for which the FolderEntryPesentationModel is invoked.
164 * @params[CreateItemSource], source form which invoked FolderEntryPesentationModel
165 * @return No Return Value
167 void SetSourceForm(CreateItemSource currentSource);
170 * used to sort all the entries which are present in __pFileEntries arraylist
171 * @param Takes no parameters
172 * Returns no parameters
174 void SortFolderEntries(void);
176 /*@fn StartThumbnailRequest
177 * This function requests thumbnailmanager to get the thumbnail for a file.
178 *Takes index as an argument, this is the index of the file in the data-stucture maintained by the presentation model.
179 * Returns result value. Result of the StartThumbnailRequest function call
181 result StartThumbnailRequest(int iReqIndex = -1);
183 result SetListUpdateEventListener(IListViewStateChangeListener* pListener);
185 /*@fn StopThumbnailManager
186 * This function send request to thumbnailmanager to stops processing further thumbnail request.
188 * Returns result value
190 result StopThumbnailManager(bool bForceStop=false);
192 void RefreshFolderEntries(void);
195 * It executes when some fileEvent Occured
196 * param long event, string refernce and event id
197 * @return No Return values
199 virtual void OnFileEventOccured(unsigned long events, const Tizen::Base::String& path, unsigned int eventId);
201 /*@fn OnThumbnailResponseReceived
202 * This function receives thumbnail image received from thumbnailmanager.
203 * Takes pointer to the bitmap and index of the item for which bitmap is received as argument
204 * Returns result value
206 result OnThumbnailResponseReceived(Tizen::Graphics::Bitmap* pThumb, int Index);
208 /*@fn OnThumbnailResponseFailed
209 * This function is the callback of the thumbnail loading failed
210 * Takes index of the item for which bitmap is generation failed as an argument
211 * Returns result value
213 result OnThumbnailResponseFailed(int Index = -1);
214 void SetCurrentReqId(int currentRequestId);
215 int GetCurrentReqId(void);
217 void CreateStack(void);
218 void CreateTraversalTree(void);
219 int GetDeviceListCount(void);
221 /*@fn FileListPresentationModel()
222 * Copy Constructor for the FileListPresentationModel class
223 * Takes FileListPresentationModel as a parameter
224 * Returns no parameters
226 FolderEntryPresentationModel(const FolderEntryPresentationModel& content);
229 * Overloaded assignment operator for FileListPresentationModel class
230 * Takes FileListPresentationModel as a parameter
231 * Returns FileListPresentationModel as a return value
233 FolderEntryPresentationModel& operator =(const FolderEntryPresentationModel& source);
236 * Responsible for creating the entries in __pFileEntries.
238 void CreateFolderEntryList(const Tizen::Base::String& directoryName, int index = 0);
241 *This method is used to get the next available position in the arraylist of the directory entry during Swap operation.
242 * \param pList an arraylist which contains all the DirectoryStructure entries of the given path
243 * @return Returns the next available position where swapping can be done
245 int GetSwapIndex(void);
248 * Responsible for constructing all the entries in the given path
250 result MakeFolderEntryList(const Tizen::Base::String& directoryName, int index = 0);
253 * This method is used to swap two DirectoryStructure entries. This will be useful while sorting the elements of any file entry list.
254 * \param source a DirectoryStructure variable which contains the first object.
255 * \param destination a DirectoryStructure variable which contains the second object.
256 * @return No Return values
258 void SwapFolderEntries(DirectoryEntry& source, DirectoryEntry& destination);
261 * It Updates the folder enteries on occuring of file event
262 * param long events and one string refernce
263 * @return No Return values
265 void UpdateFileListEnteries(unsigned long events, const Tizen::Base::String& path);
266 void GetDeviceList(Tizen::Base::Collection::ArrayList* pDeviceList);
270 int __currentRequestId;
274 bool __ThumbnailRequestInProgress;
276 AppControlView __currentViewType;
277 CreateItemSource __sourceForm;
278 FileType __entryType;
280 Tizen::Base::Collection::ArrayList* __pFolderEntries;
281 Tizen::Base::String __currentFilePath;
282 Tizen::Io::FileEventManager* __pFileEventManager;
284 static IFolderEntryEventListener* __pFolderEntryEventListener;
285 ThumbnailManager* __pThumbnailManager;
286 Tizen::Base::Collection::Stack* __pFolderEntryStack;
287 CacheManager* __pCacheManager;
288 int __deviceListCount;
291 #endif // _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_