photosgallery/viewframework/drmutility/src/glxdrmutility.cpp
branchRCL_3
changeset 23 b023a8d2866a
parent 18 78ad99c24f08
child 24 ea65f74e6de4
equal deleted inserted replaced
21:f9e827349359 23:b023a8d2866a
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:    DRM utility implementation
    14  * Description:    DRM utility implementation
    15 *
    15  *
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 03/07/2007 by Rowland Cook
       
    23  */
    16  */
       
    17 
    24 
    18 
    25 // INCLUDES
    19 // INCLUDES
    26 
    20 
    27 #include "glxdrmutility.h"
    21 #include "glxdrmutility.h"
    28 
    22 
    34 #include <caf/caf.h>
    28 #include <caf/caf.h>
    35 #include <caf/content.h>
    29 #include <caf/content.h>
    36 #include <caf/data.h>
    30 #include <caf/data.h>
    37 #include <caf/manager.h>
    31 #include <caf/manager.h>
    38 #include "glxtracer.h"
    32 #include "glxtracer.h"
       
    33 #include "glxlog.h"
    39 
    34 
    40 const TInt KGlxDRMThumbnailHeight = 120;
    35 const TInt KGlxDRMThumbnailHeight = 120;
    41 const TInt KGlxDRMThumbnailWidth = 90;
    36 const TInt KGlxDRMThumbnailWidth = 90;
    42 
    37 
    43 // ======== MEMBER FUNCTIONS ========
    38 // ======== MEMBER FUNCTIONS ========
    48  * Global object stored in TLS. 
    43  * Global object stored in TLS. 
    49  * Owns the only instance of a CGlxDRMUtility
    44  * Owns the only instance of a CGlxDRMUtility
    50  */
    45  */
    51 struct CGlxDrmTls
    46 struct CGlxDrmTls
    52     {
    47     {
    53     CGlxDrmTls(CGlxDRMUtility* aUtility) 
    48     CGlxDrmTls(CGlxDRMUtility* aUtility)
    54         {
    49         {
    55         iDrmUtility = aUtility;
    50         iDrmUtility = aUtility;
    56         iRefCount = 0;
    51         iRefCount = 0;
    57         }
    52         }
    58         
    53 
    59     CGlxDRMUtility* iDrmUtility;
    54     CGlxDRMUtility* iDrmUtility;
    60     TInt iRefCount;
    55     TInt iRefCount;
    61     };
    56     };
    62 
    57 
    63 //============================================================================
    58 //============================================================================
    64 // InstanceL
    59 // InstanceL
    65 //============================================================================
    60 //============================================================================
    66 EXPORT_C CGlxDRMUtility* CGlxDRMUtility::InstanceL()
    61 EXPORT_C CGlxDRMUtility* CGlxDRMUtility::InstanceL()
    67     {
    62     {
    68     TRACER("CGlxDRMUtility::InstanceL()");
    63     TRACER("CGlxDRMUtility::InstanceL()");
    69     CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*>(Dll::Tls());
    64     CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*> (Dll::Tls());
    70     
    65 
    71     if ( !tls )
    66     if (!tls)
    72         {
    67         {
    73         CGlxDRMUtility* drmutil = new(ELeave)CGlxDRMUtility();
    68         CGlxDRMUtility* drmutil = new (ELeave) CGlxDRMUtility();
    74         CleanupStack::PushL(drmutil);
    69         CleanupStack::PushL(drmutil);
    75         drmutil->ConstructL();
    70         drmutil->ConstructL();
    76         
    71 
    77         tls = new (ELeave) CGlxDrmTls(drmutil);
    72         tls = new (ELeave) CGlxDrmTls(drmutil);
    78         
    73 
    79         CleanupStack::Pop(drmutil);
    74         CleanupStack::Pop(drmutil);
    80         
    75 
    81         Dll::SetTls( reinterpret_cast<TAny*>(tls));
    76         Dll::SetTls(reinterpret_cast<TAny*> (tls));
    82         }
    77         }
    83         
    78 
    84     tls->iRefCount++;
    79     tls->iRefCount++;
    85     
    80 
    86     return tls->iDrmUtility;
    81     return tls->iDrmUtility;
    87     }
    82     }
    88     
    83 
    89 //============================================================================
    84 //============================================================================
    90 // Close
    85 // Close
    91 //============================================================================ 
    86 //============================================================================ 
    92 EXPORT_C void CGlxDRMUtility::Close()
    87 EXPORT_C void CGlxDRMUtility::Close()
    93     {
    88     {
    94     TRACER("CGlxDRMUtility::Close()");
    89     TRACER("CGlxDRMUtility::Close()");
    95     CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*>(Dll::Tls());
    90     CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*> (Dll::Tls());
    96    
    91 
    97     if ( tls ) 
    92     if (tls)
    98         {
    93         {
    99         tls->iRefCount--;
    94         tls->iRefCount--;
   100         
    95 
   101         // Delete the tls pointer and list manager instance if this was the 
    96         // Delete the tls pointer and list manager instance if this was the 
   102         // last reference
    97         // last reference
   103         if (tls->iRefCount == 0)
    98         if (tls->iRefCount == 0)
   104             {
    99             {
   105             delete tls->iDrmUtility;
   100             delete tls->iDrmUtility;
   117     TRACER("CGlxDRMUtility::~CGlxDRMUtility()");
   112     TRACER("CGlxDRMUtility::~CGlxDRMUtility()");
   118     delete iCManager;
   113     delete iCManager;
   119     delete iDrmHelper;
   114     delete iDrmHelper;
   120     delete iLastConsumedItemUri;
   115     delete iLastConsumedItemUri;
   121     }
   116     }
   122     
   117 
   123 //============================================================================
   118 //============================================================================
   124 // ItemRightsValidityCheckL
   119 // ItemRightsValidityCheckL
   125 // for checking DRM rights validity for item.
   120 // for checking DRM rights validity for item.
   126 // is called before right is consumed and for all items (focused or unfocused).
   121 // is called before right is consumed and for all items (focused or unfocused).
   127 //============================================================================
   122 //============================================================================
   128 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL( const TDesC& aUri,
   123 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL(const TDesC& aUri,
   129                                                 TBool aCheckViewRights )
   124         TBool aCheckViewRights)
   130     {
   125     {
   131     TRACER("CGlxDRMUtility::ItemRightsValidityCheckL()");
   126     TRACER("CGlxDRMUtility::ItemRightsValidityCheckL(URI)");
       
   127 #ifdef _DEBUG
       
   128     TTime startTime;
       
   129     startTime.HomeTime();
       
   130 #endif         
   132     // When checking current rights for a URI
   131     // When checking current rights for a URI
   133 
       
   134     //Allow to Open if rights for a URI was just consumed (i.e. same as stored URI)
   132     //Allow to Open if rights for a URI was just consumed (i.e. same as stored URI)
   135 	if ( iLastConsumedItemUri->Length() > 0 )
   133     if (iLastConsumedItemUri->Length() > 0)
   136 		{
   134         {
   137 		if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 )
   135         if (aUri.CompareF(*iLastConsumedItemUri) == 0)
   138 			{
   136             {
   139 			return ETrue;
   137             return ETrue;
   140 			}
   138             }
   141 		}
   139         }
   142 
   140 
   143 	//Else for uri of non-focused uri, just check validity rights
   141     //Else for uri of non-focused uri, just check validity rights
   144     TBool rightsValid = EFalse;
   142     TBool rightsValid = EFalse;
   145     TVirtualPathPtr path( aUri, KDefaultContentObject() );
   143     TVirtualPathPtr path(aUri, KDefaultContentObject());
   146 
   144 
   147     ContentAccess::TAttribute attr = 
   145     ContentAccess::TAttribute attr =
   148         aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay;
   146         aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay;
   149 
   147 
   150     // rightsValid is not updated if an error occurs
   148     // rightsValid is not updated if an error occurs
   151     iCManager->GetAttribute( attr, rightsValid, path );
   149     iCManager->GetAttribute(attr, rightsValid, path);
   152     
   150 #ifdef _DEBUG
       
   151     TTime stopTime;
       
   152     stopTime.HomeTime();
       
   153     GLX_DEBUG2("CGlxDRMUtility::ItemRightsValidityCheckL(URI) took <%d> us",
       
   154             (TInt) stopTime.MicroSecondsFrom(startTime).Int64());
       
   155 #endif  
   153     return rightsValid;
   156     return rightsValid;
   154     }
   157     }
   155 
   158 
   156 //============================================================================
   159 //============================================================================
   157 // ItemRightsValidityCheckL
   160 // ItemRightsValidityCheckL
   158 // for checking DRM rights validity for item.
   161 // for checking DRM rights validity for item.
   159 // is called before right is consumed and for all items (focused or unfocused).
   162 // is called before right is consumed and for all items (focused or unfocused).
   160 //============================================================================
   163 //============================================================================
   161 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL( RFile& aFileHandle,
   164 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL(RFile& aFileHandle,
   162                                                 TBool aCheckViewRights )
   165         TBool aCheckViewRights)
   163     {
   166     {
   164     TRACER("CGlxDRMUtility::ItemRightsValidityCheckL()");
   167     TRACER("CGlxDRMUtility::ItemRightsValidityCheckL(RFile)");
       
   168 #ifdef _DEBUG
       
   169     TTime startTime;
       
   170     startTime.HomeTime();
       
   171 #endif         
   165     TBool rightsValid = EFalse;
   172     TBool rightsValid = EFalse;
   166 
   173     ContentAccess::TAttribute attrib =
   167     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( aFileHandle );
   174         aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay;
   168     TInt err( content->GetAttribute( ContentAccess::ECanView, rightsValid ) );
   175 
   169     CleanupStack::PopAndDestroy( content );
   176     ContentAccess::CContent* content = ContentAccess::CContent::NewLC(
       
   177             aFileHandle);
       
   178     TInt err(content->GetAttribute(attrib, rightsValid));
       
   179     CleanupStack::PopAndDestroy(content);
       
   180 #ifdef _DEBUG
       
   181     TTime stopTime;
       
   182     stopTime.HomeTime();
       
   183     GLX_DEBUG2("CGlxDRMUtility::ItemRightsValidityCheckL(RFile) took <%d> us",
       
   184             (TInt) stopTime.MicroSecondsFrom(startTime).Int64());
       
   185 #endif    
   170     return rightsValid;
   186     return rightsValid;
   171     }
   187     }
   172 
   188 
   173 //============================================================================
   189 //============================================================================
   174 // DisplayItemRightsCheckL
   190 // DisplayItemRightsCheckL
   175 // is called after right is consumed and for only focused/displayed item.
   191 // is called after right is consumed and for only focused/displayed item.
   176 //============================================================================
   192 //============================================================================
   177 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL( const TDesC& aUri,
   193 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL(const TDesC& aUri,
   178                                                     TBool aCheckViewRights )
   194         TBool aCheckViewRights)
   179     {
   195     {
   180     TRACER("CGlxDRMUtility::DisplayItemRightsCheckL()");
   196     TRACER("CGlxDRMUtility::DisplayItemRightsCheckL(URI)");
   181 
   197 
   182     // Allow to display if rights for a URI was just consumed (i.e. same as stored URI)
   198     // Allow to display if rights for a URI was just consumed (i.e. same as stored URI)
   183     if ( iLastConsumedItemUri->Length() > 0 )
   199     if (iLastConsumedItemUri->Length() > 0)
   184         {
   200         {
   185         if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 )
   201         if (aUri.CompareF(*iLastConsumedItemUri) == 0)
   186             {
   202             {
   187             return ETrue;
   203             return ETrue;
   188             }
   204             }
   189         }
   205         }
   190 
   206 
   191     //Clear the stored uri since focus has changed
   207     //Clear the stored uri since focus has changed
   192     ClearLastConsumedItemUriL();
   208     ClearLastConsumedItemUriL();
   193 
   209 
   194     // Otherwise, check current rights for the URI of newly focused item
   210     // Otherwise, check current rights for the URI of newly focused item
   195     return ItemRightsValidityCheckL( aUri, aCheckViewRights );
   211     return ItemRightsValidityCheckL(aUri, aCheckViewRights);
   196     }
   212     }
   197 
   213 
   198 //============================================================================
   214 //============================================================================
   199 // DisplayItemRightsCheckL
   215 // DisplayItemRightsCheckL
   200 // is called after right is consumed and for only focused/displayed item.
   216 // is called after right is consumed and for only focused/displayed item.
   201 //============================================================================
   217 //============================================================================
   202 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL( RFile& aFileHandle,
   218 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL(RFile& aFileHandle,
   203                                                     TBool aCheckViewRights )
   219         TBool aCheckViewRights)
   204     {
   220     {
   205     TRACER("CGlxDRMUtility::DisplayItemRightsCheckL()");
   221     TRACER("CGlxDRMUtility::DisplayItemRightsCheckL(RFile)");
   206     // Otherwise, check current rights for the URI of newly focused item
   222     // Otherwise, check current rights for the URI of newly focused item
   207     return ItemRightsValidityCheckL( aFileHandle, aCheckViewRights );
   223     return ItemRightsValidityCheckL(aFileHandle, aCheckViewRights);
   208     }
   224     }
   209 
       
   210 
   225 
   211 //============================================================================
   226 //============================================================================
   212 // ConsumeRightsL
   227 // ConsumeRightsL
   213 //============================================================================    
   228 //============================================================================    
   214 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(const TDesC& aUri)
   229 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(const TDesC& aUri)
   215     {
   230     {
   216     TRACER("CGlxDRMUtility::ConsumeRightsL()");
   231     TRACER("CGlxDRMUtility::ConsumeRightsL(URI)");
   217     TVirtualPathPtr path( aUri, KDefaultContentObject() );
   232     TVirtualPathPtr path(aUri, KDefaultContentObject());
   218 
   233 
   219     // Create a CData object to read the content
   234     // Create a CData object to read the content
   220     // Tell the agent we are planning to display the content
   235     // Tell the agent we are planning to display the content
   221     CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly);
   236     CData* data = CData::NewLC(path, ContentAccess::EView,
       
   237             EContentShareReadOnly);
   222 
   238 
   223     //When consuming rights for a URI, clear stored URI
   239     //When consuming rights for a URI, clear stored URI
   224     ClearLastConsumedItemUriL();
   240     ClearLastConsumedItemUriL();
   225 
   241 
   226     // Execute the intent, tell the agent that we plan to display the content
   242     // Execute the intent, tell the agent that we plan to display the content
   227     // It is at this point that any stateful rights will be decremented
   243     // It is at this point that any stateful rights will be decremented
   228     TInt err = data->ExecuteIntent(ContentAccess::EView);
   244     TInt err = data->ExecuteIntent(ContentAccess::EView);
   229     if ( err == KErrNone )
   245     if (err == KErrNone)
   230         {
   246         {
   231         //Update stored URI
   247         //Update stored URI
   232         iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() );
   248         iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL(aUri.Length());
   233         TPtr newPtr = iLastConsumedItemUri->Des();
   249         TPtr newPtr = iLastConsumedItemUri->Des();
   234         newPtr.Copy( aUri );
   250         newPtr.Copy(aUri);
   235         }
   251         }
   236 
   252 
   237     CleanupStack::PopAndDestroy(data);
   253     CleanupStack::PopAndDestroy(data);
   238 
   254 
   239     return (err == KErrNone);
   255     return (err == KErrNone);
   240     }
   256     }
   241 
       
   242 
   257 
   243 //============================================================================
   258 //============================================================================
   244 // ConsumeRightsL
   259 // ConsumeRightsL
   245 //============================================================================    
   260 //============================================================================    
   246 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle)
   261 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle)
   247     {
   262     {
   248     TRACER("CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle)");
   263     TRACER("CGlxDRMUtility::ConsumeRightsL(RFile)");
   249     CData* data = CData::NewLC( aFileHandle, KDefaultContentObject(), EPeek );
   264     CData* data = CData::NewLC(aFileHandle, KDefaultContentObject(), EPeek);
   250     TInt err = data->ExecuteIntent(ContentAccess::EView);
   265     TInt err = data->ExecuteIntent(ContentAccess::EView);
   251     CleanupStack::PopAndDestroy( data );
   266     CleanupStack::PopAndDestroy(data);
   252     return (err == KErrNone);
   267     return (err == KErrNone);
   253     }
   268     }
   254 
   269 
   255 //============================================================================
   270 //============================================================================
   256 //Clears Last Consumed Uri
   271 //Clears Last Consumed Uri
   257 //============================================================================
   272 //============================================================================
   258 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUriL()
   273 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUriL()
   259 	{
   274     {
   260 	//clears the stored uri
   275     TRACER("CGlxDRMUtility::ClearLastConsumedItemUriL()");
   261 	TPtr ptr = iLastConsumedItemUri->Des();
   276     //clears the stored uri
   262 	ptr.Zero();
   277     TPtr ptr = iLastConsumedItemUri->Des();
   263 	iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 );
   278     ptr.Zero();
   264 	}
   279     iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL(0);
       
   280     }
   265 
   281 
   266 //============================================================================
   282 //============================================================================
   267 // Test whether a media item is OMA DRM 2.0 protected and has an associated
   283 // Test whether a media item is OMA DRM 2.0 protected and has an associated
   268 // info URL.
   284 // info URL.
   269 //============================================================================
   285 //============================================================================
   271     {
   287     {
   272     TRACER("CGlxDRMUtility::CanShowInfoOnlineL()");
   288     TRACER("CGlxDRMUtility::CanShowInfoOnlineL()");
   273     TBool canShowInfoOnline = EFalse;
   289     TBool canShowInfoOnline = EFalse;
   274 
   290 
   275     HBufC8* urlBuf = NULL;
   291     HBufC8* urlBuf = NULL;
   276     canShowInfoOnline = iDrmHelper->HasInfoUrlL( const_cast<TDesC&>(aUri) , urlBuf);
   292     canShowInfoOnline = iDrmHelper->HasInfoUrlL(const_cast<TDesC&> (aUri),
       
   293             urlBuf);
   277 
   294 
   278     // discard buf we don't need it
   295     // discard buf we don't need it
   279     delete urlBuf;
   296     delete urlBuf;
   280     
   297 
   281     return canShowInfoOnline;
   298     return canShowInfoOnline;
   282     }
   299     }
   283 
   300 
   284 //============================================================================
   301 //============================================================================
   285 // Open the associated info URL for a media item in the browser.
   302 // Open the associated info URL for a media item in the browser.
   286 //============================================================================
   303 //============================================================================
   287 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(const TDesC& aUri)
   304 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(const TDesC& aUri)
   288     {
   305     {
   289     TRACER("CGlxDRMUtility::ShowInfoOnlineL()");
   306     TRACER("CGlxDRMUtility::ShowInfoOnlineL()");
   290     iDrmHelper->OpenInfoUrlL( const_cast<TDesC&>(aUri) );
   307     iDrmHelper->OpenInfoUrlL(const_cast<TDesC&> (aUri));
   291     }
   308     }
   292 
   309 
   293 //============================================================================
   310 //============================================================================
   294 // Test whether a media item can be set as automated content.
   311 // Test whether a media item can be set as automated content.
   295 //============================================================================
   312 //============================================================================
   296 EXPORT_C TBool CGlxDRMUtility::CanSetAsAutomatedL(const TDesC& aUri, 
   313 EXPORT_C TBool CGlxDRMUtility::CanSetAsAutomatedL(const TDesC& aUri,
   297                                     TGlxDrmAutomatedType aType)
   314         TGlxDrmAutomatedType aType)
   298     {
   315     {
   299     TRACER("CGlxDRMUtility::CanSetAsAutomatedL()");
   316     TRACER("CGlxDRMUtility::CanSetAsAutomatedL()");
   300     TBool canSetAutomated = EFalse;
   317     TBool canSetAutomated = EFalse;
   301     switch(aType)
   318     switch (aType)
   302         {
   319         {
   303     case EGlxDrmAutomatedTypeWallpaper:
   320         case EGlxDrmAutomatedTypeWallpaper:
   304         {
   321             {
   305         User::LeaveIfError(iDrmHelper->SetAutomatedType(CDRMHelper::EAutomatedTypeWallpaper));
   322             User::LeaveIfError(iDrmHelper->SetAutomatedType(
   306         User::LeaveIfError(iDrmHelper->CanSetAutomated(aUri, canSetAutomated));
   323                     CDRMHelper::EAutomatedTypeWallpaper));
   307         break;
   324             User::LeaveIfError(iDrmHelper->CanSetAutomated(aUri,
   308         }
   325                     canSetAutomated));
   309     default:
   326             break;
   310         break;
   327             }
       
   328         default:
       
   329             break;
   311         };
   330         };
   312     return canSetAutomated;
   331     return canSetAutomated;
   313     }
   332     }
   314 
   333 
   315 //============================================================================
   334 //============================================================================
   316 // SetAsAutomatedL
   335 // SetAsAutomatedL
   317 //============================================================================
   336 //============================================================================
   318 EXPORT_C void CGlxDRMUtility::SetAsAutomatedL(const TDesC& aUri, 
   337 EXPORT_C void CGlxDRMUtility::SetAsAutomatedL(const TDesC& aUri,
   319                                     TGlxDrmAutomatedType aType)
   338         TGlxDrmAutomatedType aType)
   320     {
   339     {
   321     TRACER("CGlxDRMUtility::SetAsAutomatedL()");
   340     TRACER("CGlxDRMUtility::SetAsAutomatedL()");
   322      switch(aType)
   341     switch (aType)
   323         {
   342         {
   324     case EGlxDrmAutomatedTypeWallpaper:
   343         case EGlxDrmAutomatedTypeWallpaper:
   325         {
       
   326         TInt error = iDrmHelper->SetAutomatedType(CDRMHelper::EAutomatedTypeWallpaper);
       
   327         if(KErrNone==error)
       
   328             {
   344             {
   329             error= iDrmHelper->SetAutomatedPassive(aUri);
   345             TInt error = iDrmHelper->SetAutomatedType(
   330             if(KErrNone!=error)
   346                     CDRMHelper::EAutomatedTypeWallpaper);
       
   347             if (KErrNone == error)
   331                 {
   348                 {
   332                 iDrmHelper->HandleErrorL(error, aUri);
   349                 error = iDrmHelper->SetAutomatedPassive(aUri);
       
   350                 if (KErrNone != error)
       
   351                     {
       
   352                     iDrmHelper->HandleErrorL(error, aUri);
       
   353                     }
   333                 }
   354                 }
       
   355 
       
   356             break;
   334             }
   357             }
   335         
   358         default:
   336         break;
   359             break;
   337         }
       
   338     default:
       
   339         break;
       
   340         };
   360         };
   341     }
   361     }
   342 
   362 
   343 //============================================================================
   363 //============================================================================
   344 // ShowDRMDetailsPane
   364 // ShowDRMDetailsPane
   345 //============================================================================  
   365 //============================================================================  
   346 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL( const TDesC& aUri )
   366 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(const TDesC& aUri)
   347     {
   367     {
   348     TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()");
   368     TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL(URI)");
   349     TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) );
   369     TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) );
   350     // if no rights ask user to re-activate
   370     // if no rights ask user to re-activate
   351     if( err == KErrCANoRights )
   371     if (err == KErrCANoRights)
   352         {
   372         {
   353         HBufC* buf = aUri.AllocLC();
   373         HBufC* buf = aUri.AllocLC();
   354         iDrmHelper->ActivateContentL( *buf );        
   374         iDrmHelper->ActivateContentL(*buf);
   355         CleanupStack::PopAndDestroy( buf );
   375         CleanupStack::PopAndDestroy(buf);
   356         }
   376         }
   357 
   377 
   358     }
   378     }
   359 
   379 
   360 //============================================================================
   380 //============================================================================
   361 // ShowDRMDetailsPane
   381 // ShowDRMDetailsPane
   362 //============================================================================  
   382 //============================================================================  
   363 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(RFile& aFileHandle)
   383 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(RFile& aFileHandle)
   364     {
   384     {
   365     TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()");
   385     TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL(RFile)");
   366     TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aFileHandle ) );
   386     TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aFileHandle ) );
   367     // if no rights ask user to re-activate
   387     // if no rights ask user to re-activate
   368     if( err == KErrCANoRights )
   388     if (err == KErrCANoRights)
   369         {
   389         {
   370         //need to check if we need to handle.
   390         //need to check if we need to handle.
   371         }
   391         }
   372 
       
   373     }
   392     }
   374 
   393 
   375 //============================================================================
   394 //============================================================================
   376 // IsForwardLockedL
   395 // IsForwardLockedL
   377 //============================================================================  
   396 //============================================================================  
   378 EXPORT_C TBool CGlxDRMUtility::IsForwardLockedL(const TDesC& aUri)
   397 EXPORT_C TBool CGlxDRMUtility::IsForwardLockedL(const TDesC& aUri)
   379     {
   398     {
   380     TRACER("CGlxDRMUtility::IsForwardLockedL()");
   399     TRACER("CGlxDRMUtility::IsForwardLockedL()");
   381     TBool forwardLocked = EFalse;
   400     TBool forwardLocked = EFalse;
   382     TVirtualPathPtr path( aUri, KDefaultContentObject() );
   401     TVirtualPathPtr path(aUri, KDefaultContentObject());
   383 
   402 
   384     // forwardLocked is not updated if an error occurs
   403     // forwardLocked is not updated if an error occurs
   385     iCManager->GetAttribute( ContentAccess::EIsForwardable, forwardLocked, path );
   404     iCManager->GetAttribute(ContentAccess::EIsForwardable, forwardLocked,
       
   405             path);
   386 
   406 
   387     return forwardLocked;
   407     return forwardLocked;
   388     }
   408     }
   389     
   409 
   390 //============================================================================
   410 //============================================================================
   391 // ShowRightsInfoL
   411 // ShowRightsInfoL
   392 //============================================================================    
   412 //============================================================================    
   393 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(const TDesC& aUri)    
   413 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(const TDesC& aUri)
   394     {
   414     {
   395     TRACER("CGlxDRMUtility::ShowRightsInfoL()");
   415     TRACER("CGlxDRMUtility::ShowRightsInfoL(URI)");
   396     iDrmHelper->CheckRightsAmountL( aUri );
   416     iDrmHelper->CheckRightsAmountL(aUri);
   397     }
   417     }
   398 
   418 
   399 //============================================================================
   419 //============================================================================
   400 // ShowRightsInfoL
   420 // ShowRightsInfoL
   401 //============================================================================    
   421 //============================================================================    
   402 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(RFile& aFileHandle)    
   422 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(RFile& aFileHandle)
   403     {
   423     {
   404     TRACER("CGlxDRMUtility::ShowRightsInfoL(aFileHandle)");
   424     TRACER("CGlxDRMUtility::ShowRightsInfoL(RFile)");
   405     iDrmHelper->CheckRightsAmountL( aFileHandle );
   425     iDrmHelper->CheckRightsAmountL(aFileHandle);
   406     }
   426     }
   407 
   427 
   408 //============================================================================
   428 //============================================================================
   409 // Return size for DRM thumbnail request.
   429 // Return size for DRM thumbnail request.
   410 //============================================================================
   430 //============================================================================
   411 EXPORT_C TSize CGlxDRMUtility::DRMThumbnailSize(TSize& aSize)
   431 EXPORT_C TSize CGlxDRMUtility::DRMThumbnailSize(TSize& aSize)
   412     {
   432     {
   413     TRACER("CGlxDRMUtility::DRMThumbnailSize()");
   433     TRACER("CGlxDRMUtility::DRMThumbnailSize()");
   414     TSize thumbnailSize(KGlxDRMThumbnailWidth, KGlxDRMThumbnailHeight);
   434     TSize thumbnailSize(KGlxDRMThumbnailWidth, KGlxDRMThumbnailHeight);
   415     
   435 
   416     if((aSize.iWidth*aSize.iHeight)/4 < 
   436     if ((aSize.iWidth * aSize.iHeight) / 4 < KGlxDRMThumbnailWidth
   417             KGlxDRMThumbnailWidth * KGlxDRMThumbnailHeight)
   437             * KGlxDRMThumbnailHeight)
   418         {
   438         {
   419         thumbnailSize.iWidth = aSize.iWidth/2;
   439         thumbnailSize.iWidth = aSize.iWidth / 2;
   420         thumbnailSize.iHeight = aSize.iHeight/2;
   440         thumbnailSize.iHeight = aSize.iHeight / 2;
   421         }
   441         }
   422     
   442 
   423     return thumbnailSize;
   443     return thumbnailSize;
   424     }
   444     }
   425     
   445 
   426 /**
   446 /**
   427  * C++ default constructor.
   447  * C++ default constructor.
   428  */
   448  */
   429 CGlxDRMUtility::CGlxDRMUtility()
   449 CGlxDRMUtility::CGlxDRMUtility()
   430     {
   450     {
   440     iCManager = ContentAccess::CManager::NewL();
   460     iCManager = ContentAccess::CManager::NewL();
   441     iDrmHelper = CDRMHelper::NewL();
   461     iDrmHelper = CDRMHelper::NewL();
   442     iLastConsumedItemUri = HBufC::NewL(0);
   462     iLastConsumedItemUri = HBufC::NewL(0);
   443     }
   463     }
   444 
   464 
   445 
       
   446 // End of File
   465 // End of File