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