contentmgmt/referencedrmagent/TestAgent/TestAgentFile.cpp
changeset 15 da2ae96f639b
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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 the License "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: 
       
    15 * dcffile.cpp
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <caf/caf.h>
       
    21 #include "TestAgentFile.h"
       
    22 
       
    23 using namespace ContentAccess;
       
    24 
       
    25 _LIT8(KDrmMimeType, "application/testagent.drm");
       
    26 
       
    27 CTestAgentFile* CTestAgentFile::NewL(RFile& aFile)
       
    28 	{
       
    29 	CTestAgentFile *self = new (ELeave) CTestAgentFile(aFile);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 CTestAgentFile::CTestAgentFile(RFile& aFile) : iFile(aFile)
       
    34 	{
       
    35 	}
       
    36 
       
    37 CTestAgentFile::~CTestAgentFile()
       
    38 	{	
       
    39 	}	
       
    40 
       
    41 TInt CTestAgentFile::Read(TDes8& aDes,TInt aLength)
       
    42 	{
       
    43 	return iFile.Read(aDes, aLength);
       
    44 	}
       
    45 
       
    46 void CTestAgentFile::Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus)
       
    47 	{
       
    48 	iFile.Read(aDes, aLength, aStatus);
       
    49 	}
       
    50 	
       
    51 void CTestAgentFile::ReadCancel(TRequestStatus& aStatus)
       
    52 {
       
    53 	iFile.ReadCancel(aStatus);
       
    54 }
       
    55 
       
    56 TInt CTestAgentFile::Seek(TSeek aMode, TInt& aPos)
       
    57 	{
       
    58 	return iFile.Seek(aMode, aPos);
       
    59 	}
       
    60 
       
    61 TPtrC8 CTestAgentFile::ContentMimeType()
       
    62 	{
       
    63 	return KDrmMimeType();
       
    64 	}
       
    65 
       
    66 TInt CTestAgentFile::GetAttribute(TInt aAttribute, TInt& aValue)
       
    67 	{
       
    68 	TInt err = KErrNone;
       
    69 	
       
    70 	switch(aAttribute)
       
    71 		{
       
    72 	case EIsProtected:
       
    73 		aValue = EFalse;
       
    74 		break;
       
    75 	case EIsForwardable:
       
    76 		aValue = ETrue;
       
    77 		break;
       
    78 	case EIsModifyable:
       
    79 		aValue = EFalse;
       
    80 		break;
       
    81 	case EIsCopyable:
       
    82 		aValue = ETrue;
       
    83 		break;
       
    84 	case EContentCDataInUse:
       
    85 		aValue = KErrCANotSupported;
       
    86 		break;
       
    87 	case ECopyPaste:
       
    88 		aValue = ETrue;	
       
    89 		break;
       
    90 	case ECanMove:
       
    91 		aValue = ETrue;
       
    92 		break;
       
    93 	case ECanRename:
       
    94 		aValue = ETrue;
       
    95 		break;
       
    96 	case EContentVersion:
       
    97 	default:
       
    98 		err = KErrCANotSupported;
       
    99 		break;
       
   100 		};
       
   101 	return err;
       
   102 	}
       
   103 	
       
   104 TInt CTestAgentFile::GetStringAttribute(TInt aAttribute, TDes& aValue)
       
   105 	{
       
   106 	TInt err = KErrNone;
       
   107 	
       
   108 	// the file itself
       
   109 	switch(aAttribute)
       
   110 		{
       
   111 		case EMimeType:
       
   112 			aValue.Copy(KDrmMimeType());
       
   113 			break;
       
   114 		default:
       
   115 			err = KErrCANotSupported;
       
   116 			break;
       
   117 		};
       
   118 	return err;	
       
   119 	}
       
   120 	
       
   121 void CTestAgentFile::DataSizeL(TInt &aSize)
       
   122 	{
       
   123 	iFile.Size(aSize);
       
   124 	}
       
   125 	
       
   126 void CTestAgentFile::Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus)
       
   127 	{
       
   128 	iFile.Read(aPos, aDes, aLength, aStatus);
       
   129 	}	
       
   130