filehandling/fileconverterfw/INC/CONARC.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__CONARC_H__)
       
    17 #define __CONARC_H__
       
    18 
       
    19 #if !defined(__E32BASE_H__)
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 #if !defined(__APMSTD_H__)
       
    23 #include <apmstd.h>
       
    24 #endif
       
    25 
       
    26 //
       
    27 // base interface for converters
       
    28 //
       
    29 
       
    30 /**
       
    31 @publishedAll
       
    32 @released
       
    33 */
       
    34 const TInt KUidConverterToBase64=0x10000721;
       
    35 /**
       
    36 @publishedAll
       
    37 @released
       
    38 */
       
    39 const TInt KUidConverterFromBase64=0x100011C5;
       
    40 /**
       
    41 @publishedAll
       
    42 @released
       
    43 */
       
    44 const TInt KUidPlainTextToQuotedPrintableConverter=0x10001826;
       
    45 /**
       
    46 @publishedAll
       
    47 @released
       
    48 */
       
    49 const TInt KUidQuotedPrintableToPlainTextConverter=0x10001825;
       
    50 /**
       
    51 @publishedAll
       
    52 @released
       
    53 */
       
    54 const TInt KUidETextToPlainTextConverter=
       
    55 #if defined(ETEXT_CONVERTER_UIDS_CORRECTED)
       
    56 	0x100040c8;
       
    57 #else
       
    58 	0x100040c7;
       
    59 #endif
       
    60  
       
    61 /**
       
    62 @publishedAll
       
    63 @released
       
    64 */
       
    65 const TInt KUidPlainTextToETextConverter=
       
    66 #if defined(ETEXT_CONVERTER_UIDS_CORRECTED)
       
    67 	0x100040c7;
       
    68 #else
       
    69 	0x100040c8;
       
    70 #endif
       
    71  
       
    72 /**
       
    73 @publishedAll
       
    74 @released
       
    75 */
       
    76 #ifdef _UNICODE
       
    77 #define KUidConverterDll KUidConverterDll16
       
    78 #else
       
    79 #define KUidConverterDll KUidConverterDll8
       
    80 #endif
       
    81 
       
    82 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    83 /**
       
    84 @internalComponent
       
    85 @deprecated
       
    86 */
       
    87 const TInt KUidConverterDllValue8=0x10000C61;
       
    88 
       
    89 /**
       
    90 @internalComponent
       
    91 @deprecated
       
    92 */
       
    93 const TUid KUidConverterDll8={KUidConverterDllValue8};
       
    94 
       
    95 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    96 
       
    97 //gmahe. This needs to be promoted to publishedAll.
       
    98 /**
       
    99 @internalComponent
       
   100 */
       
   101 const TInt KUidConverterInfoFileValue=0x10000C62;
       
   102 
       
   103 /**
       
   104 @publishedAll
       
   105 @released
       
   106 */
       
   107 const TUid KUidConverterInfoFile={KUidConverterInfoFileValue};
       
   108 
       
   109 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   110 /**
       
   111 @internalComponent
       
   112 */
       
   113 const TInt KUidConverterInfoStreamValue=0x10000CD0;
       
   114 
       
   115 /**
       
   116 @internalComponent
       
   117 */
       
   118 const TUid KUidConverterInfoStream={KUidConverterInfoStreamValue};
       
   119 
       
   120 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
   121 /**
       
   122 The UID2 of converter-type DLLs.
       
   123 @publishedAll
       
   124 @released
       
   125 */
       
   126 const TUid KUidConverterDll16={0x10003A30};
       
   127 
       
   128 /**
       
   129 The extension of converter information files.
       
   130 @publishedAll
       
   131 @released
       
   132 */
       
   133 _LIT(KConverterInfoFileExtension,".CNF");
       
   134 /**
       
   135 The extension of converter DLLs.
       
   136 @publishedAll
       
   137 @released
       
   138 */
       
   139 _LIT(KConverterDllExtension,".CNV");
       
   140 
       
   141 
       
   142 class MConverterUiObserver
       
   143 /**
       
   144 Interface implemented by the client of a conversion operation to observe conversion 
       
   145 progress.
       
   146 
       
   147 @see CConverterBase2
       
   148 @publishedAll 
       
   149 @released
       
   150 */
       
   151 	{
       
   152 public:
       
   153 	/** Describes the result of a conversion operation. */
       
   154 	enum TResult
       
   155 		{
       
   156 		/** Conversion succeeded. */
       
   157 		ESuccess,
       
   158 		/** Conversion partially succeeded. */
       
   159 		EPartialSuccess,
       
   160 		/** Conversion failed. */
       
   161 		EFailure
       
   162 		};
       
   163 	/** Describes the actions that the converter should take. */
       
   164 	enum TAction
       
   165 		{
       
   166 		/** Keep already converted data. */
       
   167 		ERetain,
       
   168 		/** Delete converted data. */
       
   169 		ERemove,
       
   170 		/** Reconvert data. */
       
   171 		ERepeat
       
   172 		}; 
       
   173 public:
       
   174 	/** Gets the maximum number of steps that the conversion operation can take. 
       
   175 	
       
   176 	The conversion may complete in less than this number of steps (for example 
       
   177 	if an error occurs or the action is cancelled). 
       
   178 	
       
   179 	Each step is a call to CConverterBase2::DoConvert(), although during synchronous 
       
   180 	conversions this is transparent to the client code.
       
   181 	
       
   182 	@param aMax Maximum number of conversion steps.
       
   183 	@param aObject Index that identifies an embedded object when one is being converted. */
       
   184 	virtual void MaxSteps(TInt aMax, TInt aObject)=0;
       
   185 	/** Alerts the client to an error in conversion.
       
   186 	
       
   187 	@param aResult A TResult value indicating the conversion state.
       
   188 	@param aObject Index that identifies an embedded object when one is being converted.
       
   189 	@return A TAction value that indicates what action the converter should take. */
       
   190 	virtual TInt Result(TInt aResult, TInt aObject)=0;
       
   191 	/** Queries the client for a password in order to access the data.
       
   192 	
       
   193 	@param aClue Data with a meaning that is specific to each converter: it could for 
       
   194 	example indicate where the password is stored.
       
   195 	@return The password entered. */
       
   196 	virtual HBufC* QueryPasswordL(const TDesC& aClue)=0;
       
   197 	IMPORT_C virtual void Reserved1_Conv_Obs();
       
   198 	};
       
   199 
       
   200 
       
   201 class CConverterBase : public CBase
       
   202 /** For Ecom Style Converters i.e.,for v9.1 and above CConverterBase2 should be used.
       
   203 
       
   204 Polymorphic interface for converters from one data format to another.
       
   205 
       
   206 Clients use this interface to access data converters. The implementator of 
       
   207 a data converter derives a class from this in which to implement the appropriate 
       
   208 conversion functionality.
       
   209 
       
   210 The interface offers conversions between files, and between objects that support 
       
   211 the stream interfaces, e.g. stream stores.
       
   212 
       
   213 There are two flavours of conversion methods:
       
   214 
       
   215 the synchronous interfaces, ConvertL() and ConvertObjectL(), which perform 
       
   216 the specified conversion and then return
       
   217 
       
   218 the asynchronous interfaces, ConvertAL() and ConvertObjectAL(), which initialise 
       
   219 the converter object, and allow the client code to call DoConvertL() a number 
       
   220 of times until the conversion is complete or abandoned.
       
   221 
       
   222 @see CConverterBase2
       
   223 @publishedAll
       
   224 @released  */
       
   225 	{
       
   226 public:
       
   227 	/** Bitmask values that describe the capabilities of the converter. */
       
   228 	enum TCapability
       
   229 		{
       
   230 		/** The converter can convert files. */
       
   231 		EConvertsFiles=0x01,
       
   232 		/** The converter can convert stream objects. */
       
   233 		EConvertsObjects=0x02,
       
   234 		/** The converter can extract embedded objects. */
       
   235 		EConvertsExtract=0x04
       
   236 		};
       
   237 public:
       
   238 	IMPORT_C virtual void ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver=NULL); // These default to calling the async versions in a loop
       
   239 	IMPORT_C virtual void ConvertObjectL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL);
       
   240 	IMPORT_C virtual void ConvertAL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver=NULL); // these default to leaving with KErrNotSupported
       
   241 	IMPORT_C virtual void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL); // these default to leaving with KErrNotSupported
       
   242 	IMPORT_C virtual TBool DoConvertL(); // these default to leaving with KErrNotSupported
       
   243 	/** Gets the converter's UID.
       
   244 	
       
   245 	@return Converter's UID */
       
   246 	virtual TUid Uid() =0;
       
   247 	IMPORT_C virtual TInt Capabilities(); // defaults to "everything"
       
   248 	IMPORT_C virtual void CancelConvert(); // for any cleanup
       
   249 	IMPORT_C virtual CConverterBase* EmbeddedObjectL(TDataType& aType);
       
   250 	IMPORT_C virtual TBool GetEmbeddedFileName(TFileName& aFileName);
       
   251 	IMPORT_C virtual void ExtendedInterfaceL(TUid aInterfaceUid, CBase*& aInterface); 
       
   252 	};
       
   253 
       
   254 
       
   255 class CConverterLibrary : public CBase
       
   256 /** A converter DLL's factory for individual CConverterBase-derived objects.
       
   257 
       
   258 The implementor of a converter DLL should implement this class. 
       
   259 
       
   260 @publishedAll 
       
   261 @deprecated */
       
   262 	{
       
   263 public:
       
   264 	/** Creates and returns an instance of the converter with the specified UID.
       
   265 	
       
   266 	This class should not allocate any resources that are not returned to the 
       
   267 	caller.
       
   268 	
       
   269 	@param aUid UID of the converter to create
       
   270 	@return The specified converter. If the converter does not implement a converter 
       
   271 	associated with the UID, then it should return NULL. */
       
   272 	virtual CConverterBase* Converter(TUid aUid)=0;	// passes ownership
       
   273 	};
       
   274 
       
   275 class CConverterBase2 : public CConverterBase
       
   276 /** Base Class for Ecom Style Converters
       
   277 The methods in CConverterBase2 are inherited from CConverterBase
       
   278 
       
   279 There are two flavours of conversion methods:
       
   280 
       
   281 the synchronous interfaces, ConvertL() and ConvertObjectL(), which perform 
       
   282 the specified conversion and then return
       
   283 
       
   284 the asynchronous interfaces, ConvertAL() and ConvertObjectAL(), which initialise 
       
   285 the converter object, and allow the client code to call DoConvertL() a number 
       
   286 of times until the conversion is complete or abandoned.
       
   287 
       
   288 @publishedAll
       
   289 @released  */
       
   290 	{
       
   291 public:
       
   292 	static CConverterBase2* CreateConverterL(TUid aImplUid);
       
   293 	IMPORT_C virtual ~CConverterBase2(); 
       
   294 	IMPORT_C virtual void ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver=NULL); // These default to calling the async versions in a loop
       
   295 	IMPORT_C virtual void ConvertObjectL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL);
       
   296 	IMPORT_C virtual void ConvertAL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver=NULL); // these default to leaving with KErrNotSupported
       
   297 	IMPORT_C virtual void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL); // these default to leaving with KErrNotSupported
       
   298 	IMPORT_C virtual TBool DoConvertL(); // these default to leaving with KErrNotSupported
       
   299 	virtual  TUid Uid()=0;
       
   300 	IMPORT_C virtual TInt Capabilities(); // defaults to "everything"
       
   301 	IMPORT_C virtual void CancelConvert(); // for any cleanup
       
   302 	IMPORT_C virtual CConverterBase* EmbeddedObjectL(TDataType& aType);
       
   303 	IMPORT_C virtual TBool GetEmbeddedFileName(TFileName& aFileName);
       
   304 	IMPORT_C virtual void ExtendedInterfaceL(TUid aInterfaceUid, CBase*& aInterface);
       
   305 	IMPORT_C virtual void Reserved_1();
       
   306 	IMPORT_C virtual void Reserved_2();
       
   307 private:
       
   308 	TUid iDestructionKey;
       
   309 	TInt iSpare;
       
   310 	};
       
   311 #endif