|
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: XDM GS plugin Settings list container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef GS_XDMPLUGIN_SL_CONTAINER_H |
|
22 #define GS_XDMPLUGIN_SL_CONTAINER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <bldvariant.hrh> |
|
26 #include <coeccntx.h> |
|
27 #include <eikclb.h> |
|
28 #include <aknview.h> |
|
29 |
|
30 #include "XDMPlugin.hrh" |
|
31 |
|
32 // FORWARD DECLARATION |
|
33 class CGSListBoxItemTextArray; |
|
34 class CEikTextListBox; |
|
35 class CSettingsData; |
|
36 class CXDMPluginSettinglist; |
|
37 class CAknColumnListBox; |
|
38 class CAknViewAppUi; |
|
39 |
|
40 /** |
|
41 * CXDMPluginSLContainer Settings list container class |
|
42 */ |
|
43 class CXDMPluginSLContainer : public CCoeControl, MEikListBoxObserver |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * C++ Constructor |
|
49 */ |
|
50 CXDMPluginSLContainer(CAknView* aView); |
|
51 |
|
52 /** |
|
53 * Symbian OS constructor. |
|
54 * @param aRect Listbox's rect. |
|
55 */ |
|
56 void ConstructL( const TRect& aRect); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 ~CXDMPluginSLContainer(); |
|
62 |
|
63 public: // From CCoeControl |
|
64 |
|
65 /** |
|
66 * See CCoeControl. |
|
67 */ |
|
68 TInt CountComponentControls() const; |
|
69 |
|
70 /** |
|
71 * See CCoeControl. |
|
72 */ |
|
73 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
74 |
|
75 /** |
|
76 * See CCoeControl. |
|
77 */ |
|
78 TKeyResponse OfferKeyEventL( |
|
79 const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
80 |
|
81 /** |
|
82 * See CCoeControl. |
|
83 */ |
|
84 void SizeChanged(); |
|
85 |
|
86 /** |
|
87 * See CCoeControl. |
|
88 */ |
|
89 void Draw(const TRect& aRect) const; |
|
90 |
|
91 /** |
|
92 * See CCoeControl |
|
93 */ |
|
94 void HandleResourceChange( TInt aType ); |
|
95 |
|
96 /** |
|
97 * Gets help context |
|
98 */ |
|
99 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
100 |
|
101 /** |
|
102 * See CCoeControl |
|
103 */ |
|
104 void FocusChanged(TDrawNow aDrawNow); |
|
105 |
|
106 public: |
|
107 |
|
108 /** |
|
109 * Edit currently focused item on settings list. called from UI |
|
110 */ |
|
111 void EditCurrentItemL(); |
|
112 |
|
113 /** |
|
114 * See MEikListBoxObserver |
|
115 */ |
|
116 void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); |
|
117 |
|
118 /** |
|
119 * Prepare the XDM set with given name for editing |
|
120 * @param aXDMSetName reference to the XDM set name to be edited |
|
121 */ |
|
122 void PrepareXDMSetForEditingL(TDesC& aXDMSetName); |
|
123 |
|
124 /** |
|
125 * Prepare the a new XDM set with default values |
|
126 * @param none |
|
127 */ |
|
128 void PrepareXDMSetNewDefaultL(); |
|
129 |
|
130 /** |
|
131 * Prepare the a new XDM set with values from an existing set |
|
132 * @param aXDMSetName reference to the new XDM set name |
|
133 */ |
|
134 void PrepareNewXDMSetFromExistingL(TDesC& aXDMSetName); |
|
135 |
|
136 /** |
|
137 * Display the dialog to the user to select the creation of new set |
|
138 * from existing sets. Saves the selected name to iData |
|
139 * @return ETrue if user has choosen a set, return EFalse if user cancels |
|
140 */ |
|
141 TBool DisplayNewXDMSetOptionsL(); |
|
142 |
|
143 /** |
|
144 * Called by the UI when back button is pressed, to perform needed steps |
|
145 * @return ETrue if settings list is allowed to close |
|
146 */ |
|
147 TBool IsExitProcessingOKL(); |
|
148 |
|
149 /** |
|
150 * Handle manual resource change with its type |
|
151 * @param aType, type of resource |
|
152 */ |
|
153 void HandleResourceChangeManual(TInt aType); |
|
154 |
|
155 /** |
|
156 * Save settings if possible, without any user interaction. |
|
157 * this is useful for force exit, e.g. when mmc taken out |
|
158 */ |
|
159 void SaveSettingsIfPossibleL(); |
|
160 |
|
161 /** |
|
162 * Return the name of current set in iData |
|
163 * @return TDes reference to current set |
|
164 */ |
|
165 TDes& GetCurrentSetName(); |
|
166 |
|
167 |
|
168 private: // Most of these methods perform operations using iData |
|
169 |
|
170 /** |
|
171 * Sets the title pane text with given discriptor |
|
172 * @param aTitleText text to be shown on title pane |
|
173 */ |
|
174 void SetTitlePaneTextL( const TDesC& aTitleText ) const; |
|
175 |
|
176 /** |
|
177 * Finds out whether compulsory items are filled |
|
178 * @return ETrue if compulsory items are filled |
|
179 */ |
|
180 TBool AreCompulsoryItemsFilled(); |
|
181 |
|
182 /** |
|
183 * Display a query dialog to user that compulsory settings are not |
|
184 * filled, and if user wants to delete the settings |
|
185 * @return ETrue if user wants to delete the settings |
|
186 */ |
|
187 TBool DisplayDeleteOrDontSaveDialogL(); |
|
188 |
|
189 /** |
|
190 * Update an XDM set if it already exist or create it if it doesnt exist |
|
191 * @param aShowDialog whether dialog will be displayed or not |
|
192 * @return ETrue if save procedure goes ok |
|
193 */ |
|
194 TBool SaveOrCreateAndSaveXDMSetL(TBool aShowDialog); |
|
195 |
|
196 /** |
|
197 * Deletes the XDM set if it exist in the XDM settings API |
|
198 */ |
|
199 void DeleteXDMSetIfExistL(); |
|
200 |
|
201 /** |
|
202 * Gets the setting id of the given set name |
|
203 * @param aXDMSetName reference to XDM set name |
|
204 * @return settingid of the given xdm set |
|
205 */ |
|
206 TInt GetSettingIdL(TDesC& aXDMSetName); |
|
207 |
|
208 /** |
|
209 * If the given XDM set name with given ID is exist or not |
|
210 * @param aXDMSetName reference to XDM set name |
|
211 * aSettingId settings id of the XDM |
|
212 * @return ETrue of XDM set exist with given name |
|
213 */ |
|
214 TBool IsXDMSetNameExistL(TDesC& aXDMSetName, TInt32& aSettingId); |
|
215 |
|
216 /** |
|
217 * Load XDM Collection names with trap, useful when list doesnt have anything |
|
218 * @param Reference to setting ids |
|
219 * @return CDesCArray collection names |
|
220 */ |
|
221 CDesCArray* LoadCollectionNamesL(RArray<TInt>& aSettingIDs, TBool aDisp); |
|
222 |
|
223 /** |
|
224 * Check the given name and returns the possible altered name. NULL |
|
225 * pointer is returned no change is needed in aName, so aName can be |
|
226 * used if NULL pointer is returned. If some valid pointer is returned |
|
227 * then that pointer is owned by client, and needed to be deleted after |
|
228 * usage. |
|
229 * @param aName, the name from which to start suggestion. |
|
230 * @param aChanged, returns ETrue if an alternate name is returned. |
|
231 * @return HBufC* pointer to the new name, can be NULL if not needed. |
|
232 */ |
|
233 HBufC* DoMakeValidNameL(HBufC* aName, TBool& aChanged); |
|
234 |
|
235 /** |
|
236 * Ensures that the passed name is valid, length > 0 & length < max. |
|
237 * If length == 0, leaves with KErrInvalidName |
|
238 * If name is only whitespace, leaves with KErrInvalidName |
|
239 * If name is longer than max, name is truncated |
|
240 * It copies the name, pushes it onto the CleanupStack and passes |
|
241 * ownership. |
|
242 |
|
243 * @param aName The name |
|
244 * @param aChanged A reference to a boolean to hold whether the name |
|
245 * had been changed or not. |
|
246 * @return The valid-length name |
|
247 */ |
|
248 HBufC* EnsureMaxLengthLC( const TDesC* aName, TBool& aChanged); |
|
249 |
|
250 /** |
|
251 * Given aName in the format <prefix> or |
|
252 * <prefix><brace><integer><brace>, return a |
|
253 * pointer to the leading part. That is, if there is |
|
254 * trailing <space><integer>, then that is excluded; |
|
255 * if there is no trailing part, then the original |
|
256 * decriptor is returned. |
|
257 * Examples: |
|
258 * - "Foo" returns "Foo"; |
|
259 * - "Foo 12" returns "Foo 12"; |
|
260 * - "Foo(12)" returns "Foo"; |
|
261 * - "Foo 12 (34)" returns "Foo 12 "; |
|
262 * - "Foo bar" returns "Foo bar"; |
|
263 * - "Foo " returns "Foo ". |
|
264 * @param aName The name to get the prefix from |
|
265 * @return The prefix |
|
266 */ |
|
267 TPtrC GetPrefix( const TDesC& aName ); |
|
268 |
|
269 |
|
270 /** |
|
271 * If aName is constructed from aPrefix with a postfix, get the numeric |
|
272 * value of the postfix, e.g: |
|
273 * - GetPostfix( "Foo (3)", "Foo" ) == 3 |
|
274 * - GetPostfix( "Foo 23 (45)", "Foo 23" ) == 45 |
|
275 * If aName is the same as aPrefix, return 0, e.g.: |
|
276 * - GetPostfix( "Foo", "Foo" ) == 0 |
|
277 * If aName is not constructed from aPrefix, return -1, e.g.: |
|
278 * - GetPostfix( "Foobar", "Foo" ) == -1 |
|
279 * - GetPostfix( "Fo 23 45", "Foo" ) == -1 |
|
280 * @param aName The name to get the postfix from |
|
281 * @param aPrefix The prefix |
|
282 * @return The postfix |
|
283 */ |
|
284 TInt GetPostfix( const TDesC& aName, const TDesC& aPrefix ); |
|
285 |
|
286 |
|
287 private: // data |
|
288 |
|
289 // CXDMPluginSettinglist owned |
|
290 CXDMPluginSettinglist* iSettingList; |
|
291 |
|
292 // Pointer to settings data owned |
|
293 CSettingsData* iData; |
|
294 |
|
295 // Pointer to the application view, not owned |
|
296 CAknView* iView; // not owned |
|
297 |
|
298 }; |
|
299 |
|
300 #endif //GS_XDMPLUGIN_SL_CONTAINER_H |