|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description : class declaration of CCalenAttachmentModel |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CALENATTACHMENTMODEL_H |
|
19 #define CALENATTACHMENTMODEL_H |
|
20 |
|
21 #include <apgcli.h> |
|
22 #include <calentry.h> |
|
23 #include "calenattachmentinfo.h" |
|
24 |
|
25 class CGulIcon; |
|
26 class CCalenAttachmentInfo; |
|
27 class CFbsBitmap; |
|
28 |
|
29 /** |
|
30 * Attachment model observer. |
|
31 */ |
|
32 class MCalenAttachmentModelObserver |
|
33 { |
|
34 public: |
|
35 |
|
36 enum TCalenAttachmentCommand |
|
37 { |
|
38 ECalenAttachmentAdded = 0, |
|
39 ECalenAttachmentRemoved |
|
40 }; |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * This function that is called when attachment model adds or removes |
|
46 * attachments from its list. |
|
47 * |
|
48 * @param aCommand |
|
49 */ |
|
50 virtual void NotifyChanges( TCalenAttachmentCommand aCommand , |
|
51 TInt aAttachmentIndex) = 0; |
|
52 |
|
53 /** |
|
54 * This function that is called when attachment model needs to |
|
55 * get access to an attachment file |
|
56 * |
|
57 * @param aIndex Index of the attachment for which file handle is requested |
|
58 * @return (read-only) file handle |
|
59 */ |
|
60 virtual RFile GetAttachmentFileL(TInt aIndex) = 0; |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Attachment model. |
|
65 */ |
|
66 class CCalenAttachmentModel : public CBase |
|
67 { |
|
68 public: |
|
69 |
|
70 /** |
|
71 * First phase constructor |
|
72 * |
|
73 * @return returns pointer to CCalenAttachmentModel |
|
74 */ |
|
75 IMPORT_C static CCalenAttachmentModel* NewL(); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 ~CCalenAttachmentModel(); |
|
81 |
|
82 private: |
|
83 |
|
84 /** |
|
85 * Default Constructor. |
|
86 */ |
|
87 CCalenAttachmentModel(); |
|
88 |
|
89 /** |
|
90 * 2nd phase constructor. |
|
91 */ |
|
92 void ConstructL(); |
|
93 |
|
94 public: |
|
95 |
|
96 /** |
|
97 * Sets attachment model observer. |
|
98 * |
|
99 * @param aObserver pointer to the MCalenAttachmentModelObserver |
|
100 */ |
|
101 IMPORT_C void SetObserver(MCalenAttachmentModelObserver* aObserver); |
|
102 |
|
103 /** |
|
104 * Returns number of attachments in the internal array of attachments. |
|
105 * |
|
106 * @return TInt number of attachments |
|
107 */ |
|
108 IMPORT_C TInt NumberOfItems() const; |
|
109 |
|
110 /** |
|
111 * Returns reference to attachment info at given index. |
|
112 * |
|
113 * @param aIndex index for which attachment info is needed |
|
114 * @return return attachment info |
|
115 */ |
|
116 IMPORT_C CCalenAttachmentInfo& AttachmentInfoAt(TInt aIndex) const; |
|
117 |
|
118 /** |
|
119 * Adds attachment to the internal array. Notifies attachment model |
|
120 * observer with ECalenAttachmentAdded parameter. |
|
121 * |
|
122 * @param aFullName file name of the attachment to be added |
|
123 */ |
|
124 IMPORT_C void AddAttachmentL(const TDesC& aFullName, const TDesC& aSystemFileName); |
|
125 |
|
126 /** |
|
127 * Adds attachment to the internal array. Notifies attachment model |
|
128 * observer with ECalenAttachmentAdded parameter. |
|
129 * |
|
130 * @param aFullName file name of the attachment to be added |
|
131 * @param aSize size of the attachment file |
|
132 * @param aFetched fetched or not |
|
133 * @param aDataType mime type of the attachment |
|
134 */ |
|
135 IMPORT_C void AddAttachmentL( const TDesC& aFullName, const TDesC& aSystemFileName, TInt aSize, |
|
136 TBool aFetched, const TDataType& aDataType, RFile &aFile); |
|
137 |
|
138 /** |
|
139 * Deletes attachment from internal array. Notifies attachment model |
|
140 * observer with ECalenAttachmentRemoved parameter. |
|
141 * |
|
142 * @param aIndex index for which attachment to be deleted |
|
143 */ |
|
144 IMPORT_C TBool DeleteAttachment(TInt aIndex); |
|
145 |
|
146 /** |
|
147 * Reset the attachment model (empties the internal array). |
|
148 */ |
|
149 IMPORT_C void Reset(); |
|
150 |
|
151 /** |
|
152 * Loads resources, i.e. bitmaps & layouts |
|
153 */ |
|
154 IMPORT_C void LoadResourcesL(); |
|
155 |
|
156 /* |
|
157 * Get file handle from "model observer" |
|
158 * |
|
159 * @param aIndex index of the attachment info |
|
160 * @return RFile returns the file handle |
|
161 */ |
|
162 IMPORT_C RFile GetAttachmentFileL( TInt aIndex ); |
|
163 |
|
164 /** |
|
165 * Get the attachment lists |
|
166 * |
|
167 * @param aAttachmentList fills the attachment list |
|
168 */ |
|
169 IMPORT_C void GetAttachmentListL( |
|
170 RPointerArray<CCalenAttachmentInfo> &aAttachmentList); |
|
171 |
|
172 /** |
|
173 * Returns pointer to bitmap of the application that handles given file. |
|
174 * |
|
175 * @param aAttaInfo reference to the attachment info |
|
176 * @return returns CGulIcon |
|
177 */ |
|
178 IMPORT_C CGulIcon* BitmapForFileL(CCalenAttachmentInfo& aAttaInfo); |
|
179 |
|
180 /** |
|
181 * Updates attachment mode with the attahcments of entr if it has any |
|
182 * |
|
183 * @param None |
|
184 * @return None |
|
185 */ |
|
186 IMPORT_C void CheckForExistingAttachmentsL(CCalEntry* entry); |
|
187 |
|
188 /** |
|
189 * Set the flag to ETrue if the attachment(Photo, audio and vedio files) is open. |
|
190 * |
|
191 * @param aEmbeddedFileOpened, set to ETrue when attachment(Photo, audio and vedio files) is Open |
|
192 * @return None |
|
193 */ |
|
194 IMPORT_C void AttachmentOpen(TBool& aEmbeddedFileOpened); |
|
195 |
|
196 /** |
|
197 * return ETrue if the atacchment is opened. |
|
198 * |
|
199 * @param None |
|
200 * @return None |
|
201 */ |
|
202 IMPORT_C TBool IsAttachmentOpen(); |
|
203 |
|
204 private: |
|
205 |
|
206 /** |
|
207 * Returns pointer to bitmap of given application. |
|
208 * |
|
209 * @param aAppUid UID of the application for which bitmap is requested |
|
210 * @return |
|
211 */ |
|
212 CGulIcon* BitmapForAppL( const TUid &aAppUid ); |
|
213 |
|
214 /** |
|
215 * Creates new attachment info object. |
|
216 * |
|
217 * @param aFileName filename of the attachment |
|
218 * @param aSize size of the attachment |
|
219 * @param aFetched attacment fetched or not |
|
220 * @param aDataType mime type of the attachment |
|
221 * @return |
|
222 */ |
|
223 CCalenAttachmentInfo* CreateNewInfoL( const TDesC& aFileName, |
|
224 const TDesC& aSystemFileName, |
|
225 TInt aSize, |
|
226 TBool aFetched, |
|
227 const TDataType& aDataType, |
|
228 const CCalenAttachmentInfo::TCalenAttachmentStoreType aStoreType); |
|
229 |
|
230 /** |
|
231 * Deletes attachment from given index. |
|
232 * |
|
233 * @param aIndex Index of the deleted attachment. |
|
234 */ |
|
235 TBool DoDeleteAttachmentL( TInt aIndex ); |
|
236 /** |
|
237 * @brief Checks if the total attachment size plus the new file size exceeds 1MB . |
|
238 * |
|
239 * @param aNewFileSize Size of the selected attachment. |
|
240 */ |
|
241 TBool CheckFileSizeLimitL( TInt aNewFileSize ); |
|
242 |
|
243 private: |
|
244 RPointerArray<CCalenAttachmentInfo> iAttachInfoArray; |
|
245 MCalenAttachmentModelObserver* iAttachmentModelObserver; |
|
246 RApaLsSession iAppList; |
|
247 TSize iIconSize; |
|
248 TBool isAttachmentModelCleared; // Flag to tell if attachment model is reset. If yes, then only it will be populated again |
|
249 TBool iEmbeddedFileOpened; |
|
250 }; |
|
251 |
|
252 #endif // CALENATTACHMENTMODEL_H |
|
253 |
|
254 // End of File |