First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
26 #ifndef __SUPPLIER_H__
27 #define __SUPPLIER_H__
31 #include <caf/caftypes.h>
36 namespace ContentAccess
41 class MFileHandleProvider;
48 Used to import files using a content access agent. In the case of some
49 DRM agents the import will be a transformation from an unprotected content type
50 to a protected content type.
52 It creates CImportFile objects to import files into a Content Access
53 Agent. CSupplier uses it's CAgentResolver to determine which agent should receive
54 the file based upon the mime type of the file.
56 Clients can check if a mime type is supported by by calling the
57 CSupplier::IsImportSupported() function.
59 The CSupplier does not dynamically update it's list of agents so applications
60 should not use a long term persistent instance of CSupplier.
65 class CSupplier : public CBase
68 /** Create a new CSupplier
69 @return a CSupplier object
71 IMPORT_C static CSupplier* NewL();
73 /** Create a new CSupplier
74 @return a CSupplier object
76 IMPORT_C static CSupplier* NewLC();
81 /** Sets the output directory for any files generated by the CAF.
83 @param aOutputDirectory The preferred location to store any output files
85 IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory);
87 /** Determines whether one of the CAF agents wants to import
88 a file with the given mimetype
90 If this function returns ETrue the application should use the CSupplier to
91 create a ContentAccess::CImportFile session and import the file into CAF.
93 @param aMimeType The mime type of the file determined by an Apparc recognition or transmission header information.
94 @return ETrue if the mimetype is recognized by one of the CAF agents, EFalse otherwise.
96 IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType);
99 /** Get HTTP download headers from the agents
101 Some DRM schemes require specific headers to be present in the HTTP request
102 header. This function allows a client to retrieve these headers from the
103 agents so any download request will satisfy the criteria required by
106 @param aStringPool The string pool used by the HTTP session
107 @param aRequestHeaders The agents will add any required fields to the headers
109 IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
112 /** Creates a new CImportFile object and allow the agent to generate the output files
114 @param aMimeType This should be one of the mime types supported by CAF, IsImportSupported() can be used to check this.
115 @param aImportMetaData Any additional information that may be useful for the agent performing the import.
116 Ideally this will include the mime headers for the file about to be passed into CAF.
117 @param aSuggestedFileName Suggested filename for the CAF agent to use when
118 creating the output files, Details of the output files produced can be obtained using
119 CImportFile::OutputFileL().
120 @return A CImportFile object to import the file.
122 @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
124 IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName);
126 /** Creates a new CImportFile object where the caller must provide file handles to store output files.
128 This allows a server to store the output files within its own private directory. The CAF agent will write to the private directory
129 using the file handle provided by the server.
131 If the agent requires a new output file it will return KErrCANewFileHandleRequired from CImportFile::Write() or CImportFile::WriteComplete()
132 The application performing the supply should provide the agent with a new file handle using CImportFile::ContinueWithNewOutputFile();
134 @param aMimeType This should be one of the mime types supported a CAF agent, IsImportSupported() can be used to check this.
135 @param aImportMetaData Any additional information that may be useful for the agent performing the import.
136 Ideally this will include the mime headers for the file about to be passed into CAF.
137 @return A CImportFile object to import the file.
139 @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
141 IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData);
145 @param aMimeHeader Mime headers associated with the file to import
146 @param aSuggestedFileName The application supplied name for any output file created by the agent
149 IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName);
156 // Resolver used to figure out which CA agent is responsible for importing a particular file
157 CAgentResolver* iAgentResolver;
158 HBufC* iOutputDirectory;