|
1 /* |
|
2 * Copyright (c) 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: Meta data video access |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMMMTPDPMETADATAVIDEOACCESS_H |
|
20 #define CMMMTPDPMETADATAVIDEOACCESS_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <s32file.h> // for CPermanentFileStore |
|
25 #include <d32dbms.h> |
|
26 |
|
27 /* |
|
28 * Mapping property code to db column name |
|
29 */ |
|
30 typedef struct |
|
31 { |
|
32 TMTPObjectPropertyCode iPropCode; |
|
33 const TDesC& iDbColumnName; |
|
34 } TColumnNameTable; |
|
35 |
|
36 class CMmMtpDpMetadataVideoAccess : public CBase |
|
37 { |
|
38 public: |
|
39 static CMmMtpDpMetadataVideoAccess* NewL( RFs& aRfs ); |
|
40 |
|
41 /** |
|
42 * Destructor |
|
43 */ |
|
44 ~CMmMtpDpMetadataVideoAccess(); |
|
45 |
|
46 /* |
|
47 * Called when the MTP session is initialised |
|
48 */ |
|
49 void OpenSessionL(); |
|
50 |
|
51 /* |
|
52 * Cleanup db and notify CFL |
|
53 */ |
|
54 void CloseSessionL(); |
|
55 |
|
56 /* |
|
57 * Set root for db to manipulate relevant ".db" file |
|
58 */ |
|
59 void SetStorageRootL( const TDesC& aStorageRoot ); |
|
60 |
|
61 /** |
|
62 * Adds Video info to Video DB |
|
63 * @param aFullFileName, full file name of Media file |
|
64 */ |
|
65 void AddVideoL( const TDesC& aFullFileName ); |
|
66 |
|
67 /* |
|
68 * Gets a piece of metadata from permanent store |
|
69 * @aPropCode |
|
70 * @aNewData, output param, store the value get from db |
|
71 * @aObjectMetaData, source to get properties |
|
72 */ |
|
73 void GetObjectMetadataValueL( const TUint16 aPropCode, |
|
74 MMTPType& aNewData, |
|
75 const CMTPObjectMetaData& aObjectMetaData ); |
|
76 |
|
77 /** |
|
78 * Set object property and updated object in DB according property code, |
|
79 * only for update, not for creation |
|
80 * @param aPropCode, property code of aObjectMetaData |
|
81 * @param aNewData, object property value which will be set into |
|
82 * aObjectMetaData |
|
83 * @param aObjectMetaData, owner of the property which should be |
|
84 * updated into database |
|
85 */ |
|
86 void SetObjectMetadataValueL( const TUint16 aPropCode, |
|
87 const MMTPType& aNewData, |
|
88 const CMTPObjectMetaData& aObjectMetaData ); |
|
89 |
|
90 /* |
|
91 * Rename the record acording to full file name |
|
92 * @aOldFileName, specify the object which need to be changed |
|
93 * @aNewFileName, specify the new name which will be changed into |
|
94 */ |
|
95 void RenameRecordL( const TDesC& aOldFileName, const TDesC& aNewFileName ); |
|
96 |
|
97 /** |
|
98 * Remove the file from DB |
|
99 * @param aFullFileName, the file to remove |
|
100 */ |
|
101 void DeleteRecordL( const TDesC& aFullFileName ); |
|
102 |
|
103 /** |
|
104 * Remove all records from DB |
|
105 */ |
|
106 void DeleteAllRecordsL(); // Removes all metadata from the database |
|
107 |
|
108 /** |
|
109 * set image specific properties specific to videos |
|
110 * @param aFullFileName, the fullFileName of object |
|
111 * @param aWidth, the width of an object in pixels to set |
|
112 * @parem aHeight, the height of an object in pixels to set |
|
113 */ |
|
114 void SetImageObjPropL( const TDesC& aFullFileName, |
|
115 const TUint32 aWidth, |
|
116 const TUint32 aHeight ); |
|
117 |
|
118 /** |
|
119 * get image specific properties specific to videos |
|
120 * @param aFullFileName, the fullFileName of object |
|
121 * @param aWidth, the width of an object in pixels to get |
|
122 * @parem aHeight, the height of an object in pixels to get |
|
123 */ |
|
124 void GetImageObjPropL( const TDesC& aFullFileName, |
|
125 TUint32& aWidth, |
|
126 TUint32& aHeight ); |
|
127 |
|
128 /** |
|
129 * Cleanup Database |
|
130 */ |
|
131 void CleanupDatabaseL(); |
|
132 |
|
133 private: |
|
134 |
|
135 enum TMtpDbState |
|
136 { |
|
137 ENoRecord, |
|
138 ERecordRead, |
|
139 ERecordWrite, |
|
140 EFailedWrite |
|
141 }; |
|
142 |
|
143 CMmMtpDpMetadataVideoAccess( RFs& aRfs ); |
|
144 void ConstructL(); |
|
145 |
|
146 TInt OpenDatabase(); |
|
147 void OpenDatabaseL(); |
|
148 void CreateDatabaseTablesL(); |
|
149 void CompactDbIfNecessaryL(); |
|
150 void CleanupDbIfNecessaryL(); |
|
151 |
|
152 void IdentifyDeletedFilesL(); |
|
153 |
|
154 HBufC* ReadLongTextL( const TDesC& aColumn); |
|
155 void WriteLongTextL( const TDesC& aColumn, const TDesC& aValue); |
|
156 |
|
157 void ExecuteQueryL( const TDesC& aSelectThese, |
|
158 const TDesC& aFromTable, |
|
159 const TDesC& aColumnToMatch = KNullDesC, |
|
160 const TDesC& aMatchCriteria = KNullDesC, |
|
161 const TBool aIfNot = EFalse, |
|
162 const TBool aNeedQuote = ETrue ); |
|
163 |
|
164 void SetRecordL( const TDesC& aFullFileName, TMtpDbState aState ); // Updates the iRecord to the selected file |
|
165 void SetMetadataL( const TUint16 aPropCode, const MMTPType& aNewData ); |
|
166 |
|
167 inline TBool IsDatabaseOpened() |
|
168 { |
|
169 return iDbOpened; |
|
170 } |
|
171 |
|
172 const TDesC& ColumnNameFromPropCodeL( const TUint16 aPropCode ); |
|
173 |
|
174 TBool FileExists( const TDesC& aFullFileName ); |
|
175 |
|
176 private: // Data |
|
177 |
|
178 RFs iRfs; |
|
179 |
|
180 CPermanentFileStore* iFileStore; |
|
181 TMtpDbState iDbState; |
|
182 TFileName iCurrentFileName; |
|
183 |
|
184 RDbs iDbsSession; |
|
185 RDbView iRecordSet; |
|
186 HBufC* iQueryText; |
|
187 CDbColSet* iColSet; |
|
188 RDbStoreDatabase iDatabase; |
|
189 TBool iDbOpened; |
|
190 TInt iRecordCount; // Used to compact the database every KMtpCompactInterval |
|
191 TInt iStoreNum; |
|
192 |
|
193 }; |
|
194 |
|
195 #endif // CMMMTPDPMETADATAVIDEOACCESS_H |