imagingandcamerafws/imaginginttest/TestImageIAgent/src/testimageiagentdata.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <caf/attribute.h>
       
    17 #include "testimageiagentdata.h"
       
    18 
       
    19 using namespace ContentAccess;
       
    20 
       
    21 CTestIMAGEIAgentData* CTestIMAGEIAgentData::NewL(const TDesC& aURI, TContentShareMode aMode)
       
    22 	{
       
    23 	CTestIMAGEIAgentData* self = NewLC(aURI, aMode);
       
    24 	CleanupStack::Pop(self);
       
    25 	return self;
       
    26 	}
       
    27 
       
    28 CTestIMAGEIAgentData* CTestIMAGEIAgentData::NewLC(const TDesC& aURI, TContentShareMode aMode)
       
    29 	{
       
    30 	CTestIMAGEIAgentData* self=new(ELeave) CTestIMAGEIAgentData();
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL(aURI, aMode);
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 CTestIMAGEIAgentData::CTestIMAGEIAgentData()
       
    37 	{
       
    38 	}
       
    39 
       
    40 CTestIMAGEIAgentData::~CTestIMAGEIAgentData()
       
    41 	{
       
    42 	// Tidy up RFile and RFs
       
    43 	iFile.Close();
       
    44 	iFs.Close();
       
    45 	}
       
    46 
       
    47 
       
    48 
       
    49 void CTestIMAGEIAgentData::ConstructL(const TDesC& aURI, TContentShareMode aMode)
       
    50 	{
       
    51 	User::LeaveIfError(iFs.Connect());
       
    52 	// Make the file session shareable
       
    53 	User::LeaveIfError(iFs.ShareAuto());
       
    54 	User::LeaveIfError(iFile.Open(iFs, aURI, aMode));
       
    55 	}
       
    56 
       
    57 
       
    58 void CTestIMAGEIAgentData::GetAttributeL(const CBitset& /*aQuerySet*/,
       
    59 									        CBitset& aResponseSet)
       
    60 	{
       
    61 	// Test attributes
       
    62 	aResponseSet.Set(EIsProtected);
       
    63 	aResponseSet.Unset(EIsForwardable);
       
    64 	aResponseSet.Unset(EIsModifyable);
       
    65 	aResponseSet.Set(EIsCopyable);
       
    66 	}
       
    67 
       
    68 void CTestIMAGEIAgentData::DataSizeL(TInt &aSize)
       
    69 	{
       
    70 	User::LeaveIfError(iFile.Size(aSize));
       
    71 	}
       
    72 
       
    73 TInt CTestIMAGEIAgentData::EvaluateIntent(TIntent /*aIntent*/)
       
    74 	{
       
    75 	return KErrNone;
       
    76 	}
       
    77 
       
    78 TInt CTestIMAGEIAgentData::ExecuteIntent(TIntent /*aIntent*/)
       
    79 	{
       
    80 	return KErrNone;
       
    81 	}
       
    82 
       
    83 TInt CTestIMAGEIAgentData::Read(TDes8& aDes)
       
    84 	{
       
    85 	TInt err = iFile.Read(aDes);
       
    86 	
       
    87 	if(err == KErrNone)
       
    88 		{
       
    89 		InvertDes(aDes);
       
    90 		}
       
    91 	
       
    92 	return err;
       
    93 	}
       
    94 
       
    95 void CTestIMAGEIAgentData::InvertDes(TDes8& aDes)
       
    96 	{
       
    97 	TInt8 byteBuf;
       
    98 
       
    99 	for(TInt index=0; index<aDes.Length(); index++)
       
   100 		{
       
   101 		byteBuf = aDes[index];
       
   102 		byteBuf ^= 0xFF; //inverting the buf bits
       
   103 		aDes[index] = byteBuf;
       
   104 		}		
       
   105 	}
       
   106 
       
   107 TInt CTestIMAGEIAgentData::Read(TDes8& aDes,TInt aLength)
       
   108 	{
       
   109 	TInt err = iFile.Read(aDes,aLength);
       
   110 	
       
   111 	if(err == KErrNone)
       
   112 		{
       
   113 		InvertDes(aDes);
       
   114 		}
       
   115 	
       
   116 	return err;
       
   117 	}
       
   118 
       
   119 void CTestIMAGEIAgentData::Read(TDes8& aDes,TRequestStatus& aStatus)
       
   120 	{
       
   121 	iFile.Read(aDes, aStatus);
       
   122 	InvertDes(aDes);
       
   123 	}
       
   124 
       
   125 void CTestIMAGEIAgentData::Read(TDes8& aDes,
       
   126 							 TInt aLength,
       
   127 							 TRequestStatus& aStatus)
       
   128 	{
       
   129 	iFile.Read(aDes, aLength, aStatus);
       
   130 	InvertDes(aDes);
       
   131 	}
       
   132 
       
   133 TInt CTestIMAGEIAgentData::Seek(TSeek aMode, TInt& aPos) 
       
   134 	{
       
   135 	return iFile.Seek(aMode, aPos);
       
   136 	}
       
   137 
       
   138 TInt CTestIMAGEIAgentData::SetProperty(TAgentProperty /*aProperty*/, TInt /*aValue*/)
       
   139 	{
       
   140 	return KErrCANotSupported;
       
   141 	}
       
   142 
       
   143 TInt CTestIMAGEIAgentData::GetAttribute(TInt /*aAttribute*/, TInt& /*aValue*/)
       
   144 	{
       
   145 	return KErrNone;
       
   146 	}
       
   147 
       
   148 TInt CTestIMAGEIAgentData::GetAttributeSet(RAttributeSet& /*aAttributeSet*/)
       
   149 	{
       
   150 	return KErrNone;			
       
   151 	}
       
   152 
       
   153 TInt CTestIMAGEIAgentData::GetStringAttribute(TInt /*aAttribute*/, TDes& /*aValue*/)
       
   154 	{
       
   155 	return KErrNone;
       
   156 	}
       
   157 
       
   158 TInt CTestIMAGEIAgentData::GetStringAttributeSet(RStringAttributeSet& /*aStringAttributeSet*/)
       
   159 	{
       
   160 	return KErrNone;
       
   161 	}