|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Thumbnail storage implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 30/07/2007 by Simon Brooks |
|
23 */ |
|
24 |
|
25 #ifndef GLXTNDATABASE_H |
|
26 #define GLXTNDATABASE_H |
|
27 |
|
28 // INCLUDES |
|
29 |
|
30 #include <e32base.h> |
|
31 #include <f32file.h> |
|
32 #include <driveinfo.h> |
|
33 #include "mglxtnstorage.h" |
|
34 #include "mglxtnvolumedatabaseobserver.h" |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // MACROS |
|
39 |
|
40 // DATA TYPES |
|
41 |
|
42 // FUNCTION PROTOTYPES |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 |
|
46 class CGlxtnVolumeDatabase; |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * Default implementation of thumbnail storage. |
|
52 * |
|
53 * @author Dan Rhodes |
|
54 * @ingroup glx_thumbnail_creator |
|
55 */ |
|
56 class CGlxtnThumbnailDatabase : public CBase, public MGlxtnThumbnailStorage, |
|
57 public MGlxtnVolumeDatabaseObserver |
|
58 { |
|
59 public: // Constructors and destructor |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * @param aDbFilename Filename (without path) for database. |
|
64 * @param aStorageObserver Observer of storage operations. |
|
65 */ |
|
66 IMPORT_C static CGlxtnThumbnailDatabase* NewL(const TDesC& aDbFilename, |
|
67 MGlxtnThumbnailStorageObserver* aStorageObserver = NULL); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CGlxtnThumbnailDatabase(); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 public: // Functions from MGlxtnThumbnailStorage |
|
77 void LoadThumbnailDataL(HBufC8*& aData, TGlxImageDataFormat& aFormat, |
|
78 const TGlxMediaId& aId, const CGlxtnFileInfo& aFileInfo, |
|
79 const TSize& aSize, TRequestStatus* aStatus); |
|
80 void SaveThumbnailDataL(const TDesC8& aData, |
|
81 TGlxImageDataFormat aFormat, const TGlxMediaId& aId, |
|
82 const CGlxtnFileInfo& aFileInfo, const TSize& aSize, |
|
83 TRequestStatus* aStatus); |
|
84 void DeleteThumbnailsL(const TGlxMediaId& aId, |
|
85 const CGlxtnFileInfo& aFileInfo, TRequestStatus* aStatus); |
|
86 void CleanupThumbnailsL(TRequestStatus* aStatus); |
|
87 void IsThumbnailAvailableL(const TGlxMediaId& aId, |
|
88 const CGlxtnFileInfo& aFileInfo, |
|
89 const TSize& aSize, TRequestStatus* aStatus); |
|
90 void StorageCancel(); |
|
91 void NotifyBackgroundError(const TGlxMediaId& aId, TInt aError); |
|
92 |
|
93 private: // From MGlxtnVolumeDatabaseObserver |
|
94 void HandleDatabaseError(TInt aError); |
|
95 void HandleThumbnailIdFromMediaIdL( |
|
96 const TGlxtnThumbnailId& aThumbId ); |
|
97 void HandleThumbnailIdFromFilenameL( |
|
98 const TGlxtnThumbnailId& aThumbId ); |
|
99 void HandleThumbnailIdStoredL(); |
|
100 void HandleThumbnail(TGlxImageDataFormat aFormat, HBufC8* aData); |
|
101 void HandleThumbnailStored(); |
|
102 void HandleMediaIdDeletedL(); |
|
103 void HandleThumbnailsDeletedL(); |
|
104 void HandleItemDeletedL(); |
|
105 void HandleAvailabilityChecked(TInt aResult); |
|
106 void HandleDatabaseCleanedL(); |
|
107 TInt DriveName(const TInt& aDefaultDrive, TDes& aDriveName); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * C++ default constructor. |
|
113 */ |
|
114 CGlxtnThumbnailDatabase(); |
|
115 |
|
116 /** |
|
117 * By default Symbian 2nd phase constructor is private. |
|
118 * @param aDbFilename Filename (without path) for database. |
|
119 * @param aStorageObserver Observer of storage operations. |
|
120 */ |
|
121 void ConstructL(const TDesC& aDbFilename, |
|
122 MGlxtnThumbnailStorageObserver* aStorageObserver); |
|
123 |
|
124 /** |
|
125 * Continue current operation after receiving the thumbnail ID. |
|
126 */ |
|
127 void DoHandleThumbnailIdL(); |
|
128 |
|
129 /** |
|
130 * Open a volume database on the specified drive. |
|
131 * @param aDrive String beginnning with drive letter and colon. |
|
132 */ |
|
133 CGlxtnVolumeDatabase* OpenDatabaseL(const TDesC& aDrive); |
|
134 |
|
135 CGlxtnVolumeDatabase* OpenDatabaseL(const DriveInfo::TDefaultDrives& aDrive); |
|
136 |
|
137 /** |
|
138 * Delete the volume database if the storage media has changed. |
|
139 * @param aDrive String beginnning with drive letter and colon. |
|
140 */ |
|
141 void DeleteDBIfStorageChangedL(TFileName aPath); |
|
142 |
|
143 /** |
|
144 * Delete the file at location aPath |
|
145 * @param aPath The location of the file to be deleted. |
|
146 */ |
|
147 void DeleteFile(const TDesC& aPath) ; |
|
148 |
|
149 /** |
|
150 * Recover from database file handling error |
|
151 */ |
|
152 void RecoverFromDatabaseError(); |
|
153 |
|
154 private: // Data |
|
155 enum TDatabaseOperation |
|
156 { |
|
157 ELoading, ESaving, EDeleting, ECleaning, ECheckingAvailable |
|
158 }; |
|
159 |
|
160 /** Pointer to a storage observer */ |
|
161 MGlxtnThumbnailStorageObserver* iStorageObserver; |
|
162 /** File server session */ |
|
163 RFs iFs; |
|
164 /** Path to the database files (excluding drive letter) */ |
|
165 TFileName iDatabasePath; |
|
166 /** Drive name of the phone memory drive */ |
|
167 TDriveName iInternalDrive; |
|
168 /** Array of open databases (one per volume) */ |
|
169 RPointerArray<CGlxtnVolumeDatabase> iDatabaseArray; |
|
170 /** Request status for asynchronous operation */ |
|
171 TRequestStatus* iClientStatus; |
|
172 /** Operation currently being carried out by the database */ |
|
173 TDatabaseOperation iCurrentOperation; |
|
174 /** Media ID for request */ |
|
175 TGlxMediaId iMediaId; |
|
176 /** URI for request (not owned) */ |
|
177 const CGlxtnFileInfo* iFileInfo; |
|
178 /** Thumbnail size for request */ |
|
179 TSize iSize; |
|
180 /** Data buffer for load request */ |
|
181 HBufC8** iLoadData; |
|
182 /** Data buffer for save request */ |
|
183 TPtrC8 iSaveData; |
|
184 /** Thumbnail format for load request */ |
|
185 TGlxImageDataFormat* iLoadFormat; |
|
186 /** Thumbnail format for save request */ |
|
187 TGlxImageDataFormat iSaveFormat; |
|
188 /** ID for thumbnail */ |
|
189 TGlxtnThumbnailId iThumbId; |
|
190 /** Index to count through iDatabaseArray */ |
|
191 TInt iDatabaseIndex; |
|
192 }; |
|
193 |
|
194 #endif // GLXTNDATABASE_H |
|
195 |
|
196 // End of File |