|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 fetch dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2FETCHDLG_H |
|
20 #define CPBK2FETCHDLG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknDialog.h> |
|
24 #include "MPbk2FetchDlg.h" |
|
25 #include "MPbk2FetchResultsObserver.h" |
|
26 #include <MPbk2DialogEliminator.h> |
|
27 #include <babitflags.h> |
|
28 #include "MPbk2StoreConfigurationObserver.h" |
|
29 #include "CPbk2StoreConfiguration.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CVPbkContactLinkArray; |
|
33 class CAknNavigationDecorator; |
|
34 class MPbk2FetchDlgPages; |
|
35 class MVPbkContactOperationBase; |
|
36 class MPbk2ContactUiControl; |
|
37 class MVPbkViewContact; |
|
38 class MPbk2ExitCallback; |
|
39 class CPbk2FetchResults; |
|
40 class CPbk2NamesListControl; |
|
41 class CPbk2StoreConfiguration; |
|
42 |
|
43 // CLASS DECLARATIONS |
|
44 |
|
45 /** |
|
46 * Phonebook 2 fetch dialog. |
|
47 * Responsible for: |
|
48 * - presenting a fetch dialog for the user |
|
49 * - managing dialog pages |
|
50 * - handling select/deselect of contacts |
|
51 */ |
|
52 class CPbk2FetchDlg : public CAknDialog, |
|
53 public MPbk2FetchDlg, |
|
54 public MPbk2DialogEliminator, |
|
55 private MPbk2FetchResultsObserver, |
|
56 private MPbk2StoreConfigurationObserver |
|
57 { |
|
58 public: // Data structures |
|
59 |
|
60 /** |
|
61 * Fetch parameter flags. |
|
62 */ |
|
63 enum TFetchFlags |
|
64 { |
|
65 /// Multiple entry fetch |
|
66 EFetchMultiple = 0x0001, |
|
67 /// Single entry fetch |
|
68 EFetchSingle = 0x0002, |
|
69 /// Call item fetch |
|
70 EFetchCallItem = 0x0004 |
|
71 }; |
|
72 |
|
73 /** |
|
74 * Exit parameter flags |
|
75 */ |
|
76 enum TExitState |
|
77 { |
|
78 EExitOrdered, |
|
79 EExitApproved, |
|
80 EOkToExitWithoutHandlingIt |
|
81 }; |
|
82 |
|
83 /** |
|
84 * Fetch parameters struct. |
|
85 * Parameters specify the fetch return value. |
|
86 */ |
|
87 class TParams |
|
88 { |
|
89 public: // Interface |
|
90 |
|
91 /** |
|
92 * Constructor. |
|
93 */ |
|
94 IMPORT_C TParams(); |
|
95 |
|
96 /** |
|
97 * Returns a cleanup item which will release all resources |
|
98 * held by this object in case a leave occurs. |
|
99 */ |
|
100 IMPORT_C operator TCleanupItem(); |
|
101 |
|
102 private: // Implementation |
|
103 static void Cleanup( |
|
104 TAny* aPtr ); |
|
105 |
|
106 private: // Unimplemented |
|
107 /// Unimplemented assignment operator |
|
108 TParams& operator=( |
|
109 const TParams& ); |
|
110 |
|
111 public: // Input parameters |
|
112 /// Own: Fetch flags, defaults to EFetchSingle |
|
113 /// @see TFetchFlags |
|
114 TUint iFlags; |
|
115 /// Own: PBK2_FETCH_DIALOG resource id |
|
116 /// Defaults to r_pbk2_single_entry_fetch_dlg |
|
117 TInt iResId; |
|
118 /// Ref: Pre-marked entries |
|
119 MVPbkContactLinkArray* iMarkedEntries; |
|
120 /// Ref: The contact view shown in the names list page |
|
121 MVPbkContactViewBase* iNamesListView; |
|
122 /// Ref: The contact view shown in the groups list page |
|
123 MVPbkContactViewBase* iGroupsListView; |
|
124 /// Own: Optional fetch softkey resource id |
|
125 TInt iCbaId; |
|
126 /// Own: Optional navi pane resource id |
|
127 TInt iNaviPaneId; |
|
128 /// Ref: Exit callback |
|
129 MPbk2ExitCallback* iExitCallback; |
|
130 /// Own: SK1 is invisible till user selects defined amount of entries |
|
131 /// default is 1 if not defined by user |
|
132 TInt iMinSelection; |
|
133 }; |
|
134 |
|
135 public: // Construction and destruction |
|
136 |
|
137 /** |
|
138 * Creates a new instance of this class. |
|
139 * |
|
140 * @param aParams The fetch parameters. |
|
141 * @param aObserver Fetch observer. |
|
142 * @return A new instance of this class. |
|
143 */ |
|
144 IMPORT_C static CPbk2FetchDlg* NewL( |
|
145 TParams aParams, |
|
146 MPbk2FetchDlgObserver& aObserver ); |
|
147 |
|
148 /** |
|
149 * Destructor. |
|
150 */ |
|
151 ~CPbk2FetchDlg(); |
|
152 |
|
153 public: // Interface |
|
154 |
|
155 /** |
|
156 * Marks the given contact as selected. |
|
157 * |
|
158 * @param aContactLink Link to a contact to select. |
|
159 */ |
|
160 IMPORT_C void AcceptDelayedFetchL( |
|
161 const TDesC8& aContactLink ); |
|
162 |
|
163 /** |
|
164 * Unmarks the given contact as selected. |
|
165 * |
|
166 * @param aContactLink Link to a contact to select. |
|
167 */ |
|
168 IMPORT_C void DenyDelayedFetchL( |
|
169 const TDesC8& aContactLink ); |
|
170 |
|
171 public: // From CEikDialog |
|
172 IMPORT_C TInt ExecuteLD(); |
|
173 |
|
174 public: // From MPbk2DialogEliminator |
|
175 void RequestExitL( |
|
176 TInt aCommandId ); |
|
177 void ForceExit(); |
|
178 void ResetWhenDestroyed( |
|
179 MPbk2DialogEliminator** aSelfPtr ); |
|
180 |
|
181 private: // From CEikDialog |
|
182 SEikControlInfo CreateCustomControlL( |
|
183 TInt aControlType ); |
|
184 void PreLayoutDynInitL(); |
|
185 TBool OkToExitL( |
|
186 TInt aButtonId ); |
|
187 void PageChangedL( |
|
188 TInt aPageId ); |
|
189 TKeyResponse OfferKeyEventL( |
|
190 const TKeyEvent& aKeyEvent, |
|
191 TEventCode aType ); |
|
192 void HandleResourceChange( |
|
193 TInt aType ); |
|
194 void LineChangedL( |
|
195 TInt aControlId ); |
|
196 |
|
197 private: // From MPbk2FetchDlg |
|
198 CCoeControl* FetchDlgControl( |
|
199 TInt aCtrlId ) const; |
|
200 MVPbkContactViewBase& FetchDlgViewL( |
|
201 TInt aControlId ) const; |
|
202 void SetFetchDlgViewL( |
|
203 TInt aControlId, |
|
204 MVPbkContactViewBase& aView ); |
|
205 MVPbkContactLinkArray& FetchDlgSelection(); |
|
206 void FetchDlgHandleError( |
|
207 TInt aError ); |
|
208 TRect FetchDlgClientRect() const; |
|
209 void FetchDlgPageChangedL( |
|
210 MPbk2FetchDlgPage& aPage ); |
|
211 MPbk2FetchDlgObserver& FetchDlgObserver() const; |
|
212 void SelectContactL( |
|
213 const MVPbkContactLink& aLink, |
|
214 TBool aSelected ); |
|
215 TBool IsSelectPermitted(); |
|
216 |
|
217 private: // From MPbk2StoreConfigurationObserver |
|
218 void ConfigurationChanged(); |
|
219 void ConfigurationChangedComplete(); |
|
220 |
|
221 private: // From MPbk2ControlObserver |
|
222 void HandleControlEventL( |
|
223 MPbk2ContactUiControl& aControl, |
|
224 const TPbk2ControlEvent& aEvent ); |
|
225 |
|
226 private: // From MPbk2FetchResultsObserver |
|
227 void ContactSelected( |
|
228 const MVPbkContactLink& aLink, |
|
229 TBool aSelected ); |
|
230 void ContactSelectionFailed(); |
|
231 |
|
232 private: // Implementation |
|
233 CPbk2FetchDlg( |
|
234 TParams aParams, |
|
235 MPbk2FetchDlgObserver& aObserver ); |
|
236 void ConstructL(); |
|
237 void SetCbaCommandSetL( |
|
238 TInt aResourceId ); |
|
239 void SetupStatusPaneL(); |
|
240 void UpdateCbasL(); |
|
241 void UpdateMultiSelectionMSKL( |
|
242 TBool aContactSelected ); |
|
243 void RemoveCommandFromMSK(); |
|
244 void SetMiddleSoftKeyLabelL( |
|
245 const TInt aResourceId, |
|
246 const TInt aCommandId ); |
|
247 static TInt TryAcceptSelectionL( |
|
248 TAny* aSelf ); |
|
249 TBool CheckIsOkToExitL( |
|
250 TInt aButtonId ); |
|
251 TBool Canceled( |
|
252 TInt aButtonId ); |
|
253 void SkinTabsL(); |
|
254 static TInt DelaySkinning( |
|
255 TAny* aFetchDlg ); |
|
256 static TInt RestoreSelections( |
|
257 TAny* aFetchDlg ); |
|
258 void RestoreSelectionsL(); |
|
259 TBool OkToExitApplicationL( |
|
260 TInt aCommandId ); |
|
261 void ExitApplication( |
|
262 TInt aCommandId ); |
|
263 |
|
264 private: // Types and data structures |
|
265 /// Resource data, see PBK2_FETCHENTRY_DIALOG. |
|
266 struct TResData |
|
267 { |
|
268 /** |
|
269 * Reads the data from resources. |
|
270 * |
|
271 * @param aReader Resource reader pointed |
|
272 * to PBK2_FETCHENTRY_DIALOG resource. |
|
273 */ |
|
274 void ReadFromResource( |
|
275 TResourceReader& aReader ); |
|
276 |
|
277 /// Own: Dialog resource id |
|
278 TInt iDialogId; |
|
279 /// Own: CBA resource id |
|
280 TInt iCbaId; |
|
281 /// Own: Empty CBA resource id |
|
282 TInt iEmptyCbaId; |
|
283 /// Own: Navi pane resource id |
|
284 TInt iNaviPaneId; |
|
285 }; |
|
286 |
|
287 private: // Data |
|
288 /// Own: Parameters |
|
289 TParams iParams; |
|
290 /// Own: Resource data |
|
291 TResData iResData; |
|
292 /// Own: Navi pane control |
|
293 CAknNavigationDecorator* iNaviDecorator; |
|
294 /// Ref: Set to NULL when this dialog is destroyed |
|
295 MPbk2DialogEliminator** iSelfPtr; |
|
296 /// Ref: Set to ETrue when the execution enters destructor |
|
297 TBool* iDestroyedPtr; |
|
298 /// Own: Dialog pages |
|
299 MPbk2FetchDlgPages* iPages; |
|
300 /// Own: Current CBA command set |
|
301 TInt iCbaCommandSet; |
|
302 /// Own: Detect store status. |
|
303 CPbk2StoreConfiguration* iStoreConfiguration; |
|
304 /// Ref: Observer |
|
305 MPbk2FetchDlgObserver& iObserver; |
|
306 /// Own: Exit handling |
|
307 TBitFlags8 iExitRecord; |
|
308 /// Own: Dialog accepter |
|
309 CAsyncCallBack* iDialogAccepter; |
|
310 /// Own: Delay for tab skinning |
|
311 CIdle* iTabSkinDelay; |
|
312 /// Own: Fetch results |
|
313 CPbk2FetchResults* iResults; |
|
314 /// Own: Link to focused contact |
|
315 MVPbkContactLink* iFocusedContactLink; |
|
316 /// Own: Delay for restoring selections |
|
317 CIdle* iSelectionRestorer; |
|
318 /// Own: Set to EFalse if MSK is not enabled in the current layout |
|
319 TBool iMSKEnabled; |
|
320 /// Not own: Names list control |
|
321 CPbk2NamesListControl* iNamesListControl; |
|
322 /// Not own: Group list control |
|
323 CPbk2NamesListControl* iGroupListControl; |
|
324 /// Is selection permitted |
|
325 TBool iSelectPermitted; |
|
326 }; |
|
327 |
|
328 #endif // CPBK2FETCHDLG_H |
|
329 |
|
330 // End of File |