epoc32/include/cmsvattachment.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 cmsvattachment.h
     1 // Copyright (c) 2004-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 #ifndef __CMSVATTACHMENT_H__
       
    17 #define __CMSVATTACHMENT_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <msvstd.h>
       
    21 
       
    22 /**
       
    23 Attachment Id for uniquely identifying attachments. 
       
    24 
       
    25 This is unique on a per message entry basis.
       
    26 
       
    27 @publishedAll
       
    28 @released
       
    29 */
       
    30 typedef TUint TMsvAttachmentId;
       
    31 
       
    32 /**
       
    33 DRM Mime type
       
    34 
       
    35 @publishedPartner
       
    36 @released
       
    37 */
       
    38 _LIT8(KEpocMimeTypeDrm,"X-Epoc/DRM.Receipt");
       
    39 
       
    40 class CMsvAttributeManager;
       
    41 
       
    42 /**
       
    43 Represents a single attachment and information about the attachment.
       
    44 
       
    45 This object is used to represent all types of attachments (file, linked file or message 
       
    46 entry). Note that some APIs may not be valid for particular attachment types. This is
       
    47 described under each method. It is the responsibility of the client to ensure that the
       
    48 data about the attachment is set such as its mime-type or size.
       
    49 
       
    50 @publishedAll
       
    51 @released
       
    52 */
       
    53 class CMsvAttachment : public CBase
       
    54 	{
       
    55 public:
       
    56 	/**
       
    57 	Enum to define the different types of attachments supported by messaging.
       
    58 	*/
       
    59 	enum TMsvAttachmentType
       
    60 		{
       
    61 		/**
       
    62 		File attachment. This is a file attachment that is copied into the message store.
       
    63 		*/
       
    64 		EMsvFile = 0,
       
    65 		/**
       
    66 		Linked file attachment. This is an attachment that is linked to using its file path,
       
    67 		this is not copied into the message store.
       
    68 		*/
       
    69 		EMsvLinkedFile,
       
    70 		/**
       
    71 		Message entry attachment. This is a message entry that is registered as an attachment.
       
    72 		*/
       
    73 		EMsvMessageEntry
       
    74 		};
       
    75 	
       
    76 public:
       
    77 	IMPORT_C static CMsvAttachment* NewL(TMsvAttachmentType aType);
       
    78 	IMPORT_C static CMsvAttachment* NewL(TMsvAttachmentType aType, TInt aSize, HBufC8* aMimeType, HBufC* aAttachmentName);
       
    79 	
       
    80 	IMPORT_C static CMsvAttachment* NewL(const CMsvAttachment& aAttachment);
       
    81 	
       
    82 	IMPORT_C ~CMsvAttachment();
       
    83 	
       
    84 	IMPORT_C TMsvAttachmentId Id() const;
       
    85 	IMPORT_C void SetId(TMsvAttachmentId aId);
       
    86 	
       
    87 	IMPORT_C TMsvAttachmentType Type() const;
       
    88 	
       
    89 	IMPORT_C TMsvId EntryAttachmentId() const;
       
    90 	void SetEntryAttachmentId(TMsvId aEntryId);
       
    91 	
       
    92 	IMPORT_C const TDesC& AttachmentName() const;
       
    93 	IMPORT_C void SetAttachmentNameL(const TDesC& aAttachmentName);
       
    94 	
       
    95 	IMPORT_C const TDesC& FilePath() const;
       
    96 	void SetFilePathL(const TDesC& aFilePath);
       
    97 	
       
    98 	IMPORT_C TInt Size() const;
       
    99 	IMPORT_C void SetSize(TInt aSize);
       
   100 	
       
   101 	IMPORT_C const TDesC8& MimeType() const;
       
   102 	IMPORT_C void SetMimeTypeL(const TDesC8& aMimeType);
       
   103 		
       
   104 	IMPORT_C TBool Complete() const;
       
   105 	IMPORT_C void SetComplete(TBool aComplete);
       
   106 	
       
   107 	IMPORT_C void SetDesC8AttributeL(TUid aAttributeId, const TDesC8& aAttribute);
       
   108 	IMPORT_C TInt GetDesC8Attribute(TUid aAttributeId, TPtrC8& aAttribute) const;
       
   109 	IMPORT_C void RemoveDesC8Attribute(TUid aAttributeId);
       
   110 	
       
   111 	IMPORT_C void SetIntAttributeL(TUid aAttributeId, TInt aAttribute);
       
   112 	IMPORT_C TInt GetIntAttribute(TUid aAttributeId, TInt& aAttribute) const;
       
   113 	IMPORT_C void RemoveIntAttribute(TUid aAttributeId);
       
   114 	
       
   115 	void InternalizeL(RReadStream& aStream);
       
   116 	void ExternalizeL(RWriteStream& aStream) const;
       
   117 	
       
   118 	TBool IsPathRequired() const;
       
   119 	
       
   120 private:
       
   121 	CMsvAttachment(TMsvAttachmentType aType);
       
   122 	CMsvAttachment(TMsvAttachmentType aType, TInt aSize, HBufC8* aMimeType, HBufC* aAttachmentName);
       
   123 	void ConstructL();
       
   124 	void ConstructL(const CMsvAttachment& aAttachment);
       
   125 	
       
   126 private:
       
   127 	/** The unique attachment Id. This is unique per message entry and is auto-assigned. */
       
   128 	TMsvAttachmentId iId;
       
   129 	
       
   130 	/** The attachment type. */
       
   131 	TMsvAttachmentType iType;
       
   132 	
       
   133 	/** Size of the attachment in bytes. */
       
   134 	TInt iSize;
       
   135 	
       
   136 	/** Descriptor indicating the mime type of the attachment. */
       
   137 	HBufC8* iMimeType;
       
   138 			
       
   139 	/** The full file path and file name of attachment files and linked files. */
       
   140 	HBufC* iFilePath;
       
   141 		
       
   142 	/** The message entry Id of the entry attachment. */
       
   143 	TMsvId iEntryId;
       
   144 	
       
   145 	/** Name of the attachment to identify to the attachment. */
       
   146 	HBufC* iAttachmentName;
       
   147 	
       
   148 	/** Attachment entry completeness flag. */
       
   149 	TBool iComplete;
       
   150 	
       
   151 	/** Attribute manager for handling the attributes for this attachment. */
       
   152 	CMsvAttributeManager* iAttributeManager;
       
   153 	
       
   154 	/** Flag to indicate whether a path needs to be added. */
       
   155 	TBool iNeedsPath;
       
   156 	};
       
   157 
       
   158 #endif // __CMSVATTACHMENT_H__