os/security/contentmgmt/contentaccessfwfordrm/inc/supplier.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @publishedPartner
    22  @released
    23 */
    24 
    25 
    26 #ifndef __SUPPLIER_H__
    27 #define __SUPPLIER_H__
    28 
    29 #include <e32base.h>
    30 #include <e32std.h>
    31 #include <caf/caftypes.h>
    32 
    33 class RHTTPHeaders;
    34 class RStringPool;
    35 
    36 namespace ContentAccess 
    37 	{
    38 	class CImportFile;
    39 	class CMetaDataArray;
    40 	class CAgentResolver;
    41 	class MFileHandleProvider;
    42 
    43 #ifndef REMOVE_CAF1
    44 	class CCafMimeHeader;
    45 #endif
    46 
    47 	/** 
    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.
    51 	 
    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.
    55 	
    56 	Clients can check if a mime type is supported by by calling the
    57 	CSupplier::IsImportSupported() function.
    58 	
    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.
    61 	
    62 	@publishedPartner
    63 	@released
    64 	*/
    65 	class CSupplier : public CBase
    66 		{ 
    67 	public:
    68 		/** Create a new CSupplier 
    69 		@return a CSupplier object
    70 		*/
    71 		IMPORT_C static CSupplier* NewL();
    72 
    73 		/** Create a new CSupplier 
    74 		@return a CSupplier object
    75 		*/
    76 		IMPORT_C static CSupplier* NewLC();
    77 
    78 		/** destructor */
    79 		virtual ~CSupplier();
    80 
    81 		/** Sets the output directory for any files generated by the CAF.
    82 		
    83 		@param aOutputDirectory The preferred location to store any output files
    84 		*/
    85 		IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory);
    86 
    87 		/** Determines whether one of the CAF agents wants to import
    88 		a file with the given mimetype
    89 
    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.
    92 		
    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.
    95 		*/
    96 		IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType);
    97 
    98 		
    99 		/** Get HTTP download headers from the agents
   100 
   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 
   104 		the HTTP server.
   105 
   106 		@param aStringPool The string pool used by the HTTP session
   107 		@param aRequestHeaders The agents will add any required fields to the headers
   108 		*/
   109 		IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
   110 		
   111 		
   112 		/** Creates a new CImportFile object and allow the agent to generate the output files 
   113 		
   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.
   121 		
   122 		@leave KErrCANoAgent		No agent supports the mime type supplied in aMimeType
   123 		*/
   124 		IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName);
   125 
   126 		/** Creates a new CImportFile object where the caller must provide file handles to store output files. 
   127 		
   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.
   130 
   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();
   133 		
   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.
   138 		
   139 		@leave KErrCANoAgent		No agent supports the mime type supplied in aMimeType
   140 		*/
   141 		IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData);
   142 
   143 #ifndef REMOVE_CAF1
   144 		/** Import a file
   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
   147 		@deprecated 
   148 		*/
   149 		IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName);
   150 #endif
   151 
   152 	private:	
   153 		CSupplier();
   154 		void ConstructL();
   155 
   156 		// Resolver used to figure out which CA agent is responsible for importing a particular file
   157 		CAgentResolver* iAgentResolver;
   158 		HBufC* iOutputDirectory;
   159 		};
   160 	}
   161 
   162 #endif