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