|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Delete helper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_MPX_DELETE_HELPER_H |
|
20 #define C_MPX_DELETE_HELPER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> |
|
24 #include <thumbnailmanager.h> |
|
25 #include <thumbnailmanagerobserver.h> |
|
26 #include <mpxcollectionobserver.h> |
|
27 #include <mpxharvesterutilityobserver.h> |
|
28 #include <mpxmessage2.h> |
|
29 #include <usbman.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MMPXCollectionUtility; |
|
33 class MMPXPlaybackUtility; |
|
34 class MMPXHarvesterUtility; |
|
35 class MMPXCHelperObserver; |
|
36 class CMPXCollectionPath; |
|
37 |
|
38 |
|
39 /** |
|
40 * Delete Helper |
|
41 * |
|
42 * @lib mpxcollectionhelper.lib |
|
43 * @since S60 3.0 |
|
44 */ |
|
45 NONSHARABLE_CLASS( CMPXDeleteHelper ) : public CActive, |
|
46 public MThumbnailManagerObserver |
|
47 { |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two-Phased Constructor |
|
52 * @param aCollectionUtility reference to a collection utility |
|
53 * @param aHarvesterUtility reference to a harvester utility |
|
54 * @param aObserver observer to callback upon completion of the operation |
|
55 * @return new instance of CMPXDeleteHelper |
|
56 */ |
|
57 static CMPXDeleteHelper* NewL(MMPXCollectionUtility& aCollectionUtility, |
|
58 MMPXHarvesterUtility& aHarvesterUtility, |
|
59 MMPXCHelperObserver& aObserver); |
|
60 |
|
61 /** |
|
62 * Virtual Destructor |
|
63 */ |
|
64 virtual ~CMPXDeleteHelper(); |
|
65 |
|
66 public: // New functions |
|
67 |
|
68 /** |
|
69 * Delete all items in a collection path |
|
70 * @param aPath, collection path to delete |
|
71 */ |
|
72 void DeleteL( CMPXCollectionPath& aPath ); |
|
73 |
|
74 /** |
|
75 * Handles any collection message callbacks from collection helper |
|
76 */ |
|
77 void HandleCollectionMessage(CMPXMessage* aMessage, TInt aErr); |
|
78 |
|
79 /** |
|
80 * Stop deleting |
|
81 * |
|
82 */ |
|
83 void Stop(); |
|
84 |
|
85 private: |
|
86 |
|
87 /** |
|
88 * From CActive |
|
89 * Handles an active object's request completion event |
|
90 */ |
|
91 void RunL(); |
|
92 |
|
93 /** |
|
94 * From CActive |
|
95 * Implements cancellation of an outstanding request. |
|
96 */ |
|
97 void DoCancel(); |
|
98 |
|
99 /** |
|
100 * Performs incremental delete operation |
|
101 */ |
|
102 void DoTaskStep(); |
|
103 |
|
104 /** |
|
105 * Performs incremental delete operation |
|
106 */ |
|
107 void DoTaskStepL(); |
|
108 |
|
109 /** |
|
110 * Completes delete operation request and notifies the client |
|
111 */ |
|
112 void CompleteDelete( TInt aErr ); |
|
113 |
|
114 /** |
|
115 * Finish the delete operation |
|
116 * @param aErr error |
|
117 */ |
|
118 void DoCompleteDeleteL( TInt aErr ); |
|
119 |
|
120 /** |
|
121 * Resets members to get ready for the next client request |
|
122 */ |
|
123 void Reset(); |
|
124 |
|
125 /** |
|
126 * Retrieves a list of file URIs associated with the path |
|
127 */ |
|
128 void RetrieveFileListL(); |
|
129 |
|
130 /** |
|
131 * Perfoms cleanup of all unused data before delete |
|
132 */ |
|
133 void StartDeleteL(); |
|
134 |
|
135 /** |
|
136 * Deletes one file from the file system then removes it from the |
|
137 * collection |
|
138 */ |
|
139 void DeleteL(); |
|
140 |
|
141 /** |
|
142 * Deletes the file from the file system and harvester's database |
|
143 * @return ETrue if the file has been deleted from the file system; |
|
144 * otherwise EFalse. |
|
145 */ |
|
146 TBool DeleteFileL(); |
|
147 |
|
148 /** |
|
149 * Connect to usbman. |
|
150 */ |
|
151 void ConnectUsbMan(); |
|
152 |
|
153 // MThumbnailManagerObserver for getting thumbnails |
|
154 void ThumbnailPreviewReady( |
|
155 MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
156 |
|
157 void ThumbnailReady( |
|
158 TInt aError, |
|
159 MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
160 |
|
161 private: |
|
162 |
|
163 /** |
|
164 * Constructor |
|
165 * @param aCollectionUtility reference to a collection utility |
|
166 * @param aHarvesterUtility reference to a harvester utility |
|
167 * @param aObserver observer to callback upon completion of the operation |
|
168 */ |
|
169 CMPXDeleteHelper(MMPXCollectionUtility& aCollectionUtility, |
|
170 MMPXHarvesterUtility& aHarvesterUtility, |
|
171 MMPXCHelperObserver& aObserver); |
|
172 |
|
173 /** |
|
174 * 2nd phase constructor |
|
175 */ |
|
176 void ConstructL(); |
|
177 |
|
178 private: |
|
179 |
|
180 /* |
|
181 * state for deleting one item |
|
182 */ |
|
183 enum TMPXDeleteState |
|
184 { |
|
185 EMPXIdle, |
|
186 EMPXInitDelete, |
|
187 EMPXPreparation, |
|
188 EMPXDelete |
|
189 }; |
|
190 |
|
191 private: // data |
|
192 MMPXCollectionUtility& iCollectionUtil; |
|
193 MMPXHarvesterUtility& iHarvester; |
|
194 MMPXCHelperObserver& iObserver; |
|
195 |
|
196 MMPXPlaybackUtility* iPbUtil; |
|
197 |
|
198 CMPXCollectionPath* iDeletePath; |
|
199 CDesCArray* iFiles; |
|
200 |
|
201 TBool iMoreToDo; |
|
202 TBool iHadInUse; |
|
203 TBool iCancelled; |
|
204 |
|
205 TMPXDeleteState iState; |
|
206 |
|
207 CMPXMessageArray* iMessageArray; |
|
208 TInt iItemsCount; |
|
209 TInt iRetrievedItemsCount; |
|
210 TInt iDeletePercent; |
|
211 TInt iDeleteIncFactor; |
|
212 TInt iDeleteCount; |
|
213 RFs iFs; // FsSession (owned) |
|
214 CThumbnailManager* iTNManager; |
|
215 RUsb iUsbMan; |
|
216 TBool iUsbManConnected; |
|
217 |
|
218 }; |
|
219 |
|
220 #endif // C_MPX_DELETE_HELPER_H |