phonesettings/pslncallimageplugin/src/PslnCallImagePluginDRM.cpp
branchRCL_3
changeset 62 5266b1f337bd
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:  Implementation of CPslnCallImagePluginDRM class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "PslnCallImagePluginDRM.h"
       
    21 
       
    22 #include    <DRMHelper.h>
       
    23 #include    <coemain.h>
       
    24 #include    <aknnotewrappers.h>
       
    25 #include    <Psln.rsg>
       
    26 #include    <drmutility.h>
       
    27 
       
    28 // Logging
       
    29 #include    "PslnCallImagePluginLogger.h"
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CCPslnCallImagePluginDRM::CPslnCallImagePluginDRM
       
    35 // C++ default constructor can NOT contain any code, that might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPslnCallImagePluginDRM::CPslnCallImagePluginDRM()
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CPslnCallImagePluginDRM::ConstructL
       
    44 // Symbian 2nd phase constructor can leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CPslnCallImagePluginDRM::ConstructL()
       
    48     {
       
    49     __CALLLOGSTRING("CPslnCallImagePluginDRM::ConstructL");
       
    50     iDRMHelper = CDRMHelper::NewL( *CCoeEnv::Static() );
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CPslnCallImagePluginDRM::NewL
       
    55 // Two-phased constructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CPslnCallImagePluginDRM* CPslnCallImagePluginDRM::NewL()
       
    59     {
       
    60     CPslnCallImagePluginDRM* self = new( ELeave ) CPslnCallImagePluginDRM();
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop( self );
       
    64     return self;
       
    65     }
       
    66     
       
    67 // -----------------------------------------------------------------------------
       
    68 // CPslnCallImagePluginDRM::~CPslnCallImagePluginDRM
       
    69 // Destructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CPslnCallImagePluginDRM::~CPslnCallImagePluginDRM()
       
    73     {
       
    74     __CALLLOGSTRING("CPslnCallImagePluginDRM::~CPslnCallImagePluginDRM");
       
    75     delete iDRMHelper;
       
    76     iDRMHelper = NULL;
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CPslnCallImagePluginDRM::IsFileValidL
       
    81 // Empty implementation.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TBool CPslnCallImagePluginDRM::VerifySelectionL(const MDesCArray* aSelectedFiles)
       
    85     {
       
    86     __CALLLOGSTRING("CPslnCallImagePluginDRM::VerifySelectionL START");
       
    87 
       
    88     TBool canbeautomated( EFalse );
       
    89     TBool iDrmProtected( EFalse );
       
    90     TInt res( KErrNone );
       
    91     RFile fileHandle;
       
    92     TUint fileMode = EFileShareReadersOrWriters | EFileStream | EFileRead;
       
    93     RFs fs = CCoeEnv::Static()->FsSession();
       
    94     
       
    95     if( aSelectedFiles->MdcaCount()<1 )
       
    96         {
       
    97         __CALLLOGSTRING("CPslnCallImagePluginDRM::VerifySelectionL zero items");
       
    98         __CALLLOGSTRING("CPslnCallImagePluginDRM::VerifySelectionL RETURN TRUE");
       
    99         // Download item
       
   100         return ETrue;
       
   101         }
       
   102  
       
   103     User::LeaveIfError(fileHandle.Open(fs, aSelectedFiles->MdcaPoint(0), fileMode));
       
   104     CleanupClosePushL(fileHandle);
       
   105      
       
   106     DRM::CDrmUtility* drmUtil = DRM::CDrmUtility::NewLC();
       
   107     iDrmProtected = drmUtil->IsProtectedL(fileHandle);
       
   108      
       
   109     CleanupStack::PopAndDestroy(2); // fileHandle, drmUtil
       
   110     
       
   111     if( !iDrmProtected )
       
   112         {
       
   113         res = iDRMHelper->SetAutomatedType( CDRMHelper::EAutomatedTypeWallpaper );
       
   114         __CALLLOGSTRING1("CPslnCallImagePluginDRM::VerifySelectionL SetAutomatedType called, result=%d", res );
       
   115         if ( res == KErrNone )
       
   116             {        
       
   117             res = iDRMHelper->CanSetAutomated(
       
   118                 aSelectedFiles->MdcaPoint(0), 
       
   119                 canbeautomated );
       
   120             }
       
   121         }
       
   122         
       
   123     __CALLLOGSTRING1("CPslnCallImagePluginDRM::VerifySelectionL Automated called, value=%d", canbeautomated);
       
   124     __CALLLOGSTRING1("CPslnCallImagePluginDRM::VerifySelectionL Automated called, result=%d", res);
       
   125     if (!res && !canbeautomated)
       
   126         {
       
   127         ShowErrorNoteL( R_PSLN_QTN_DRM_PREV_RIGHTS_SET );
       
   128         }
       
   129     else if (res || !canbeautomated)
       
   130         {
       
   131         iDRMHelper->HandleErrorL(res, aSelectedFiles->MdcaPoint(0) );
       
   132         }
       
   133     
       
   134     __CALLLOGSTRING("CPslnCallImagePluginDRM::VerifySelectionL RETURNING");
       
   135     return canbeautomated;
       
   136     }
       
   137     
       
   138 // -----------------------------------------------------------------------------
       
   139 // CPslnCallImagePluginDRM::ShowErrorNoteL
       
   140 // (other items were commented in a header).
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CPslnCallImagePluginDRM::ShowErrorNoteL( TInt  aResourceId  ) const
       
   144     {
       
   145     HBufC* errorText = 
       
   146         CCoeEnv::Static()->AllocReadResourceLC( aResourceId );
       
   147     CAknInformationNote* note = new( ELeave ) CAknInformationNote( EFalse );
       
   148     note->ExecuteLD( *errorText );
       
   149     CleanupStack::PopAndDestroy( errorText );
       
   150     }
       
   151 
       
   152 // End of File