photosgallery/controllers/imageviewer/src/glximageviewermanager.cpp
branchRCL_3
changeset 24 ea65f74e6de4
parent 19 420f6808bf21
equal deleted inserted replaced
23:b023a8d2866a 24:ea65f74e6de4
    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 <caf/content.h>
    27 #include <driveinfo.h>
    27 #include <driveinfo.h>
    28 #include <coeutils.h>
    28 #include <coeutils.h>
       
    29 #include <coemain.h>
    29 
    30 
    30 _LIT( KPrivateFolder, "\\Private\\" );
    31 _LIT( KPrivateFolder, "\\Private\\" );
    31 _LIT( KGifFileMime, "image/gif" );
    32 _LIT( KGifFileMime, "image/gif" );
    32 _LIT( KMbmFileExt, "image/x-epoc-mbm");
    33 _LIT( KMbmFileExt, "image/x-epoc-mbm");
    33 _LIT( KTempFilePath, "?:\\data\\images\\" );
    34 _LIT( KTempFilePath, "?:\\data\\images\\" );
   119     if (aFileName.Length() == 0)
   120     if (aFileName.Length() == 0)
   120         {
   121         {
   121         User::Leave(KErrNotSupported);    
   122         User::Leave(KErrNotSupported);    
   122         }
   123         }
   123     iImageUri = aFileName.AllocL();  
   124     iImageUri = aFileName.AllocL();  
       
   125     CreateImageDecoderL();
   124     }
   126     }
   125 
   127 
   126 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   127 // Reset
   129 // Reset
   128 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   134         {
   136         {
   135         iFile->Close();
   137         iFile->Close();
   136         }
   138         }
   137     delete iFile;
   139     delete iFile;
   138     iFile = NULL;
   140     iFile = NULL;
       
   141 
       
   142 	CloseImageDecoder();
   139 
   143 
   140     if (iIsPrivateGif)
   144     if (iIsPrivateGif)
   141         {
   145         {
   142         iManager->DeleteFile(iImageUri->Des());
   146         iManager->DeleteFile(iImageUri->Des());
   143         iIsPrivateGif = EFalse;
   147         iIsPrivateGif = EFalse;
   206             iIsPrivateGif = ETrue;
   210             iIsPrivateGif = ETrue;
   207             }
   211             }
   208         }
   212         }
   209     SetImageUriL( filePath );
   213     SetImageUriL( filePath );
   210     }
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // CloseImageDecoder
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C void CGlxImageViewerManager::CloseImageDecoder()
       
   221     {
       
   222     TRACER("void CGlxImageViewerManager::CloseImageDecoder()");
       
   223     if (iImageDecoder)
       
   224         {
       
   225         delete iImageDecoder;
       
   226         iImageDecoder = NULL;
       
   227         }
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // CreateImageDecoderL
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C void CGlxImageViewerManager::CreateImageDecoderL()
       
   235     {
       
   236     TRACER("void CGlxImageViewerManager::CreateImageDecoderL()");
       
   237 
       
   238     CloseImageDecoder();
       
   239 
       
   240     TInt err = KErrNone;
       
   241     if (IsPrivate())
       
   242         {
       
   243         if (&ImageFileHandle())
       
   244             {
       
   245             GLX_DEBUG1("CGlxImageViewerManager::CreateImageDecoderL() FH");
       
   246             TRAP(err, iImageDecoder = CImageDecoder::FileNewL(
       
   247                     ImageFileHandle(), ContentAccess::EPeek));
       
   248             }
       
   249         }
       
   250     else
       
   251         {
       
   252         if (ImageUri())
       
   253             {
       
   254             GLX_DEBUG1("CGlxImageViewerManager::CreateImageDecoderL() FN");
       
   255             TRAP(err, iImageDecoder = CImageDecoder::FileNewL(
       
   256                     CCoeEnv::Static()->FsSession(), ImageUri()->Des()));
       
   257             }
       
   258         }
       
   259 
       
   260     GLX_DEBUG2("CGlxImageViewerManager::CreateImageDecoderL() err(%d)", err);
       
   261     User::LeaveIfError(err);
       
   262     }