|
1 /* |
|
2 * Copyright (c) 2002 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 * Bio control for vCalendar messages. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef VCALENDARBIOCONTROL_H |
|
22 #define VCALENDARBIOCONTROL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <msgbiocontrol.h> // for CMsgBioControl |
|
26 #include <MMsgBioControlExtension.h> // for MMsgBioControlExtension |
|
27 #include <calprogresscallback.h> // for MCalProgressCallBack |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CRichBio; |
|
31 class CCalSession; |
|
32 class CCalEntryView; |
|
33 class CCalEntry; |
|
34 class CAiwServiceHandler; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Bio control for Calendar messages. |
|
40 */ |
|
41 NONSHARABLE_CLASS(CVCalendarBioControl) : |
|
42 public CMsgBioControl, |
|
43 public MCalProgressCallBack, |
|
44 public MMsgBioControlExtension, |
|
45 public MMsgBioControlScrollExtension |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Two-phased constructor |
|
51 * @param aObserver Reference to the Bio control observer. |
|
52 * @param aSession Reference to Message Server session. |
|
53 * @param aId Id of the message. |
|
54 * @param aEditorOrViewerMode Flags the new Bio control as editor or viewer. |
|
55 * @param aFile filehandle. |
|
56 * @return The newly created object. |
|
57 */ |
|
58 IMPORT_C static CMsgBioControl* NewL( |
|
59 MMsgBioControlObserver& aObserver, |
|
60 CMsvSession* aSession, |
|
61 TMsvId aId, |
|
62 TMsgBioMode aEditorOrViewerMode, |
|
63 const RFile* aFile); |
|
64 |
|
65 /// Destructor |
|
66 ~CVCalendarBioControl(); |
|
67 |
|
68 public: //from MMsgBioControl |
|
69 |
|
70 /** |
|
71 * Calculates and sets size for a Bio control according to aSize. |
|
72 * @param aSize A reference to the suggested size and new size. |
|
73 */ |
|
74 void SetAndGetSizeL(TSize& aSize); |
|
75 |
|
76 /** |
|
77 * Adds a menu command. |
|
78 * @param aMenuPane Reference to the CEikMenuPane of the application. |
|
79 */ |
|
80 void SetMenuCommandSetL(CEikMenuPane& aMenuPane); |
|
81 |
|
82 /* |
|
83 * The command handler of the bio control. |
|
84 * The commands usually originate from a bio specific menu item being |
|
85 * selected by the user. |
|
86 * @param aCommand Id of command to be handled. |
|
87 */ |
|
88 TBool HandleBioCommandL(TInt aCommand); |
|
89 |
|
90 /** |
|
91 * Returns a rectangle slice of the bio controls viewing area. |
|
92 * It is used by the CMsgEditorView class for scrolling the screen. |
|
93 * @return TRect |
|
94 */ |
|
95 TRect CurrentLineRect() const; |
|
96 |
|
97 /** |
|
98 * This is used by the body container for managing focus and |
|
99 * scrolling. |
|
100 * @param aDirection The direction to be checked. |
|
101 */ |
|
102 TBool IsFocusChangePossible(TMsgFocusDirection aDirection) const; |
|
103 |
|
104 /** |
|
105 * Returns the header text. |
|
106 * @return The header text. |
|
107 */ |
|
108 HBufC* HeaderTextL(void) const; |
|
109 |
|
110 /** |
|
111 * Gives the height of the text in pixels. |
|
112 * It is used by the scrolling framework of Editor Base. |
|
113 * @return Height of the text in pixels. |
|
114 */ |
|
115 TInt VirtualHeight(); |
|
116 |
|
117 /** |
|
118 * Gives the cursor position in pixels. |
|
119 * It is used by the scrolling framework of Editor Base. |
|
120 * @return Cursor position in pixels. |
|
121 */ |
|
122 TInt VirtualVisibleTop(); |
|
123 |
|
124 /** |
|
125 * Tells whether the cursor is in the topmost or bottom position. |
|
126 * It is used by the scrolling framework. |
|
127 * @param aLocation Specifies either top or bottom. |
|
128 * @return ETrue if the cursor is in the part specified by aLocation. |
|
129 */ |
|
130 TBool IsCursorLocation(TMsgCursorLocation aLocation) const; |
|
131 |
|
132 public: // from CCoeControl |
|
133 |
|
134 /** |
|
135 * Returns a bio control's a context sensitive help. |
|
136 * @param aHelpContext Help context. |
|
137 */ |
|
138 void GetHelpContext(TCoeHelpContext& aHelpContext) const; |
|
139 |
|
140 |
|
141 protected: // from CCoeControl |
|
142 |
|
143 /** |
|
144 * Gives the number of component controls. |
|
145 * @return The number of component controls. |
|
146 */ |
|
147 TInt CountComponentControls() const; |
|
148 |
|
149 /** |
|
150 * For accessing a component control. |
|
151 * @param aIndex Index of the component to be returned. |
|
152 */ |
|
153 CCoeControl* ComponentControl(TInt aIndex) const; |
|
154 |
|
155 /** |
|
156 * This is called by the CONE framework, and gives this control a |
|
157 * chance to manage the layout of its subcontrols. |
|
158 */ |
|
159 void SizeChanged(); |
|
160 |
|
161 /** |
|
162 * This is called when focus is lost or gained, and is used |
|
163 * for setting the focus of the list box. |
|
164 * @param aDrawNow Whether to draw now or not. |
|
165 */ |
|
166 void FocusChanged(TDrawNow aDrawNow); |
|
167 |
|
168 /** |
|
169 * Sets the container window for this control. The container |
|
170 * control uses this function to set the same window for this control. |
|
171 * @return aContainer Reference to the container. |
|
172 */ |
|
173 void SetContainerWindowL(const CCoeControl& aContainer); |
|
174 |
|
175 /** |
|
176 * A CCoeControl virtual for handling key events. |
|
177 * @param aKeyEvent The key event. |
|
178 * @param aType TEventCode |
|
179 * @return EKeyWasConsumed or EKeyWasNotConsumed |
|
180 */ |
|
181 TKeyResponse OfferKeyEventL( |
|
182 const TKeyEvent& aKeyEvent, |
|
183 TEventCode aType); |
|
184 |
|
185 /** |
|
186 * Handles resource change events. |
|
187 */ |
|
188 void HandleResourceChange( TInt aType ); |
|
189 |
|
190 public: //from MMsgBioControlExtension |
|
191 |
|
192 TAny* BioControlExtension( TInt aExtensionId ); |
|
193 |
|
194 public: //from MMsgBioControlScrollExtension |
|
195 |
|
196 TInt ExtScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection ); |
|
197 |
|
198 void ExtNotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ); |
|
199 |
|
200 private: //new functions |
|
201 |
|
202 /** |
|
203 * Parses the data and produces an Agenda entry. |
|
204 * the vCalendar file. |
|
205 */ |
|
206 void ImportVCalendarL(); |
|
207 |
|
208 /** |
|
209 * Resolve the file handle of the data file that is used as input. |
|
210 * @param aFile A reference that gets the file handle. |
|
211 */ |
|
212 void ResolveFileL( RFile& aFile ); |
|
213 |
|
214 /** |
|
215 * This is needed because the menuPane adding is done in a different |
|
216 * way in BVA than in SMS Editor/Viewer. |
|
217 * @param aMenuPane Reference to the menu pane. |
|
218 * @param aStringRes String resource ID of the command text. |
|
219 * @param aCommandOffset Offset in the Options list. |
|
220 */ |
|
221 void FileBasedAddMenuItemL(CEikMenuPane& aMenuPane, |
|
222 TInt aStringRes, TInt aCommandOffset); |
|
223 |
|
224 /** |
|
225 * Opens a read stream. Puts a stream cleanup (closing) item on the |
|
226 * cleanup stack. |
|
227 * @param aStream The stream that is to be opened. |
|
228 * @param aFileName File name to which the stream is to be opened. |
|
229 */ |
|
230 static void OpenStreamLC(RFileReadStream& aStream, |
|
231 TFileName& aFileName); |
|
232 |
|
233 private: //construction |
|
234 |
|
235 /** |
|
236 * The constructor. |
|
237 * @param aObserver MMsgBioControlObserver |
|
238 * @param aSession CMsvSession, the Message Server session. |
|
239 * @param aId Id of the message in Message Server. |
|
240 * @param aEditorOrViewerMode Flags the control as being either editor or viewer |
|
241 * @param aFileName *not used* |
|
242 * @param aFile file handle to vcal content. |
|
243 */ |
|
244 CVCalendarBioControl( |
|
245 MMsgBioControlObserver& aObserver, |
|
246 CMsvSession* aSession, |
|
247 TMsvId aId, |
|
248 TMsgBioMode aEditorOrViewerMode, |
|
249 const RFile* aFile); |
|
250 |
|
251 /// Second phase constructor. |
|
252 void ConstructL(); |
|
253 |
|
254 private: // from MCalProgressCallBack |
|
255 |
|
256 |
|
257 /** Progress callback. |
|
258 This calls the observing class with the percentage complete of the current operation. |
|
259 @param aPercentageCompleted The percentage complete. */ |
|
260 void Progress(TInt aPercentageCompleted); |
|
261 |
|
262 /** Progress callback. |
|
263 This calls the observing class when the current operation is finished. |
|
264 @param aError The error if the operation failed, or KErrNone if successful. */ |
|
265 void Completed(TInt aError); |
|
266 |
|
267 /** Asks the observing class whether progress callbacks are required. |
|
268 @return If the observing class returns EFalse, then the Progress() function will not be called. */ |
|
269 TBool NotifyProgress(); |
|
270 |
|
271 |
|
272 private: //hidden away |
|
273 |
|
274 /// The default constructor is hidden away |
|
275 CVCalendarBioControl(); |
|
276 |
|
277 /// Copy contructor prohibited. |
|
278 CVCalendarBioControl(const CVCalendarBioControl& aSource); |
|
279 |
|
280 /// Assignment operator prohibited. |
|
281 const CVCalendarBioControl& operator=(const CVCalendarBioControl& aSource); |
|
282 |
|
283 private: |
|
284 |
|
285 /// The viewer control |
|
286 CRichBio* iViewer; |
|
287 |
|
288 /// Calendar session |
|
289 CCalSession* iSession; |
|
290 |
|
291 /// calender entry view for saving purposes |
|
292 CCalEntryView* iCalEntryView; |
|
293 |
|
294 /// CCalEntryView initialization error code |
|
295 TInt iCalEntryInitErrno; |
|
296 |
|
297 /// Contains imported calendar entries. |
|
298 RPointerArray<CCalEntry> iCalEntryArray; |
|
299 |
|
300 /// ETrue if BIO Control is lauched through BVA |
|
301 TBool iIsFileBased; |
|
302 |
|
303 /// Filebased filehandle |
|
304 RFile iFileHandle; |
|
305 |
|
306 /* |
|
307 * @var iCalAiwServiceHandler. |
|
308 * @brief Servicehandler to access calendaraiwprovider. |
|
309 */ |
|
310 CAiwServiceHandler* iCalAiwServiceHandler; |
|
311 }; |
|
312 #endif // VCALENDARBIOCONTROL_H |
|
313 |
|
314 // End of file |