pimappservices/calendar/inc/calattachment.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2006-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 #ifndef __CALATTACHMENT_H__
       
    17 #define __CALATTACHMENT_H__
       
    18 
       
    19 #include <f32file.h>
       
    20 
       
    21 class CAgnAttachment;
       
    22 class CAgnAttachmentFile;
       
    23 class CCalAttachmentFile;
       
    24 class CCalSessionImpl;
       
    25 
       
    26 /** The maximum length of a CCalAttachment label. 
       
    27 This sets a limit on the descriptor passed into CCalAttachment::SetLabelL().
       
    28 @publishedPartner
       
    29 @released
       
    30 */
       
    31 const TInt KCalAttachmentMaxLabelLength = 256;
       
    32 
       
    33 /** The maximum length of a CCalAttachment MIME type. 
       
    34 This sets a limit on the descriptor passed into CCalAttachment::SetMimeTypeL().
       
    35 @publishedPartner
       
    36 @released
       
    37 */
       
    38 const TInt KCalAttachmentMaxMimeTypeLength = 256;
       
    39 
       
    40 /**
       
    41 Class representing a calendar attachment. This allows access to the attachment content itself and associated
       
    42 metadata.
       
    43 
       
    44 This can be either a URI (RFC 3986) or a file attachment, which must be specified on creation.
       
    45 A URI attachment requires a descriptor containing the URI.
       
    46 A file attachment can be specified as either a descriptor containing the binary data or as a file handle.
       
    47 
       
    48 Attachment data (i.e. URI, binary data) cannot be changed once an attachment has been created. 
       
    49 This does not include metadata properties that are modifiable through the CCalAttachment APIs.
       
    50 
       
    51 File attachments may also have only a content ID on creation. This applies in cases where a vCalendar or 
       
    52 iCalendar (RFC 2445) is imported as part of a message. The content ID refers to the attachment file 
       
    53 located elsewhere in the message. The attachment data must be set using CCalAttachment::SetResourceL 
       
    54 before the attachment can be stored. 
       
    55 The content ID can be changed once it has been set.
       
    56 There is more information about content IDs in the MIME specification (RFC2045).
       
    57 
       
    58 @publishedPartner
       
    59 @released
       
    60 */
       
    61 NONSHARABLE_CLASS(CCalAttachment) : public CBase
       
    62 	{
       
    63 public:
       
    64 	/** Calendar attachment type.
       
    65 	@publishedPartner
       
    66 	@released
       
    67 	*/
       
    68 	enum TType
       
    69 		{
       
    70 		/** A URI or link to an attachment, e.g. a file or HTTP server address. */
       
    71 		EUri,
       
    72 		/** A file attachment to be stored in the calendar, either binary data or a file handle. */
       
    73 		EFile,
       
    74 		};
       
    75 	
       
    76 	/** Calendar attachment attributes.
       
    77 	Note that the first 8 bits of this enumeration (up to 0x0080) are reserved for future use.
       
    78 	@publishedPartner
       
    79 	@released
       
    80 	*/
       
    81 	enum TAttributes
       
    82 		{
       
    83 		/** If the EExportInline flag is set on a file attachment then it will be exported 
       
    84 			inline as binary data.
       
    85 			
       
    86 			Note that, by default:
       
    87 			
       
    88 			- Any file attachments created using binary data will have the EExportInline flag set. 
       
    89 			
       
    90 			- Any file attachments created using a file handle will NOT have the EExportInline flag set,
       
    91 			i.e the content of the file will not be exported inline as binaries unless the client call
       
    92 			SetAttribute(EExportInline) after an attachment object has been instantiated.
       
    93 
       
    94 			- If this flag is set but the attachment has a content ID, then the content ID will be exported instead.
       
    95 			
       
    96 			- This flag has no effect for URI attachments.
       
    97 			
       
    98 			@see EFile
       
    99 			@see EUri
       
   100 			*/
       
   101 		EExportInline = 0x0001,
       
   102 		};
       
   103 		
       
   104 	IMPORT_C static CCalAttachment* NewFileL(TDesC8* aBinaryData); // takes ownership
       
   105 	IMPORT_C static CCalAttachment* NewFileL(RFile& aFileHandle); // takes ownership
       
   106 	IMPORT_C static CCalAttachment* NewFileByContentIdL(const TDesC8& aContentId);
       
   107 	IMPORT_C static CCalAttachment* NewUriL(const TDesC8& aUri);
       
   108 	
       
   109 	IMPORT_C ~CCalAttachment();
       
   110 
       
   111 	IMPORT_C TType Type() const;
       
   112 	IMPORT_C const TDesC8& Value() const; 
       
   113 
       
   114 	IMPORT_C void SetMimeTypeL(const TDesC8& aContentMimeType);
       
   115 	IMPORT_C const TDesC8& MimeType() const; 
       
   116 
       
   117 	IMPORT_C void SetLabelL(const TDesC& aLabel); 
       
   118 	IMPORT_C const TDesC& Label() const; 
       
   119 
       
   120 	IMPORT_C void SetAttribute(TUint16 aAttribute); // uses values from TAttributes
       
   121 	IMPORT_C void ClearAttribute(TUint16 aAttribute); // uses values from TAttributes
       
   122 	IMPORT_C TBool IsAttributeSet(TUint16 aAttribute) const; // uses values from TAttributes
       
   123 
       
   124 	IMPORT_C CCalAttachmentFile* FileAttachment() const;
       
   125 	
       
   126 	static CCalAttachment* NewL(CAgnAttachment& aAttachment, CCalSessionImpl& aSessionImpl);
       
   127 	CAgnAttachment& Impl() const;
       
   128 
       
   129 private:
       
   130 	CCalAttachment();
       
   131 	CCalAttachment(CAgnAttachment& aAttachment);
       
   132 	void ConstructL(TType aType, TDesC8* aData);
       
   133 	void CreateFileAttachmentImplIfRequiredL(CCalSessionImpl* aSessionImpl);
       
   134 
       
   135 private:
       
   136 	CAgnAttachment*		iAttachmentImpl;
       
   137 	CCalAttachmentFile*	iFileAttachment;
       
   138 	};
       
   139 
       
   140 /**
       
   141 Class providing an interface to access the file attachment functionality of a CCalAttachment object. 
       
   142 
       
   143 This can be accessed using the CCalAttachment::FileAttachment function on any attachment of 
       
   144 type CCalAttachment::EFile.
       
   145 
       
   146 @publishedPartner
       
   147 @released
       
   148 */
       
   149 NONSHARABLE_CLASS(CCalAttachmentFile) : public CBase
       
   150 	{
       
   151 public:
       
   152 	IMPORT_C void SetContentIdL(const TDesC8& aContentId);
       
   153 	IMPORT_C const TDesC8& ContentId() const;
       
   154 	
       
   155 	IMPORT_C void SetDriveL(const TDesC& aDrive); 
       
   156 	IMPORT_C TDriveName Drive() const; 
       
   157 
       
   158 	IMPORT_C TInt Size() const;
       
   159 	
       
   160 	IMPORT_C void SetLastModifiedTimeUtc(const TTime& aUtcTime); 
       
   161 	IMPORT_C const TTime& LastModifiedTimeUtc() const; 
       
   162 
       
   163 	IMPORT_C void SetResourceL(RFile& aFileHandle);
       
   164 	IMPORT_C void FetchFileHandleL(RFile& aFileHandle) const;
       
   165 	IMPORT_C void LoadBinaryDataL();
       
   166 
       
   167 	CCalAttachmentFile(CCalAttachment& aFile, CCalSessionImpl* aCalSessionImpl);
       
   168 	~CCalAttachmentFile();
       
   169 	
       
   170 private:
       
   171 	CAgnAttachmentFile* iAttachmentImpl; // not owned
       
   172 	CCalSessionImpl* iCalSessionImpl; // not owned
       
   173 	};
       
   174 	
       
   175 #endif // __CALATTACHMENT_H__