|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CCALENVIEWATTACHMENTSDIALOG_H |
|
19 #define CCALENVIEWATTACHMENTSDIALOG_H |
|
20 |
|
21 // ========== INCLUDE FILES ================================ |
|
22 #include <eiklbx.h> |
|
23 #include <eikfrlb.h> // for CFormattedCellListBoxItemDrawer |
|
24 #include <aknlists.h> // for CAknDoubleLargeStyleListBox |
|
25 #include <AknForm.h> |
|
26 #include <AknServerApp.h> |
|
27 #include <aknlongtapdetector.h> |
|
28 #include <calennotificationhandler.h> // MCalenNotificationHandler |
|
29 |
|
30 #include "calenattalistitemarray.h" |
|
31 #include "calenattachmentitemdrawer.h" |
|
32 #include "calenattachmentslistbox.h" |
|
33 |
|
34 // ========== CONSTANTS ==================================== |
|
35 |
|
36 const TInt KCalenAttaItemTextLength = 256; |
|
37 |
|
38 // ========== FORWARD DECLARATIONS ========================= |
|
39 |
|
40 class MAknLongTapDetectorCallBack; |
|
41 |
|
42 class CGulIcon; |
|
43 class CAknTitlePane; |
|
44 class CCalenController; |
|
45 class CCalenAttachmentModel; |
|
46 class CCalenAttachmentInfo; |
|
47 class CDocumentHandler; |
|
48 class CAknWaitDialog; |
|
49 class CAknNavigationControlContainer; |
|
50 class CAiwGenericParamList; |
|
51 |
|
52 // ========== CLASS DECLARATION ============================ |
|
53 |
|
54 /** |
|
55 * View attachments dialog. |
|
56 */ |
|
57 class CCalenViewAttachmentsDialog : public CAknDialog, |
|
58 public MEikListBoxObserver, |
|
59 public MAknServerAppExitObserver, |
|
60 public MCalenNotificationHandler |
|
61 { |
|
62 public: |
|
63 |
|
64 /** |
|
65 * First phase constructor |
|
66 * |
|
67 * @param aController A reference to calencontroller |
|
68 * @return pointer to CCalenAttachmentSelectionObserver |
|
69 */ |
|
70 static CCalenViewAttachmentsDialog* NewL( TDesC& aTitle, |
|
71 CCalenAttachmentModel& aAttachmentModel, |
|
72 CCalenController& aController); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 ~CCalenViewAttachmentsDialog(); |
|
78 |
|
79 /** |
|
80 * 2nd phase constructor. |
|
81 * Deprecated. |
|
82 */ |
|
83 void ConstructL(); |
|
84 |
|
85 |
|
86 public: // new functions |
|
87 |
|
88 /** |
|
89 * Returns the index of currently selected listbox item or KErrNotFound if list |
|
90 * empty or no selection. |
|
91 * @return current index |
|
92 */ |
|
93 TInt CurrentListItemIndex(); |
|
94 |
|
95 /** |
|
96 * Updates icon of list item indicated by 'aListIndex'. |
|
97 * @param aListIndex |
|
98 */ |
|
99 void UpdateIcon( TInt aListIndex ); |
|
100 |
|
101 /** |
|
102 * Handle listbox item addition. Call this after you have added attachment |
|
103 * to the attachment model. If you inserted attachment to some other |
|
104 * position than last, use same index as aIndex. |
|
105 * @param aIndex item index |
|
106 */ |
|
107 void ItemAddedL( TInt aIndex = -1 ); |
|
108 |
|
109 /** |
|
110 * Handle listbox item removal. Call this after you have removed attachment |
|
111 * from the attachment model. |
|
112 * @param aIndex item index |
|
113 */ |
|
114 void ItemRemovedL( TInt aIndex ); |
|
115 |
|
116 /** |
|
117 * NotifySizeChanged, calls SizeChanged() method of |
|
118 * dialog's listbox |
|
119 * |
|
120 */ |
|
121 void NotifySizeChanged(); |
|
122 |
|
123 /** |
|
124 * Updates all attachments fetched flags |
|
125 * in attachment model. |
|
126 */ |
|
127 void UpdateAttachmentsFetchFlags(); |
|
128 |
|
129 /** |
|
130 * From MEikListBoxObserverClass |
|
131 */ |
|
132 void HandleListBoxEventL( |
|
133 CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
134 |
|
135 /** |
|
136 * Updates list of attatchments if attatchment |
|
137 * dialog is opened before all attatchments |
|
138 * are loaded. |
|
139 */ |
|
140 void UpdateAttatchmentListL(); |
|
141 |
|
142 public: // from CAknDialog |
|
143 |
|
144 /** |
|
145 * Processes menu commands. |
|
146 * @param aCommandId |
|
147 */ |
|
148 void ProcessCommandL( TInt aCommandId ); |
|
149 |
|
150 /** |
|
151 * Removes default menu items from CAknFrom and adds own custom menu |
|
152 * items whose resource id was given in construstor. |
|
153 * @param aMenuId |
|
154 * @param aMenuPane |
|
155 */ |
|
156 void DynInitMenuPaneL( TInt aMenuId, CEikMenuPane* aMenuPane ); |
|
157 |
|
158 /** |
|
159 * From CCoeControl |
|
160 */ |
|
161 void HandleResourceChange( TInt aType ); |
|
162 |
|
163 /** |
|
164 * From CCoeControl Handle pointer event |
|
165 * @param aPointerEvent Event to be handled. |
|
166 */ |
|
167 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
168 |
|
169 /** |
|
170 * Prepare icons and listbox. |
|
171 */ |
|
172 void LoadFormDataL(); |
|
173 |
|
174 /** |
|
175 * Remove attachment from model. |
|
176 * @param aIndex attachment index |
|
177 */ |
|
178 TInt RemoveAttachmentL( TInt aIndex ); |
|
179 |
|
180 /** |
|
181 * From CCoeControl, return child control count. |
|
182 * @return Control count |
|
183 */ |
|
184 TInt CountComponentControls() const; |
|
185 |
|
186 /** |
|
187 * From CCoeControl, return child control pointer. |
|
188 * @param aIndex Child control index |
|
189 * @return Child control pointer. |
|
190 */ |
|
191 CCoeControl* ComponentControl(TInt aIndex) const; |
|
192 |
|
193 |
|
194 |
|
195 public: // from MAknServerAppExitObserver |
|
196 |
|
197 /** |
|
198 * Handle the exit of a connected server app. |
|
199 * This implementation provides S60 default behavior |
|
200 * for handling of the EAknCmdExit exit code. Derived classes |
|
201 * should base-call this implementation if they override this |
|
202 * function. |
|
203 * |
|
204 * @since S60 5.0 |
|
205 * |
|
206 * @param aReason The reason that the server application exited. |
|
207 * This will either be an error code, or the command id that caused |
|
208 * the server app to exit. |
|
209 */ |
|
210 void HandleServerAppExit( TInt aReason ); |
|
211 |
|
212 protected: // from CAknDialog |
|
213 |
|
214 /** |
|
215 * |
|
216 * @param aButtonId |
|
217 * @return |
|
218 */ |
|
219 TBool OkToExitL( TInt aButtonId ); |
|
220 |
|
221 /** |
|
222 * Create custom control. |
|
223 * @param aControlType |
|
224 * @return |
|
225 */ |
|
226 SEikControlInfo CreateCustomControlL( TInt aControlType ); |
|
227 |
|
228 /** |
|
229 * Set the generic parameter list used in opening content CDocumentHandler |
|
230 * Ownership is transferred to base class |
|
231 */ |
|
232 void SetOpenParamList( CAiwGenericParamList* aOpenParamList ); |
|
233 |
|
234 /** |
|
235 * Set the generic parameter list used in opening content CDocumentHandler |
|
236 * Ownership is transferred to base class |
|
237 */ |
|
238 CAiwGenericParamList* OpenParamList(); |
|
239 |
|
240 protected: // from CEikDialog |
|
241 |
|
242 /** |
|
243 * |
|
244 */ |
|
245 void PreLayoutDynInitL(); |
|
246 |
|
247 /** |
|
248 * |
|
249 */ |
|
250 void HandleControlStateChangeL( TInt aControlId ); |
|
251 |
|
252 private: |
|
253 |
|
254 /** |
|
255 * Constructor. |
|
256 * @param aTitle title for dialog (shown in title pane) |
|
257 * @param aMenuId resource id for menu |
|
258 * @param aAttachmentModel reference to attachment model |
|
259 * @param aController reference to calencontroller |
|
260 */ |
|
261 CCalenViewAttachmentsDialog( TDesC& aTitle, |
|
262 CCalenAttachmentModel& aAttachmentModel, |
|
263 CCalenController& aController); |
|
264 |
|
265 /** |
|
266 * Common part for ConstructL methods. |
|
267 */ |
|
268 void DoConstructL(); |
|
269 |
|
270 /** |
|
271 * Function that TCleanupItem calls. |
|
272 */ |
|
273 static void CleanupWaitDialog( TAny* aAny ); |
|
274 |
|
275 /** |
|
276 * Performs UI updating. |
|
277 */ |
|
278 void DoUpdateUiL(); |
|
279 |
|
280 /** |
|
281 * Update CBA button visibility. |
|
282 */ |
|
283 void UpdateButtonVisiblity( TInt aCommandId, TBool aValue ); |
|
284 |
|
285 /** |
|
286 * Handles notifications (Leaving) |
|
287 */ |
|
288 void HandleNotificationL( TCalenNotification aNotification ); |
|
289 |
|
290 // from MCalenNotificationHandler |
|
291 |
|
292 /** |
|
293 * Handles notifications |
|
294 */ |
|
295 void HandleNotification( const TCalenNotification aNotification ); |
|
296 |
|
297 /** |
|
298 * Opens the attachment. Its a commadn handler for opening the attachment |
|
299 */ |
|
300 void OpenAttachmentL(); |
|
301 |
|
302 /** |
|
303 * Tell whether attachment can be removed or not |
|
304 */ |
|
305 TBool CanRemoveAttachment( CCalenAttachmentInfo& aInfo ); |
|
306 |
|
307 /** |
|
308 * Sets the text for MSK |
|
309 */ |
|
310 void SetMiddleSoftKeyLabelL(TInt aResourceId, |
|
311 TInt aCommandId ); |
|
312 |
|
313 /** |
|
314 * Updates the text for MSK |
|
315 */ |
|
316 void UpdateMiddleSoftKeyL( TInt aIndex ); |
|
317 |
|
318 /** |
|
319 * Checks if free memory available in the device is below critical level |
|
320 */ |
|
321 TBool CheckSpaceBelowCriticalLevelL(); |
|
322 |
|
323 /// From CCoeControl |
|
324 TKeyResponse OfferKeyEventL( |
|
325 const TKeyEvent& aKeyEvent,TEventCode aType); |
|
326 |
|
327 /// From CCoeControl |
|
328 void GetHelpContext( TCoeHelpContext& aContext) const; |
|
329 |
|
330 /** |
|
331 * Framework function to handle the back press |
|
332 */ |
|
333 TBool HandleOkToExitL( TInt aButtonId ); |
|
334 |
|
335 /** |
|
336 * Opens the attachment |
|
337 * |
|
338 * @param RFile File handler to be opened |
|
339 * @param aExitObserver Exit observer that listens for exiting from the attahcment viewer |
|
340 * @return None |
|
341 */ |
|
342 void OpenAttachmentViewerL(RFile& file, MAknServerAppExitObserver& aExitObserver); |
|
343 |
|
344 |
|
345 protected: // data |
|
346 |
|
347 CCalenAttachmentModel& iAttachmentModel; |
|
348 CCalenAttaListItemArray* iListItems; |
|
349 CArrayPtr<CGulIcon>* iIconArray; |
|
350 CCalenAttachmentsListBox* iListBox; |
|
351 TInt iBusy; |
|
352 |
|
353 private: // data |
|
354 |
|
355 HBufC* iOldTitle; |
|
356 CAknTitlePane* iTitlePane; |
|
357 TInt iMenuId; |
|
358 CAknWaitDialog* iWaitDialog; //not used as of now. |
|
359 CAknNavigationControlContainer* iNaviPane; |
|
360 RFile iREMOVED; |
|
361 // Kept only for maintaining BC |
|
362 // If opening through CDocumentHandler needs parameters, |
|
363 // derived class must insert parameters here. |
|
364 // The iOpenParamList is initially empty |
|
365 |
|
366 CAiwGenericParamList* iOpenParamList; |
|
367 TInt iSelectedCommand; |
|
368 |
|
369 // reference to the calencontroller |
|
370 CCalenController& iController; |
|
371 CDocumentHandler* iDocHandler; |
|
372 const TDesC& iNewTitle; |
|
373 TBool iEmbeddedFileOpened; |
|
374 |
|
375 |
|
376 // Internal status flags |
|
377 TInt iFlags; |
|
378 }; |
|
379 |
|
380 #endif // CMSGVIEWATTACHMENTSDIALOG_H |
|
381 |
|
382 // End of File |