photosgallery/viewframework/dataprovider/src/glxdrmgiftexturecreator.cpp
branchRCL_3
changeset 75 01504893d9cb
parent 64 34937ec34dac
equal deleted inserted replaced
68:5b238bc8ffb6 75:01504893d9cb
    27 #include "glxtexturemanager.h"
    27 #include "glxtexturemanager.h"
    28 #include "glxbinding.h"
    28 #include "glxbinding.h"
    29 #include "glxuiutility.h"
    29 #include "glxuiutility.h"
    30 #include "glxdrmgiftexturecreator.h"
    30 #include "glxdrmgiftexturecreator.h"
    31 #include "glxdrmgifactivedecoder.h"
    31 #include "glxdrmgifactivedecoder.h"
       
    32 #include <glxdrmutility.h>
       
    33 #include <glximageviewermanager.h>
    32 
    34 
    33 // Default frame interval for animation, in microseconds
    35 // Default frame interval for animation, in microseconds
    34 const TInt KDefaultFrameInterval = 100000;
    36 const TInt KDefaultFrameInterval = 100000;
    35 
    37 
    36 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    63         iAnimationTimer->Cancel();
    65         iAnimationTimer->Cancel();
    64         delete iAnimationTimer;
    66         delete iAnimationTimer;
    65         }
    67         }
    66 
    68 
    67     iUiUtility->Close();
    69     iUiUtility->Close();
    68 
    70     if (iDrmUtility)
       
    71         {
       
    72         iDrmUtility->Close();
       
    73         }
    69     delete iGlxDecoderAO;
    74     delete iGlxDecoderAO;
    70 
       
    71     iFsSession.Close();
    75     iFsSession.Close();
    72     }
    76     }
    73 
    77 
    74 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    75 // ReleaseContent 
    79 // ReleaseContent 
    81     iAnimCount = 0;
    85     iAnimCount = 0;
    82     iAnimateFlag = EFalse;
    86     iAnimateFlag = EFalse;
    83     iTransparencyPossible = EFalse;
    87     iTransparencyPossible = EFalse;
    84     iFrameShift = EFalse;
    88     iFrameShift = EFalse;
    85 
    89 
       
    90     //delete image viewer instance, if present.
       
    91     if ( iImageViewerInstance )
       
    92         {
       
    93         iImageViewerInstance->DeleteInstance();
       
    94         }
       
    95     
    86     if (iGlxDecoderAO)
    96     if (iGlxDecoderAO)
    87         {
    97         {
    88         iGlxDecoderAO->Cancel();
    98         iGlxDecoderAO->Cancel();
    89         }
    99         }
    90 
   100 
   133 void CGlxDrmGifTextureCreator::ConstructL()
   143 void CGlxDrmGifTextureCreator::ConstructL()
   134     {
   144     {
   135     TRACER("CGlxDrmGifTextureCreator::ConstructL()");
   145     TRACER("CGlxDrmGifTextureCreator::ConstructL()");
   136     iUiUtility = CGlxUiUtility::UtilityL();
   146     iUiUtility = CGlxUiUtility::UtilityL();
   137     User::LeaveIfError(iFsSession.Connect());
   147     User::LeaveIfError(iFsSession.Connect());
       
   148     
       
   149     //Create DRM Utility to check DRM rights validity 
       
   150     iDrmUtility = CGlxDRMUtility::InstanceL();
       
   151     // Create the active object
       
   152     iGlxDecoderAO = CGlxDRMgifDecoderAO::NewL(this);
       
   153     
       
   154     //Set the initial texture.And create and starts the Image Decoder
       
   155     SetInitialTextureAndStartDecodingL();
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // UpdateNewImageL 
       
   160 // -----------------------------------------------------------------------------
       
   161 void CGlxDrmGifTextureCreator::UpdateNewImageL(const TGlxMedia& aMedia,
       
   162         TInt aItemIndex)
       
   163     {
       
   164     TRACER("CGlxDrmGifTextureCreator::UpdateNewImageL()");
       
   165     GLX_LOG_INFO1("DrmGif: UpdateNewImageL() aItemIndex=%d", aItemIndex);
       
   166     
       
   167     //Start Decoding only if the aItemIndex refers to new Item index
       
   168     if (aItemIndex == iItemIndex)
       
   169         {
       
   170         //All textures were flushed when in background.
       
   171         //so, when app. comes to foreground again and DRM Rights have expired for 
       
   172         //current item, then create default Texture.
       
   173         if(iUiUtility->GetForegroundStatus() && IsDRMRightsExpiredL())
       
   174             {
       
   175             SetTexture();
       
   176             }
       
   177         return;
       
   178         }
       
   179 
       
   180     // First release the contents before proceeding further
       
   181     ReleaseContent();
       
   182 
       
   183     iItemIndex = aItemIndex;
       
   184     iMedia = &aMedia;
       
   185 
       
   186     //Set the initial texture.And create and starts the Image Decoder
       
   187     SetInitialTextureAndStartDecodingL();
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // SetInitialTextureAndStartDecodingL 
       
   192 // -----------------------------------------------------------------------------
       
   193 void CGlxDrmGifTextureCreator::SetInitialTextureAndStartDecodingL()
       
   194     {
       
   195     TRACER("CGlxDrmGifTextureCreator::SetInitialTextureAndStartDecodingL()");
       
   196     
   138     iBitmapReady = EFalse;
   197     iBitmapReady = EFalse;
   139     iAnimCount = 0;
   198     iAnimCount = 0;
   140     iAnimateFlag = EFalse;
   199     iAnimateFlag = EFalse;
   141     iTransparencyPossible = EFalse;
   200     iTransparencyPossible = EFalse;
   142     iFrameShift = EFalse;
   201     iFrameShift = EFalse;
   143 
   202 
   144     //Set the initial texture, it could be default or the FS texture
   203     //Creates the image viewer instance, if not created already.
   145     SetTexture();
   204     iImageViewerInstance = CGlxImageViewerManager::InstanceL();    
   146     // Create the active object
   205     __ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer));
   147     iGlxDecoderAO = CGlxDRMgifDecoderAO::NewL(this);
   206     
   148 #ifdef _DEBUG
       
   149     iStartTime.HomeTime();
       
   150 #endif	
       
   151     CreateImageDecoderL(iMedia->Uri());
       
   152     CreateBitmapAndStartDecodingL();
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // UpdateNewImageL 
       
   157 // -----------------------------------------------------------------------------
       
   158 void CGlxDrmGifTextureCreator::UpdateNewImageL(const TGlxMedia& aMedia,
       
   159         TInt aItemIndex)
       
   160     {
       
   161     TRACER("CGlxDrmGifTextureCreator::UpdateNewImageL()");
       
   162     GLX_LOG_INFO1("DrmGif: UpdateNewImageL() aItemIndex=%d", aItemIndex);
       
   163     if (aItemIndex == iItemIndex)
       
   164         {
       
   165         return;
       
   166         }
       
   167 
       
   168     // First release the contents before proceeding further
       
   169     ReleaseContent();
       
   170 
       
   171     iItemIndex = aItemIndex;
       
   172     iMedia = &aMedia;
       
   173 
       
   174     iBitmapReady = EFalse;
       
   175     iAnimCount = 0;
       
   176     iAnimateFlag = EFalse;
       
   177     iTransparencyPossible = EFalse;
       
   178     iFrameShift = EFalse;
       
   179 
       
   180     //Set the initial texture, it could be default or the FS texture
   207     //Set the initial texture, it could be default or the FS texture
   181     SetTexture();
   208     SetTexture();
   182 #ifdef _DEBUG
   209 #ifdef _DEBUG
   183     iStartTime.HomeTime();
   210     iStartTime.HomeTime();
   184 #endif
   211 #endif
   185     CreateImageDecoderL(iMedia->Uri());
   212     //Check if DRM Rights are not expired before starting image decoding
   186     CreateBitmapAndStartDecodingL();
   213     if (!IsDRMRightsExpiredL())
       
   214         {
       
   215         CreateImageDecoderL(iMedia->Uri());
       
   216         CreateBitmapAndStartDecodingL();
       
   217         }  
   187     }
   218     }
   188 
   219 
   189 // -----------------------------------------------------------------------------
   220 // -----------------------------------------------------------------------------
   190 // AnimateDRMGifItem 
   221 // AnimateDRMGifItem 
   191 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   505         {
   536         {
   506         iBinding->PopulateT(*item, iMediaList.Item(iItemIndex), ETrue, aTextureId);
   537         iBinding->PopulateT(*item, iMediaList.Item(iItemIndex), ETrue, aTextureId);
   507         iModel->SetData(iItemIndex, item);
   538         iModel->SetData(iItemIndex, item);
   508         }
   539         }
   509     }
   540     }
       
   541 
       
   542 // -----------------------------------------------------------------------------
       
   543 // IsDRMRightsExpiredL
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 TBool CGlxDrmGifTextureCreator::IsDRMRightsExpiredL()
       
   547     {
       
   548     TRACER("CGlxDrmGifTextureCreator::IsDRMRightsExpiredL");
       
   549     //To check if DRM rights are expired
       
   550     TBool expired = EFalse;
       
   551     TMPXGeneralCategory cat = iMedia->Category();
       
   552     
       
   553     if (iImageViewerInstance->IsPrivate())
       
   554         {
       
   555         expired = !iDrmUtility->DisplayItemRightsCheckL
       
   556                             (iImageViewerInstance->ImageFileHandle(),(cat == EMPXImage));
       
   557         }
       
   558     else
       
   559         {
       
   560         expired = !iDrmUtility->DisplayItemRightsCheckL(iMedia->Uri(), (cat == EMPXImage));
       
   561         }
       
   562     return expired;
       
   563     }
       
   564