21 #include <glxtracer.h> |
21 #include <glxtracer.h> |
22 #include <glxlog.h> |
22 #include <glxlog.h> |
23 |
23 |
24 #include <f32file.h> |
24 #include <f32file.h> |
25 #include <caf/manager.h> |
25 #include <caf/manager.h> |
|
26 #include <caf/content.h> |
26 #include <driveinfo.h> |
27 #include <driveinfo.h> |
27 #include <coeutils.h> |
28 #include <coeutils.h> |
28 |
29 |
29 _LIT( KPrivateFolder, "\\Private\\" ); |
30 _LIT( KPrivateFolder, "\\Private\\" ); |
30 _LIT( KGifFileExt, ".gif" ); |
31 _LIT( KGifFileMime, "image/gif" ); |
31 _LIT( KMbmFileExt, ".mbm"); |
32 _LIT( KMbmFileExt, "image/x-epoc-mbm"); |
32 _LIT( KTempGifFilePath, "?:\\data\\images\\200104E7.gif" ); |
33 _LIT( KTempFilePath, "?:\\data\\images\\" ); |
33 _LIT( KTempMbmFilePath, "?:\\data\\images\\200104E7.mbm" ); |
|
34 |
34 |
35 EXPORT_C CGlxImageViewerManager* CGlxImageViewerManager::InstanceL() |
35 EXPORT_C CGlxImageViewerManager* CGlxImageViewerManager::InstanceL() |
36 { |
36 { |
37 TRACER("CGlxImageViewerManager::InstanceL()"); |
37 TRACER("CGlxImageViewerManager::InstanceL()"); |
38 return CGlxSingletonStore::InstanceL(&NewL); |
38 return CGlxSingletonStore::InstanceL(&NewL); |
118 } |
118 } |
119 if (aFileName.Length() == 0) |
119 if (aFileName.Length() == 0) |
120 { |
120 { |
121 User::Leave(KErrNotSupported); |
121 User::Leave(KErrNotSupported); |
122 } |
122 } |
123 |
123 iImageUri = aFileName.AllocL(); |
124 iImageUri = aFileName.AllocL(); |
|
125 } |
124 } |
126 |
125 |
127 // --------------------------------------------------------------------------- |
126 // --------------------------------------------------------------------------- |
128 // Reset |
127 // Reset |
129 // --------------------------------------------------------------------------- |
128 // --------------------------------------------------------------------------- |
174 { |
173 { |
175 // File is in private folder; duplicate file handle |
174 // File is in private folder; duplicate file handle |
176 iFile = new (ELeave) RFile64; |
175 iFile = new (ELeave) RFile64; |
177 User::LeaveIfError(iFile->Duplicate(aFileHandle)); |
176 User::LeaveIfError(iFile->Duplicate(aFileHandle)); |
178 iIsPrivate = ETrue; |
177 iIsPrivate = ETrue; |
|
178 |
|
179 // Better to use contentaccess as we need to deal with DRM files |
|
180 TBuf<KMaxName> mimeBuf; |
|
181 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( |
|
182 *iFile); |
|
183 TInt err(content->GetStringAttribute(ContentAccess::EMimeType, |
|
184 mimeBuf)); |
|
185 CleanupStack::PopAndDestroy(content); |
|
186 |
179 // Gif / MBM file from private path, hence make a local copy. |
187 // Gif / MBM file from private path, hence make a local copy. |
180 if (parse.Ext().Compare(KGifFileExt) == 0 || parse.Ext().Compare( |
188 if (mimeBuf.Compare(KGifFileMime) == 0 |
181 KMbmFileExt) == 0) |
189 || mimeBuf.Compare(KMbmFileExt) == 0) |
182 { |
190 { |
183 TFileName ramFilePath; |
191 TFileName ramFilePath; |
184 if (parse.Ext().Compare(KGifFileExt) == 0) |
192 ramFilePath.Copy(KTempFilePath); |
185 { |
193 ramFilePath.Append(parse.NameAndExt()); |
186 ramFilePath.Copy(KTempGifFilePath); |
194 |
187 } |
|
188 else |
|
189 { |
|
190 ramFilePath.Copy(KTempMbmFilePath); |
|
191 } |
|
192 TChar drive; |
195 TChar drive; |
193 User::LeaveIfError(DriveInfo::GetDefaultDrive( |
196 User::LeaveIfError(DriveInfo::GetDefaultDrive( |
194 DriveInfo::EDefaultRam, drive)); |
197 DriveInfo::EDefaultRam, drive)); |
195 ramFilePath[0] = drive; |
198 ramFilePath[0] = drive; |
196 ConeUtils::EnsurePathExistsL(ramFilePath); |
199 ConeUtils::EnsurePathExistsL(ramFilePath); |
197 if (!iManager) |
200 if (!iManager) |
198 { |
201 { |
199 iManager = ContentAccess::CManager::NewL(); |
202 iManager = ContentAccess::CManager::NewL(); |
200 } |
203 } |
201 iManager->CopyFile(*iFile, ramFilePath); |
204 iManager->CopyFile(*iFile, ramFilePath); |
202 filePath.Copy(ramFilePath); |
205 filePath.Copy(ramFilePath); |
203 iIsPrivateGif = ETrue; |
206 iIsPrivateGif = ETrue; |
204 } |
207 } |