1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/caf/supplier.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,164 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 + @publishedPartner
1.27 + @released
1.28 +*/
1.29 +
1.30 +
1.31 +#ifndef __SUPPLIER_H__
1.32 +#define __SUPPLIER_H__
1.33 +
1.34 +#include <e32base.h>
1.35 +#include <e32std.h>
1.36 +#include <caf/caftypes.h>
1.37 +
1.38 +class RHTTPHeaders;
1.39 +class RStringPool;
1.40 +
1.41 +namespace ContentAccess
1.42 + {
1.43 + class CImportFile;
1.44 + class CMetaDataArray;
1.45 + class CAgentResolver;
1.46 + class MFileHandleProvider;
1.47 +
1.48 +#ifndef REMOVE_CAF1
1.49 + class CCafMimeHeader;
1.50 +#endif
1.51 +
1.52 + /**
1.53 + Used to import files using a content access agent. In the case of some
1.54 + DRM agents the import will be a transformation from an unprotected content type
1.55 + to a protected content type.
1.56 +
1.57 + It creates CImportFile objects to import files into a Content Access
1.58 + Agent. CSupplier uses it's CAgentResolver to determine which agent should receive
1.59 + the file based upon the mime type of the file.
1.60 +
1.61 + Clients can check if a mime type is supported by by calling the
1.62 + CSupplier::IsImportSupported() function.
1.63 +
1.64 + The CSupplier does not dynamically update it's list of agents so applications
1.65 + should not use a long term persistent instance of CSupplier.
1.66 +
1.67 + @publishedPartner
1.68 + @released
1.69 + */
1.70 + class CSupplier : public CBase
1.71 + {
1.72 + public:
1.73 + /** Create a new CSupplier
1.74 + @return a CSupplier object
1.75 + */
1.76 + IMPORT_C static CSupplier* NewL();
1.77 +
1.78 + /** Create a new CSupplier
1.79 + @return a CSupplier object
1.80 + */
1.81 + IMPORT_C static CSupplier* NewLC();
1.82 +
1.83 + /** destructor */
1.84 + virtual ~CSupplier();
1.85 +
1.86 + /** Sets the output directory for any files generated by the CAF.
1.87 +
1.88 + @param aOutputDirectory The preferred location to store any output files
1.89 + */
1.90 + IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory);
1.91 +
1.92 + /** Determines whether one of the CAF agents wants to import
1.93 + a file with the given mimetype
1.94 +
1.95 + If this function returns ETrue the application should use the CSupplier to
1.96 + create a ContentAccess::CImportFile session and import the file into CAF.
1.97 +
1.98 + @param aMimeType The mime type of the file determined by an Apparc recognition or transmission header information.
1.99 + @return ETrue if the mimetype is recognized by one of the CAF agents, EFalse otherwise.
1.100 + */
1.101 + IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType);
1.102 +
1.103 +
1.104 + /** Get HTTP download headers from the agents
1.105 +
1.106 + Some DRM schemes require specific headers to be present in the HTTP request
1.107 + header. This function allows a client to retrieve these headers from the
1.108 + agents so any download request will satisfy the criteria required by
1.109 + the HTTP server.
1.110 +
1.111 + @param aStringPool The string pool used by the HTTP session
1.112 + @param aRequestHeaders The agents will add any required fields to the headers
1.113 + */
1.114 + IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
1.115 +
1.116 +
1.117 + /** Creates a new CImportFile object and allow the agent to generate the output files
1.118 +
1.119 + @param aMimeType This should be one of the mime types supported by CAF, IsImportSupported() can be used to check this.
1.120 + @param aImportMetaData Any additional information that may be useful for the agent performing the import.
1.121 + Ideally this will include the mime headers for the file about to be passed into CAF.
1.122 + @param aSuggestedFileName Suggested filename for the CAF agent to use when
1.123 + creating the output files, Details of the output files produced can be obtained using
1.124 + CImportFile::OutputFileL().
1.125 + @return A CImportFile object to import the file.
1.126 +
1.127 + @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
1.128 + */
1.129 + IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName);
1.130 +
1.131 + /** Creates a new CImportFile object where the caller must provide file handles to store output files.
1.132 +
1.133 + This allows a server to store the output files within its own private directory. The CAF agent will write to the private directory
1.134 + using the file handle provided by the server.
1.135 +
1.136 + If the agent requires a new output file it will return KErrCANewFileHandleRequired from CImportFile::Write() or CImportFile::WriteComplete()
1.137 + The application performing the supply should provide the agent with a new file handle using CImportFile::ContinueWithNewOutputFile();
1.138 +
1.139 + @param aMimeType This should be one of the mime types supported a CAF agent, IsImportSupported() can be used to check this.
1.140 + @param aImportMetaData Any additional information that may be useful for the agent performing the import.
1.141 + Ideally this will include the mime headers for the file about to be passed into CAF.
1.142 + @return A CImportFile object to import the file.
1.143 +
1.144 + @leave KErrCANoAgent No agent supports the mime type supplied in aMimeType
1.145 + */
1.146 + IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData);
1.147 +
1.148 +#ifndef REMOVE_CAF1
1.149 + /** Import a file
1.150 + @param aMimeHeader Mime headers associated with the file to import
1.151 + @param aSuggestedFileName The application supplied name for any output file created by the agent
1.152 + @deprecated
1.153 + */
1.154 + IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName);
1.155 +#endif
1.156 +
1.157 + private:
1.158 + CSupplier();
1.159 + void ConstructL();
1.160 +
1.161 + // Resolver used to figure out which CA agent is responsible for importing a particular file
1.162 + CAgentResolver* iAgentResolver;
1.163 + HBufC* iOutputDirectory;
1.164 + };
1.165 + }
1.166 +
1.167 +#endif