epoc32/include/miutatch.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 // Copyright (c) 1998-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined (__MIUTATCH_H__)
       
    17 #define __MIUTATCH_H__
       
    18 
       
    19 
       
    20 #if !defined (__S32FILE_H__)
       
    21 #include <s32file.h>
       
    22 #endif
       
    23 
       
    24 const TInt KDataLineBufferLength = 4096;
       
    25 _LIT(KImcvAttachFormatStr, "%S(%d)%S");
       
    26 
       
    27 /**
       
    28 @internalTechnology
       
    29 @released
       
    30 */
       
    31 enum TImAttachmentFileState
       
    32 	{ 
       
    33 	EFileNotOpen, 
       
    34 	EFileIsOpen, 
       
    35 	EFileIsClosed,		
       
    36 	EFileIsCorrupt,		// UU data being decoded is corrupt
       
    37 	EFileIsIncomplete,	// file write failed
       
    38 	EFileFailedToOpen,	// can't open attach file
       
    39 	EFileTopIncomplete	// File is incomplete due to top
       
    40 	};
       
    41 
       
    42 class TImAttachmentFile		// utility class to handle file operations with Email attachments
       
    43 /**
       
    44 @internalAll
       
    45 @released
       
    46 */
       
    47     {
       
    48 public:
       
    49  	enum TImFileOpenMode
       
    50 		{
       
    51 		/**
       
    52 		File opened for read mode
       
    53 		*/
       
    54 		EImFileRead = 0,
       
    55 		/**
       
    56 		File opened for write mode
       
    57 		*/
       
    58 		EImFileWrite,
       
    59 		};   
       
    60 public:
       
    61     IMPORT_C TImAttachmentFile(RFs& aFileSession);  // constructor
       
    62     IMPORT_C ~TImAttachmentFile();  // destructor
       
    63 
       
    64     IMPORT_C TInt MakeDir (const TDesC& aDirPath);
       
    65     IMPORT_C TInt OpenFile (const TDesC& aDirPath ,const TDesC& aFileName );
       
    66     IMPORT_C TInt CreateFile (const TDesC& aDirPath ,const TDesC& aFileName );
       
    67     IMPORT_C TInt ReadFile (TDes8& rBuffer, TInt aNumBytes );
       
    68     IMPORT_C TInt WriteFile (const TDesC8& aBuffer);
       
    69     IMPORT_C TInt WriteFile (const TDesC16& aBuffer);
       
    70     IMPORT_C TInt CloseFile();
       
    71 	IMPORT_C TInt DeleteAttachment(const TDesC& aDirPath,const TDesC& aFileName);
       
    72 	
       
    73 	IMPORT_C void SetFileHandle(RFile& aFile,TImFileOpenMode aFileMode);
       
    74 						
       
    75 	TInt AppendValidFile(const TDesC& aDirPath, const TDesC& aFileName, TFileName& rFullFilePath);
       
    76 private:
       
    77 	void Reset();
       
    78 	TInt WriteFile ();
       
    79     TInt ReadFile ();
       
    80 	TInt FlushFile();
       
    81 	TPtrC8 SelectFileData(TInt& abufLen, TInt& aDataLen);
       
    82 
       
    83 private:
       
    84     RFs&		    iFileSession;
       
    85 	RFile			iFile;
       
    86 	TFileText		iFileText;
       
    87 	TFileName		iFullFilePath;
       
    88 	TBuf8<KDataLineBufferLength>		iDataLine;
       
    89 	TBool			iWritingToFile;
       
    90 	TInt			iSpaceOnCache;
       
    91 	TInt			iPositionInCache;
       
    92     };
       
    93 
       
    94 #endif