epoc32/include/app/miutatch.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/app/miutatch.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#if !defined (__MIUTATCH_H__)
    1.20 +#define __MIUTATCH_H__
    1.21 +
    1.22 +
    1.23 +#if !defined (__S32FILE_H__)
    1.24 +#include <s32file.h>
    1.25 +#endif
    1.26 +
    1.27 +const TInt KDataLineBufferLength = 4096;
    1.28 +_LIT(KImcvAttachFormatStr, "%S(%d)%S");
    1.29 +
    1.30 +/**
    1.31 +@internalTechnology
    1.32 +@released
    1.33 +*/
    1.34 +enum TImAttachmentFileState
    1.35 +	{ 
    1.36 +	EFileNotOpen, 
    1.37 +	EFileIsOpen, 
    1.38 +	EFileIsClosed,		
    1.39 +	EFileIsCorrupt,		// UU data being decoded is corrupt
    1.40 +	EFileIsIncomplete,	// file write failed
    1.41 +	EFileFailedToOpen,	// can't open attach file
    1.42 +	EFileTopIncomplete	// File is incomplete due to top
    1.43 +	};
    1.44 +
    1.45 +class TImAttachmentFile		// utility class to handle file operations with Email attachments
    1.46 +/**
    1.47 +@internalAll
    1.48 +@released
    1.49 +*/
    1.50 +    {
    1.51 +public:
    1.52 + 	enum TImFileOpenMode
    1.53 +		{
    1.54 +		/**
    1.55 +		File opened for read mode
    1.56 +		*/
    1.57 +		EImFileRead = 0,
    1.58 +		/**
    1.59 +		File opened for write mode
    1.60 +		*/
    1.61 +		EImFileWrite,
    1.62 +		};   
    1.63 +public:
    1.64 +    IMPORT_C TImAttachmentFile(RFs& aFileSession);  // constructor
    1.65 +    IMPORT_C ~TImAttachmentFile();  // destructor
    1.66 +
    1.67 +    IMPORT_C TInt MakeDir (const TDesC& aDirPath);
    1.68 +    IMPORT_C TInt OpenFile (const TDesC& aDirPath ,const TDesC& aFileName );
    1.69 +    IMPORT_C TInt CreateFile (const TDesC& aDirPath ,const TDesC& aFileName );
    1.70 +    IMPORT_C TInt ReadFile (TDes8& rBuffer, TInt aNumBytes );
    1.71 +    IMPORT_C TInt WriteFile (const TDesC8& aBuffer);
    1.72 +    IMPORT_C TInt WriteFile (const TDesC16& aBuffer);
    1.73 +    IMPORT_C TInt CloseFile();
    1.74 +	IMPORT_C TInt DeleteAttachment(const TDesC& aDirPath,const TDesC& aFileName);
    1.75 +	
    1.76 +	IMPORT_C void SetFileHandle(RFile& aFile,TImFileOpenMode aFileMode);
    1.77 +						
    1.78 +	TInt AppendValidFile(const TDesC& aDirPath, const TDesC& aFileName, TFileName& rFullFilePath);
    1.79 +private:
    1.80 +	void Reset();
    1.81 +	TInt WriteFile ();
    1.82 +    TInt ReadFile ();
    1.83 +	TInt FlushFile();
    1.84 +	TPtrC8 SelectFileData(TInt& abufLen, TInt& aDataLen);
    1.85 +
    1.86 +private:
    1.87 +    RFs&		    iFileSession;
    1.88 +	RFile			iFile;
    1.89 +	TFileText		iFileText;
    1.90 +	TFileName		iFullFilePath;
    1.91 +	TBuf8<KDataLineBufferLength>		iDataLine;
    1.92 +	TBool			iWritingToFile;
    1.93 +	TInt			iSpaceOnCache;
    1.94 +	TInt			iPositionInCache;
    1.95 +    };
    1.96 +
    1.97 +#endif