videditor/VideoEditorCommon/src/VeiMGFetchVerifier.cpp
changeset 9 d87d32eab1a9
parent 0 951a5db380a0
equal deleted inserted replaced
0:951a5db380a0 9:d87d32eab1a9
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description: 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <coemain.h>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <drmcommon.h>
       
    23 #include <stringloader.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 
       
    26 #include <VideoEditorCommon.rsg>
       
    27 #include "VeiMGFetchVerifier.h"
       
    28 #include "VideoEditorCommon.h"
       
    29 #include "VideoEditorDebugUtils.h"
       
    30 
       
    31 // CONSTANTS
       
    32 _LIT(KResourceFile, "VideoEditorCommon.rsc");
       
    33 
       
    34 
       
    35 EXPORT_C CVeiMGFetchVerifier* CVeiMGFetchVerifier::NewLC()
       
    36 	{
       
    37 	CVeiMGFetchVerifier* self = new ( ELeave ) CVeiMGFetchVerifier;
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     return self;
       
    41 	}
       
    42 
       
    43 CVeiMGFetchVerifier::CVeiMGFetchVerifier() : iResLoader( *CCoeEnv::Static() )
       
    44 	{
       
    45 	}
       
    46 
       
    47 EXPORT_C CVeiMGFetchVerifier::~CVeiMGFetchVerifier()
       
    48 	{
       
    49 	iResLoader.Close();
       
    50 	}
       
    51 
       
    52 EXPORT_C TBool CVeiMGFetchVerifier::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
    53 	{
       
    54 	LOG(KVideoEditorLogFile, "CVeiMGFetchVerifier::VerifySelectionL: in");
       
    55         
       
    56 	TBool selectionAccepted( ETrue );
       
    57 
       
    58 	DRMCommon* drmCommon = DRMCommon::NewL();
       
    59 	CleanupStack::PushL (drmCommon);
       
    60 	
       
    61 	User::LeaveIfError( drmCommon->Connect() );
       
    62 	
       
    63 	TUint itemCount = aSelectedFiles->MdcaCount();
       
    64 	for (TUint i=0;i<itemCount;i++)
       
    65 		{
       
    66 		TInt fileProtectionStatus(0);
       
    67 		
       
    68 		TPtrC fileName = aSelectedFiles->MdcaPoint(i);
       
    69 		
       
    70 		drmCommon->IsProtectedFile( fileName, fileProtectionStatus );
       
    71 
       
    72 		if ( fileProtectionStatus != EFalse )
       
    73 			{
       
    74 			LOGFMT(KVideoEditorLogFile, "CVeiMGFetchVerifier::VerifySelectionL: File (%S) is protected. Show error note.", &fileName);
       
    75 			HBufC* stringholder;
       
    76 			CCoeEnv* coeEnv = CCoeEnv::Static();
       
    77 
       
    78 			stringholder = StringLoader::LoadLC( R_VEI_NOTE_DRM_NOT_ALLOWED, coeEnv );
       
    79 
       
    80 			CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
    81 			note->ExecuteLD( *stringholder );
       
    82 
       
    83 			CleanupStack::PopAndDestroy( stringholder );
       
    84 			selectionAccepted = EFalse;	
       
    85 			break;
       
    86 			}
       
    87 		LOGFMT(KVideoEditorLogFile, "CVeiMGFetchVerifier::VerifySelectionL: File (%S) is not protected.", &fileName);
       
    88 		}
       
    89 	drmCommon->Disconnect();
       
    90 	CleanupStack::PopAndDestroy (drmCommon);
       
    91 
       
    92 	LOGFMT(KVideoEditorLogFile, "CVeiMGFetchVerifier::VerifySelectionL: out: %d", selectionAccepted);
       
    93 	return selectionAccepted;
       
    94 	}
       
    95 
       
    96 	
       
    97 void CVeiMGFetchVerifier::ConstructL()
       
    98 	{
       
    99 	// Locate and open the resource file
       
   100     TFileName fileName;
       
   101     TParse p;    
       
   102 
       
   103     Dll::FileName(fileName);
       
   104     p.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, &fileName);
       
   105     fileName = p.FullName();
       
   106     
       
   107     LOGFMT(KVideoEditorLogFile, "\tLoading resource file: %S", &fileName);
       
   108 	iResLoader.OpenL( fileName ); // RConeResourceLoader selects the correct language file
       
   109 
       
   110 	}
       
   111 
       
   112 // End of file