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.
28 #ifndef __SUPPLIER_H__
29 #define __SUPPLIER_H__
33 #include <caf/caftypes.h>
38 namespace ContentAccess
43 class MFileHandleProvider;
50 Used to import files using a content access agent. In the case of some
51 DRM agents the import will be a transformation from an unprotected content type
52 to a protected content type.
54 It creates CImportFile objects to import files into a Content Access
55 Agent. CSupplier uses it's CAgentResolver to determine which agent should receive
56 the file based upon the mime type of the file.
58 Clients can check if a mime type is supported by by calling the
59 CSupplier::IsImportSupported() function.
61 The CSupplier does not dynamically update it's list of agents so applications
62 should not use a long term persistent instance of CSupplier.
67 class CSupplier : public CBase
70 /** Create a new CSupplier
71 @return a CSupplier object
73 IMPORT_C static CSupplier* NewL();
75 /** Create a new CSupplier
76 @return a CSupplier object
78 IMPORT_C static CSupplier* NewLC();
83 /** Sets the output directory for any files generated by the CAF.
85 @param aOutputDirectory The preferred location to store any output files
87 IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory);
89 /** Determines whether one of the CAF agents wants to import
90 a file with the given mimetype
92 If this function returns ETrue the application should use the CSupplier to
93 create a ContentAccess::CImportFile session and import the file into CAF.
95 @param aMimeType The mime type of the file determined by an Apparc recognition or transmission header information.
96 @return ETrue if the mimetype is recognized by one of the CAF agents, EFalse otherwise.
98 IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType);
101 /** Get HTTP download headers from the agents
103 Some DRM schemes require specific headers to be present in the HTTP request
104 header. This function allows a client to retrieve these headers from the
105 agents so any download request will satisfy the criteria required by
108 @param aStringPool The string pool used by the HTTP session
109 @param aRequestHeaders The agents will add any required fields to the headers
111 IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
114 /** Creates a new CImportFile object and allow the agent to generate the output files
116 @param aMimeType This should be one of the mime types supported by CAF, IsImportSupported() can be used to check this.
117 @param aImportMetaData Any additional information that may be useful for the agent performing the import.
118 Ideally this will include the mime headers for the file about to be passed into CAF.
119 @param aSuggestedFileName Suggested filename for the CAF agent to use when
120 creating the output files, Details of the output files produced can be obtained using
121 CImportFile::OutputFileL().
122 @return A CImportFile object to import the file.
124 @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
126 IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName);
128 /** Creates a new CImportFile object where the caller must provide file handles to store output files.
130 This allows a server to store the output files within its own private directory. The CAF agent will write to the private directory
131 using the file handle provided by the server.
133 If the agent requires a new output file it will return KErrCANewFileHandleRequired from CImportFile::Write() or CImportFile::WriteComplete()
134 The application performing the supply should provide the agent with a new file handle using CImportFile::ContinueWithNewOutputFile();
136 @param aMimeType This should be one of the mime types supported a CAF agent, IsImportSupported() can be used to check this.
137 @param aImportMetaData Any additional information that may be useful for the agent performing the import.
138 Ideally this will include the mime headers for the file about to be passed into CAF.
139 @return A CImportFile object to import the file.
141 @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
143 IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData);
147 @param aMimeHeader Mime headers associated with the file to import
148 @param aSuggestedFileName The application supplied name for any output file created by the agent
151 IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName);
158 // Resolver used to figure out which CA agent is responsible for importing a particular file
159 CAgentResolver* iAgentResolver;
160 HBufC* iOutputDirectory;