williamr@2: /* williamr@2: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __SUPPLIER_H__ williamr@2: #define __SUPPLIER_H__ williamr@2: williamr@2: #include <e32base.h> williamr@2: #include <e32std.h> williamr@2: #include <caf/caftypes.h> williamr@2: williamr@2: class RHTTPHeaders; williamr@2: class RStringPool; williamr@2: williamr@2: namespace ContentAccess williamr@2: { williamr@2: class CImportFile; williamr@2: class CMetaDataArray; williamr@2: class CAgentResolver; williamr@2: class MFileHandleProvider; williamr@2: williamr@2: #ifndef REMOVE_CAF1 williamr@2: class CCafMimeHeader; williamr@2: #endif williamr@2: williamr@2: /** williamr@2: Used to import files using a content access agent. In the case of some williamr@2: DRM agents the import will be a transformation from an unprotected content type williamr@2: to a protected content type. williamr@2: williamr@2: It creates CImportFile objects to import files into a Content Access williamr@2: Agent. CSupplier uses it's CAgentResolver to determine which agent should receive williamr@2: the file based upon the mime type of the file. williamr@2: williamr@2: Clients can check if a mime type is supported by by calling the williamr@2: CSupplier::IsImportSupported() function. williamr@2: williamr@2: The CSupplier does not dynamically update it's list of agents so applications williamr@2: should not use a long term persistent instance of CSupplier. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: class CSupplier : public CBase williamr@2: { williamr@2: public: williamr@2: /** Create a new CSupplier williamr@2: @return a CSupplier object williamr@2: */ williamr@2: IMPORT_C static CSupplier* NewL(); williamr@2: williamr@2: /** Create a new CSupplier williamr@2: @return a CSupplier object williamr@2: */ williamr@2: IMPORT_C static CSupplier* NewLC(); williamr@2: williamr@2: /** destructor */ williamr@2: virtual ~CSupplier(); williamr@2: williamr@2: /** Sets the output directory for any files generated by the CAF. williamr@2: williamr@2: @param aOutputDirectory The preferred location to store any output files williamr@2: */ williamr@2: IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory); williamr@2: williamr@2: /** Determines whether one of the CAF agents wants to import williamr@2: a file with the given mimetype williamr@2: williamr@2: If this function returns ETrue the application should use the CSupplier to williamr@2: create a ContentAccess::CImportFile session and import the file into CAF. williamr@2: williamr@2: @param aMimeType The mime type of the file determined by an Apparc recognition or transmission header information. williamr@2: @return ETrue if the mimetype is recognized by one of the CAF agents, EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType); williamr@2: williamr@2: williamr@2: /** Get HTTP download headers from the agents williamr@2: williamr@2: Some DRM schemes require specific headers to be present in the HTTP request williamr@2: header. This function allows a client to retrieve these headers from the williamr@2: agents so any download request will satisfy the criteria required by williamr@2: the HTTP server. williamr@2: williamr@2: @param aStringPool The string pool used by the HTTP session williamr@2: @param aRequestHeaders The agents will add any required fields to the headers williamr@2: */ williamr@2: IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const; williamr@2: williamr@2: williamr@2: /** Creates a new CImportFile object and allow the agent to generate the output files williamr@2: williamr@2: @param aMimeType This should be one of the mime types supported by CAF, IsImportSupported() can be used to check this. williamr@2: @param aImportMetaData Any additional information that may be useful for the agent performing the import. williamr@2: Ideally this will include the mime headers for the file about to be passed into CAF. williamr@2: @param aSuggestedFileName Suggested filename for the CAF agent to use when williamr@2: creating the output files, Details of the output files produced can be obtained using williamr@2: CImportFile::OutputFileL(). williamr@2: @return A CImportFile object to import the file. williamr@2: williamr@2: @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType williamr@2: */ williamr@2: IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName); williamr@2: williamr@2: /** Creates a new CImportFile object where the caller must provide file handles to store output files. williamr@2: williamr@2: This allows a server to store the output files within its own private directory. The CAF agent will write to the private directory williamr@2: using the file handle provided by the server. williamr@2: williamr@2: If the agent requires a new output file it will return KErrCANewFileHandleRequired from CImportFile::Write() or CImportFile::WriteComplete() williamr@2: The application performing the supply should provide the agent with a new file handle using CImportFile::ContinueWithNewOutputFile(); williamr@2: williamr@2: @param aMimeType This should be one of the mime types supported a CAF agent, IsImportSupported() can be used to check this. williamr@2: @param aImportMetaData Any additional information that may be useful for the agent performing the import. williamr@2: Ideally this will include the mime headers for the file about to be passed into CAF. williamr@2: @return A CImportFile object to import the file. williamr@2: williamr@2: @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType williamr@2: */ williamr@2: IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData); williamr@2: williamr@2: #ifndef REMOVE_CAF1 williamr@2: /** Import a file williamr@2: @param aMimeHeader Mime headers associated with the file to import williamr@2: @param aSuggestedFileName The application supplied name for any output file created by the agent williamr@2: @deprecated williamr@2: */ williamr@2: IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName); williamr@2: #endif williamr@2: williamr@2: private: williamr@2: CSupplier(); williamr@2: void ConstructL(); williamr@2: williamr@2: // Resolver used to figure out which CA agent is responsible for importing a particular file williamr@2: CAgentResolver* iAgentResolver; williamr@2: HBufC* iOutputDirectory; williamr@2: }; williamr@2: } williamr@2: williamr@2: #endif