|
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 * Base class for WML subitems. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CWMLSUBITEMBASE_H |
|
22 #define CWMLSUBITEMBASE_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <badesca.h> // CDesCArray |
|
27 #include "WMLBC.hrh" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class CMsgNameValue; |
|
32 |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Base class for WML subitems for WML Bio Control's internal use. |
|
38 * Instances of this class may not be initialized. Class is intented |
|
39 * to be inherited. |
|
40 */ |
|
41 NONSHARABLE_CLASS( CWmlSubItemBase ) : public CBase |
|
42 { |
|
43 |
|
44 public: // Construction / Destruction |
|
45 |
|
46 /** |
|
47 * Destructor. |
|
48 * Deletes the member iName. |
|
49 */ |
|
50 ~CWmlSubItemBase(); |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Contains the logic to store the item to the database. This |
|
56 * is template method, which calls the actual implemtation methods |
|
57 * in the subclass. |
|
58 * @param aShowNote indicates whether to show note after item has |
|
59 * been stored. By default note is shown. |
|
60 * Leaves if the database operation fails. |
|
61 */ |
|
62 TBool SaveItemL( TBool aShowNote = ETrue, |
|
63 TBool aShowPreferredQuery = ETrue, |
|
64 TBool aPreferredInformation = EFalse, |
|
65 TBool aCreateBookmarkIfNotSetAsDefault = EFalse ); |
|
66 |
|
67 /** |
|
68 * Get the item's data. |
|
69 * @return reference to an array containing items data. |
|
70 */ |
|
71 CArrayPtrFlat<CMsgNameValue>* LabelsAndValuesLC(); |
|
72 |
|
73 public: // virtual methods, which must be implemented in subclasses. |
|
74 |
|
75 /** |
|
76 * Interface for adding value for certain field. Note: The values |
|
77 * might be converted to the internal data structure and can be |
|
78 * retrieved in viewable format later. |
|
79 * @param aFieldValue Value of the field to be added. |
|
80 * @param aFieldEnum OTA parser specific enum of the field to add. |
|
81 * @exception Leaves if invalid value or field is being added. |
|
82 */ |
|
83 virtual void AddFieldL( |
|
84 const TDesC& aFieldValue, |
|
85 const TInt aFieldEnum ) = 0; |
|
86 |
|
87 /** |
|
88 * Interface for getting the count of rows needed to display |
|
89 * data in detail view. |
|
90 * @return Number of fields in item, aka rows needed in detail |
|
91 * view. |
|
92 */ |
|
93 virtual TInt FieldCount() const = 0; |
|
94 |
|
95 /** |
|
96 * Interface for getting the label and value of a field in at |
|
97 * certain index. The texts returned are localized. The texts |
|
98 * are stored in HBufCPair object which is created and pushed to |
|
99 * cleanup stack. |
|
100 * @param aIndex Pointer to field which data is to be retrieved. |
|
101 * 0 <= aIndex < GetFieldCount() |
|
102 * @return pointer to a class holding both label and value of a field. |
|
103 * @exception Leaves if index is out of range. |
|
104 */ |
|
105 virtual CMsgNameValue* GetFieldDataAtLC( const TInt aIndex ) = 0; |
|
106 |
|
107 /** |
|
108 * Check the item validity. |
|
109 * @return ETrue if the item is valid, EFalse if it's not. |
|
110 */ |
|
111 virtual TBool IsValidL() = 0; |
|
112 |
|
113 private: // private virtual methods called from SaveItemL-method. |
|
114 |
|
115 /** |
|
116 * Initialize all the member variable to their initial state. |
|
117 * So if leave occurs nothing about the aborted operation is |
|
118 * not saved. |
|
119 */ |
|
120 virtual void DoInitialize() = 0; |
|
121 |
|
122 /** |
|
123 * Get the maximum lenght of the name. |
|
124 * @return Max length of the name for this sub item type. |
|
125 */ |
|
126 virtual TInt NameMaxLength() = 0; |
|
127 |
|
128 /** |
|
129 * Get the item's name. |
|
130 * @return Pointer to the HBufC, which is pushed to the cleanupstack. |
|
131 * Name may also be empty. |
|
132 */ |
|
133 virtual HBufC* NameLC() = 0; |
|
134 |
|
135 /** |
|
136 * Set the item's name. |
|
137 * @param aName New name of the item. |
|
138 */ |
|
139 virtual void SetNameL( const TDesC& aName ) = 0; |
|
140 |
|
141 /** |
|
142 * Get the item's default name. |
|
143 * @return Pointer to the HBufC, which is in cleanupstack. |
|
144 */ |
|
145 virtual HBufC* DefaultNameLC() = 0; |
|
146 |
|
147 /** |
|
148 * Display new name query for this type of item. |
|
149 * @param aName original name to be displayed in query. |
|
150 * @return descriptor got as the query result. |
|
151 */ |
|
152 virtual HBufC* DoQueryNewNameLC( const TDesC& aName ) = 0; |
|
153 |
|
154 /** |
|
155 * Display rename query for this type of item. |
|
156 * @param aName original name to be displayed in query. |
|
157 * @return ETrue if user renamed, EFalse if cancel was pressed. |
|
158 */ |
|
159 virtual TBool DoRenameQueryL( const TDesC& aName ) = 0; |
|
160 |
|
161 /* |
|
162 * Performs the name uniqueness test. |
|
163 * @param aName name to check. |
|
164 * @param aUpdateList optimizes the checking. |
|
165 * @return ETrue if name is unique in the used database. |
|
166 * EFalse if the name already exists in the database. |
|
167 */ |
|
168 virtual TBool IsNameValidL( const TDesC& aName, |
|
169 TBool aUpdateList ) = 0; |
|
170 |
|
171 /** |
|
172 * Does the operations needed before the item is actually |
|
173 * store to the database. |
|
174 */ |
|
175 virtual void PreStoreL( const TBool aShowPreferredQuery ) = 0; |
|
176 |
|
177 /** |
|
178 * Actually store the item to the database. |
|
179 * All the unique checks MUST be done before calling |
|
180 * this method. Leaves if the database operation fails. |
|
181 */ |
|
182 virtual void StoreL() = 0; |
|
183 |
|
184 /** |
|
185 * Does the operation needed after the item has been |
|
186 * SUCCESSFULLY stored to the database. This method must |
|
187 * not be called if database operation has failed. |
|
188 * @param aShowNote indicates if note is shown after store. |
|
189 */ |
|
190 virtual void PostStoreL( const TBool aShowNote, const TInt aPreferredInformation, const TBool aCreateBookmarkIfNotSetAsDefault ) = 0; |
|
191 |
|
192 private: // Methods, which are implemented in this class. |
|
193 |
|
194 /** |
|
195 * Set all the member variables as initial values. |
|
196 */ |
|
197 void Initialize(); |
|
198 |
|
199 /** |
|
200 * Check if the item has name. |
|
201 */ |
|
202 TBool HasNameL(); |
|
203 |
|
204 /** |
|
205 * Set the item's default name in iName. |
|
206 */ |
|
207 void SetDefaultNameL(); |
|
208 |
|
209 /* |
|
210 * Calls the item's IsNameValidL method by givin iName as a parameter. |
|
211 * @return ETrue if name is unique in the used database. |
|
212 * EFalse if the name already exists in the database. |
|
213 */ |
|
214 TBool IsNameValidL( TBool aUpdateList = ETrue ); |
|
215 |
|
216 /** |
|
217 * Calls the static implementation DoIncrementNameL giving the |
|
218 * object name member pointer as a parameter. |
|
219 * @see DoIncrementNameL |
|
220 */ |
|
221 void IncrementNameL(); |
|
222 |
|
223 /** |
|
224 * Static Implementation of the name increment. |
|
225 * Name increment rules are defined and implemented in CMsgBioControl. |
|
226 * @param aName pointer to the HBufC, which is modified. |
|
227 * @param aMaxLength maximum length of the descriptor to be grown. |
|
228 */ |
|
229 static HBufC* DoIncrementNameL( const TDesC& aName, TInt aMaxLength ); |
|
230 |
|
231 /** |
|
232 * Calls the static implementation DoQueryNewNameL giving the |
|
233 * object name member pointer as a parameter. |
|
234 * @see DoQueryNewNameL |
|
235 */ |
|
236 void QueryNewNameL(); |
|
237 |
|
238 /** |
|
239 * Calls the static implementation DoRenameQueryL. |
|
240 * @return ETrue if user chose to overwrite, EFalse otherwise. |
|
241 * @see DoRenameQueryL |
|
242 */ |
|
243 TBool RenameQueryL(); |
|
244 |
|
245 private: |
|
246 |
|
247 /** |
|
248 * Item's original name is stored and restored after storing |
|
249 * Procedure. |
|
250 */ |
|
251 HBufC* iOriginalName; |
|
252 |
|
253 /// Pointer to the item name, which is used to create unique name. |
|
254 HBufC* iName; |
|
255 }; |
|
256 |
|
257 #endif // CWMLSUBITEMBASE_H |
|
258 |
|
259 // End of file |