|
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 __AGMATTACHMENT_H__ |
|
17 #define __AGMATTACHMENT_H__ |
|
18 |
|
19 #include "calattachment.h" |
|
20 #include "calcommon.h" |
|
21 #include "agmcontent.h" |
|
22 |
|
23 class RReadStream; |
|
24 class RWriteStream; |
|
25 |
|
26 typedef TUint32 TCalAttachmentUid; |
|
27 |
|
28 _LIT(KDefaultAttachmentDrive, "c:"); |
|
29 |
|
30 // used to pass data from client to server when storing a binary data attachment. |
|
31 struct TAttachmentData |
|
32 { |
|
33 TCalLocalUid iLocalUid; |
|
34 TInt iAttachmentIndex; |
|
35 TDriveName iDrive; |
|
36 }; |
|
37 |
|
38 NONSHARABLE_CLASS(AttachmentFactory) |
|
39 { |
|
40 public: |
|
41 IMPORT_C static CAgnAttachment* NewAttachmentL(RReadStream& aStream); |
|
42 IMPORT_C static CAgnAttachment* CloneL(const CAgnAttachment& aAttachment); |
|
43 IMPORT_C static CAgnAttachment* NewAttachmentL(CCalContent::TDisposition aType); |
|
44 }; |
|
45 |
|
46 /** |
|
47 Base class for internal representation of an attachment object. |
|
48 |
|
49 The following data is inherited from CAgnContent: |
|
50 TDesC8* iContent; |
|
51 TDesC8* iMimeType; |
|
52 CCalContent::TDisposition iType; |
|
53 |
|
54 @internalComponent |
|
55 */ |
|
56 NONSHARABLE_CLASS(CAgnAttachment) : public CAgnContent |
|
57 { |
|
58 public: |
|
59 // internal flags |
|
60 enum |
|
61 { |
|
62 /** If this is true then the CAgnAttachment is owned by a CCalAttachment */ |
|
63 EOwnedByCalAttachment = 0x01, |
|
64 /** EDataHasBeenSet is used to flag attachments created by content ID. This is set |
|
65 to true once the data has been set (binary data or file handle). If the data is not |
|
66 set then the attachment cannot be stored. */ |
|
67 EDataHasBeenSet = 0x02, |
|
68 }; |
|
69 |
|
70 // Destructor |
|
71 virtual ~CAgnAttachment(); |
|
72 |
|
73 // Get / set data |
|
74 IMPORT_C void SetMimeTypeL(const TDesC8& aMimeType); |
|
75 |
|
76 IMPORT_C void SetAttribute(TUint16 aAttribute); |
|
77 IMPORT_C void ClearAttribute(TUint16 aAttribute); |
|
78 IMPORT_C TBool IsAttributeSet(TUint16 aAttribute) const; |
|
79 |
|
80 IMPORT_C TCalAttachmentUid Uid() const; |
|
81 IMPORT_C void SetUid(TCalAttachmentUid aUid); |
|
82 |
|
83 IMPORT_C void SetLabelL(const TDesC& aName); |
|
84 IMPORT_C const TDesC& Label() const; |
|
85 |
|
86 IMPORT_C TInt Size() const; |
|
87 IMPORT_C void SetSize(TInt aSize); |
|
88 |
|
89 IMPORT_C void SetFlag(TUint16 aFlag); |
|
90 IMPORT_C void ClearFlag(TUint16 aFlag); |
|
91 IMPORT_C TBool FlagsSet(TUint16 aFlag) const; |
|
92 |
|
93 IMPORT_C void SetValue(TDesC8* aValue); // sets binary data or URI (NOT content ID) |
|
94 // Note value is fetched by calling CAgnContent::Content() |
|
95 |
|
96 // Used when store\restore the object to\from the file |
|
97 virtual void ExternalizeL(RWriteStream& aStream) const; |
|
98 virtual void InternalizeL(RReadStream& aStream); |
|
99 |
|
100 // Used when an entry is copied / compared |
|
101 virtual void CopyL(const CAgnAttachment& aSource); |
|
102 virtual TBool CompareL(const CAgnAttachment& aSource) const; |
|
103 |
|
104 protected: |
|
105 CAgnAttachment(CCalContent::TDisposition aType); |
|
106 |
|
107 private: |
|
108 HBufC* iLabel; |
|
109 TCalAttachmentUid iUid; |
|
110 TUint16 iAttributes; |
|
111 TUint16 iFlags; // internal flags |
|
112 TInt iSize; |
|
113 }; |
|
114 |
|
115 /** |
|
116 Class for internal representation of a URI attachment. |
|
117 @internalComponent |
|
118 */ |
|
119 NONSHARABLE_CLASS(CAgnAttachmentUri) : public CAgnAttachment |
|
120 { |
|
121 public: |
|
122 CAgnAttachmentUri(); |
|
123 |
|
124 // from CAgnAttachment |
|
125 void ExternalizeL(RWriteStream& aStream) const; |
|
126 void InternalizeL(RReadStream& aStream); |
|
127 }; |
|
128 |
|
129 /* |
|
130 Class for internal representation of a file attachment. |
|
131 Its data can be either passed in as binary data or by referencing a local file. |
|
132 @internalComponent |
|
133 */ |
|
134 NONSHARABLE_CLASS(CAgnAttachmentFile) : public CAgnAttachment |
|
135 { |
|
136 public: |
|
137 //Constructors and Destructors |
|
138 CAgnAttachmentFile(); |
|
139 ~CAgnAttachmentFile(); |
|
140 |
|
141 // Get / set data |
|
142 IMPORT_C void CopyFileHandle(const RFile& aFile); |
|
143 IMPORT_C const RFile& FileHandle() const; |
|
144 |
|
145 IMPORT_C void SetDriveL(const TDesC& aDrive); |
|
146 IMPORT_C TDriveName Drive() const; |
|
147 |
|
148 IMPORT_C void SetFileNameL(const TDesC& aFileName); |
|
149 IMPORT_C const TDesC& FileName() const; |
|
150 |
|
151 IMPORT_C const TTime& LastModifiedTimeUtc() const; |
|
152 IMPORT_C void SetLastModifiedTimeUtc(const TTime& aTime); |
|
153 |
|
154 IMPORT_C void SetContentIdL(const TDesC8& aContentId); |
|
155 IMPORT_C const TDesC8& ContentId() const; |
|
156 IMPORT_C TBool IsFileHandleSet() const; |
|
157 IMPORT_C void SetHasFileHandle(TBool aHasFileHandel); |
|
158 |
|
159 //Used when an entry is copied |
|
160 void CopyL(const CAgnAttachment& aSource); |
|
161 TBool CompareL(const CAgnAttachment& aSource) const; |
|
162 |
|
163 // from CAgnAttachment |
|
164 void ExternalizeL(RWriteStream& aStream) const; |
|
165 private: |
|
166 // from CAgnAttachment |
|
167 void InternalizeL(RReadStream& aStream); |
|
168 |
|
169 private: |
|
170 TDesC8* iContentId; // stores the content ID. This is not persisted. |
|
171 TTime iLastModifiedTimeUtc; |
|
172 HBufC* iFileName; // including drive name |
|
173 RFile iFileHandle; // used when fetching and storing file handles. Not externalized or internalized as part of CAgnAttachmentFile. |
|
174 TBool iIsFileHandleSet; |
|
175 }; |
|
176 |
|
177 #endif // __AGMATTACHMENT_H__ |