|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Bio control for Business Cards |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCARDBIOCONTROL_H |
|
21 #define VCARDBIOCONTROL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <msgbiocontrol.h> // for CMsgBioControl |
|
25 #include <MMsgBioControlExtension.h> // MMsgBioControlExtension |
|
26 #include "vcardbiocontrol.hrh" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 class CRichBio; |
|
31 class CVCardVpbUtil; |
|
32 class MVPbkStoreContactField; |
|
33 class MVPbkStoreContact; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Bio control for vCards and Compact Business Cards. |
|
39 */ |
|
40 NONSHARABLE_CLASS(CVCardBioControl): public CMsgBioControl, |
|
41 public MMsgBioControlExtension, |
|
42 public MMsgBioControlScrollExtension |
|
43 { |
|
44 public: // construction & destruction |
|
45 |
|
46 /** |
|
47 * Two-phased constructor |
|
48 * @param aObserver Reference to the Bio control observer. |
|
49 * @param aSession Reference to Message Server session. |
|
50 * @param aId Id of the message. |
|
51 * @param aEditorOrViewerMode Flags the new Bio control as editor or |
|
52 * viewer. |
|
53 * @param aFileName A reference to a file name of file based bio |
|
54 * control. |
|
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 ~CVCardBioControl(); |
|
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 * Any command can be given as an argument, but only Bio specific |
|
87 * commands should be handled. Other commands should be ignored by |
|
88 * this method. |
|
89 * @param aCommand Id of command to be handled. |
|
90 */ |
|
91 TBool HandleBioCommandL(TInt aCommand); |
|
92 |
|
93 /** |
|
94 * Returns a rectangle slice of the bio controls viewing area. |
|
95 * It is used by the CMsgEditorView class for scrolling the screen. |
|
96 * The position is given relative to the bio controls top left |
|
97 * corner. |
|
98 * @return TRect |
|
99 */ |
|
100 TRect CurrentLineRect() const; |
|
101 |
|
102 /** |
|
103 * This is used by the body container for managing focus and |
|
104 * scrolling. |
|
105 * @param aDirection The direction to be checked. |
|
106 */ |
|
107 TBool IsFocusChangePossible(TMsgFocusDirection aDirection) const; |
|
108 |
|
109 /** |
|
110 * Returns the header text. |
|
111 * @return The header text. |
|
112 */ |
|
113 HBufC* HeaderTextL(void) const; |
|
114 |
|
115 /** |
|
116 * Gives the height of the text in pixels. |
|
117 * It is used by the scrolling framework. |
|
118 * @return Height of the text in pixels. |
|
119 */ |
|
120 TInt VirtualHeight(); |
|
121 |
|
122 /** |
|
123 * Gives the cursor position in pixels. |
|
124 * It is used by the scrolling framework. |
|
125 * @return Cursor position in pixels. |
|
126 */ |
|
127 TInt VirtualVisibleTop(); |
|
128 |
|
129 /** |
|
130 * Tells whether the cursor is in the topmost or bottom position. |
|
131 * It is used by the scrolling framework. |
|
132 * @param aLocation Specifies either top or bottom. |
|
133 * @return ETrue if the cursor is in the part specified by aLocation. |
|
134 */ |
|
135 TBool IsCursorLocation(TMsgCursorLocation aLocation) const; |
|
136 |
|
137 public: // from CCoeControl |
|
138 |
|
139 /** |
|
140 * A CCoeControl virtual for handling key events. |
|
141 * @param aKeyEvent The key event. |
|
142 * @param aType TEventCode |
|
143 * @return EKeyWasConsumed or EKeyWasNotConsumed |
|
144 */ |
|
145 TKeyResponse OfferKeyEventL( |
|
146 const TKeyEvent& aKeyEvent, |
|
147 TEventCode aType); |
|
148 |
|
149 /** |
|
150 * Returns a control's a context sensitive help. |
|
151 * @param aHelpContext Help context. |
|
152 */ |
|
153 void GetHelpContext(TCoeHelpContext& aHelpContext) const; |
|
154 |
|
155 /** |
|
156 * Sets a bio control dimmed. |
|
157 * @param aDimmed ETrue to dim the control, |
|
158 * EFalse to set the control as not dimmed. |
|
159 */ |
|
160 void SetDimmed(TBool aDimmed); |
|
161 |
|
162 public: //from MMsgBioControlExtension |
|
163 |
|
164 TAny* BioControlExtension( TInt aExtensionId ); |
|
165 |
|
166 public: //from MMsgBioControlScrollExtension |
|
167 |
|
168 TInt ExtScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection ); |
|
169 |
|
170 void ExtNotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ); |
|
171 |
|
172 protected: // from CCoeControl |
|
173 |
|
174 /** |
|
175 * Gives the number of component controls. |
|
176 * @return The number of component controls. |
|
177 */ |
|
178 TInt CountComponentControls() const; |
|
179 |
|
180 /** |
|
181 * For accessing a component control. |
|
182 * @param aIndex Index of the control to be returned. |
|
183 */ |
|
184 CCoeControl* ComponentControl(TInt aIndex) const; |
|
185 |
|
186 /** |
|
187 * This is called by the CONE framework, and gives this control a |
|
188 * chance to manage the layout of its sub controls. |
|
189 */ |
|
190 void SizeChanged(); |
|
191 |
|
192 /** |
|
193 * This is called when focus is lost or gained, and is used |
|
194 * for setting the focus of the list box. |
|
195 * @param aDrawNow Whether to draw now. |
|
196 */ |
|
197 void FocusChanged(TDrawNow aDrawNow); |
|
198 |
|
199 /** |
|
200 * Sets the container window for this control. The container |
|
201 * control uses this function to set the same window for this control. |
|
202 * @param aContainer Reference to the container. |
|
203 */ |
|
204 void SetContainerWindowL(const CCoeControl& aContainer); |
|
205 |
|
206 /** |
|
207 * Handles resource change events. |
|
208 */ |
|
209 void HandleResourceChange(TInt aType); |
|
210 |
|
211 private: // enums |
|
212 |
|
213 /// These are the menu commands for this bio control. |
|
214 enum TMenuCommand |
|
215 { |
|
216 EAddToPhonebook = 0 |
|
217 }; |
|
218 |
|
219 private: // construction |
|
220 |
|
221 /** |
|
222 * The constructor. |
|
223 * @param aObserver MMsgBioControlObserver |
|
224 * @param aSession CMsvSession, the Message Server session. |
|
225 * @param aId Id of the message in Message Server. |
|
226 * @param aEditorOrViewerMode Flags the control as being either editor |
|
227 * or viewer. |
|
228 * @param aFileName not used |
|
229 * @param aFile file handle |
|
230 */ |
|
231 CVCardBioControl( |
|
232 MMsgBioControlObserver& aObserver, |
|
233 CMsvSession* aSession, |
|
234 TMsvId aId, |
|
235 TMsgBioMode aEditorOrViewerMode, |
|
236 const RFile* aFile); |
|
237 |
|
238 /// Second phase constructor. |
|
239 void ConstructL(); |
|
240 |
|
241 private: // new functions |
|
242 |
|
243 /** |
|
244 * Adds the vCard (phonebook contact item) to Phonebook. |
|
245 */ |
|
246 void AddToPhoneBookL(); |
|
247 |
|
248 /** |
|
249 * Resolves the file handle of the input data file. It also finds |
|
250 * out if the data is a vCard or a Compact Business card. |
|
251 * @param aFile Reference that gets the file handle. |
|
252 * @param aBCType Reference that gets the type of business card bio |
|
253 * control. |
|
254 */ |
|
255 void ResolveFileHandleAndTypeL( |
|
256 RFile& aFile, |
|
257 TVCardBCBusinessCardType& aBCType); |
|
258 |
|
259 /** |
|
260 * Adds the CVPbkContactItem field text to the viewer, including the |
|
261 * labels. |
|
262 * @param aContact Reference to the Pbk contact. |
|
263 */ |
|
264 void AddVPbkFieldsToViewerL(const MVPbkStoreContact& aContact); |
|
265 |
|
266 /** |
|
267 * Checks if the field is to be shown or not. |
|
268 * @param aField Reference to the contact item. |
|
269 * @return ETrue if the field is to be shown. |
|
270 */ |
|
271 static TBool FieldToBeShown(const MVPbkStoreContactField& aField); |
|
272 |
|
273 /** |
|
274 * This is needed because the menuPane adding is done in a different |
|
275 * way in BVA than in SMS Editor/Viewer. |
|
276 * @param aMenuPane Reference to menu pane |
|
277 * @param aStringRes String resource id. |
|
278 * @param aCommandOffset Offset of comand id from "first free command" |
|
279 */ |
|
280 void FileBasedAddMenuItemL(CEikMenuPane& aMenuPane, |
|
281 TInt aStringRes, TInt aCommandOffset); |
|
282 |
|
283 /** |
|
284 * Opens a read stream. Puts a stream cleanup (closing) item on the |
|
285 * cleanup stack. |
|
286 * @param aStream The stream that is to be opened. |
|
287 * @param aFileName File name to which the stream is to be opened. |
|
288 */ |
|
289 static void OpenStreamLC(RFileReadStream& aStream, |
|
290 TFileName& aFileName); |
|
291 |
|
292 /** |
|
293 * Panics the application. |
|
294 * Calls User::Panic with the classname and class-specific |
|
295 * errorcode. |
|
296 * @param aReason Class-specific error code telling what went wrong. |
|
297 */ |
|
298 static void Panic(TInt aReason); |
|
299 |
|
300 private: // hidden away |
|
301 |
|
302 /// The default constructor is prohibited |
|
303 CVCardBioControl(); |
|
304 |
|
305 /// Copy contructor prohibited. |
|
306 CVCardBioControl(const CVCardBioControl& aSource); |
|
307 |
|
308 /// Assignment operator prohibited. |
|
309 const CVCardBioControl& operator=(const CVCardBioControl& aSource); |
|
310 |
|
311 private: |
|
312 |
|
313 /// The Viewer component. |
|
314 CRichBio* iViewer; |
|
315 |
|
316 // own |
|
317 RFile iFileHandle; |
|
318 |
|
319 /// A Phonebook contact item is owned here. |
|
320 MVPbkStoreContact* iVpbContact; |
|
321 |
|
322 /// ETrue if BIO Control is lauched through BVA |
|
323 TBool iIsFileBased; |
|
324 |
|
325 CVCardVpbUtil* iVpbUtil; |
|
326 }; |
|
327 #endif // VCARDBIOCONTROL_H |
|
328 // end of file |