contentmgmt/contentaccessfwfordrm/inc/supplier.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     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 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 
       
    28 #ifndef __SUPPLIER_H__
       
    29 #define __SUPPLIER_H__
       
    30 
       
    31 #include <e32base.h>
       
    32 #include <e32std.h>
       
    33 #include <caf/caftypes.h>
       
    34 
       
    35 class RHTTPHeaders;
       
    36 class RStringPool;
       
    37 
       
    38 namespace ContentAccess 
       
    39 	{
       
    40 	class CImportFile;
       
    41 	class CMetaDataArray;
       
    42 	class CAgentResolver;
       
    43 	class MFileHandleProvider;
       
    44 
       
    45 #ifndef REMOVE_CAF1
       
    46 	class CCafMimeHeader;
       
    47 #endif
       
    48 
       
    49 	/** 
       
    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.
       
    53 	 
       
    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.
       
    57 	
       
    58 	Clients can check if a mime type is supported by by calling the
       
    59 	CSupplier::IsImportSupported() function.
       
    60 	
       
    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.
       
    63 	
       
    64 	@publishedPartner
       
    65 	@released
       
    66 	*/
       
    67 	class CSupplier : public CBase
       
    68 		{ 
       
    69 	public:
       
    70 		/** Create a new CSupplier 
       
    71 		@return a CSupplier object
       
    72 		*/
       
    73 		IMPORT_C static CSupplier* NewL();
       
    74 
       
    75 		/** Create a new CSupplier 
       
    76 		@return a CSupplier object
       
    77 		*/
       
    78 		IMPORT_C static CSupplier* NewLC();
       
    79 
       
    80 		/** destructor */
       
    81 		virtual ~CSupplier();
       
    82 
       
    83 		/** Sets the output directory for any files generated by the CAF.
       
    84 		
       
    85 		@param aOutputDirectory The preferred location to store any output files
       
    86 		*/
       
    87 		IMPORT_C void SetOutputDirectoryL(const TDesC& aOutputDirectory);
       
    88 
       
    89 		/** Determines whether one of the CAF agents wants to import
       
    90 		a file with the given mimetype
       
    91 
       
    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.
       
    94 		
       
    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.
       
    97 		*/
       
    98 		IMPORT_C TBool IsImportSupported(const TDesC8& aMimeType);
       
    99 
       
   100 		
       
   101 		/** Get HTTP download headers from the agents
       
   102 
       
   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 
       
   106 		the HTTP server.
       
   107 
       
   108 		@param aStringPool The string pool used by the HTTP session
       
   109 		@param aRequestHeaders The agents will add any required fields to the headers
       
   110 		*/
       
   111 		IMPORT_C void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
       
   112 		
       
   113 		
       
   114 		/** Creates a new CImportFile object and allow the agent to generate the output files 
       
   115 		
       
   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.
       
   123 		
       
   124 		@leave KErrCANoAgent		No agent supports the mime type supplied in aMimeType
       
   125 		*/
       
   126 		IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData, const TDesC& aSuggestedFileName);
       
   127 
       
   128 		/** Creates a new CImportFile object where the caller must provide file handles to store output files. 
       
   129 		
       
   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.
       
   132 
       
   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();
       
   135 		
       
   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.
       
   140 		
       
   141 		@leave KErrCANoAgent		No agent supports the mime type supplied in aMimeType
       
   142 		*/
       
   143 		IMPORT_C CImportFile* ImportFileL(const TDesC8& aMimeType, const CMetaDataArray& aImportMetaData);
       
   144 
       
   145 #ifndef REMOVE_CAF1
       
   146 		/** Import a file
       
   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
       
   149 		@deprecated 
       
   150 		*/
       
   151 		IMPORT_C CImportFile* ImportFileL(CCafMimeHeader &aMimeHeader, const TDesC &aSuggestedFileName);
       
   152 #endif
       
   153 
       
   154 	private:	
       
   155 		CSupplier();
       
   156 		void ConstructL();
       
   157 
       
   158 		// Resolver used to figure out which CA agent is responsible for importing a particular file
       
   159 		CAgentResolver* iAgentResolver;
       
   160 		HBufC* iOutputDirectory;
       
   161 		};
       
   162 	}
       
   163 
       
   164 #endif