|
1 /* |
|
2 * Copyright (c) 2004 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: Presence Attribute Manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __MPENGPRESENCEATTRMANAGER_H |
|
19 #define __MPENGPRESENCEATTRMANAGER_H |
|
20 |
|
21 |
|
22 //INCLUDES |
|
23 #include <E32std.h> |
|
24 #include "BaMDescA.h" |
|
25 #include "BaDescA.h" |
|
26 |
|
27 |
|
28 //DATA TYPES |
|
29 |
|
30 /** |
|
31 * Attribute instance options. |
|
32 * |
|
33 * @since 3.0 |
|
34 */ |
|
35 enum TPEngAttributeInstanceOptions |
|
36 { |
|
37 /// |
|
38 EPEngInstanceOptionsNone = 0x0, |
|
39 |
|
40 /// |
|
41 EPEngUserAttribute = 0x00000001, |
|
42 |
|
43 /// |
|
44 EPEngStorableModel = 0x00000002, |
|
45 |
|
46 /// |
|
47 EPEngEditLockedModel = 0x00000004, |
|
48 |
|
49 /// |
|
50 EPEngCreationNotAllowed = 0x00000008, |
|
51 }; |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 //FORWARD DECLARATIONS |
|
57 class MPEngPresenceAdvancedAttrModel2; |
|
58 class MPEngPresenceAttrModel2; |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 // CLASS DECLARATION |
|
64 /** |
|
65 * Interface for Presence Attribute Manager. |
|
66 * |
|
67 * NOTE!!! Attribute Manager is reference counted singleton, so client |
|
68 * which has retrieved a instance to it, must also free it |
|
69 * by calling MPEngPresenceAttrManager::Close(), when the manager isn't |
|
70 * needed anymore. |
|
71 * |
|
72 * @since 3.0 |
|
73 */ |
|
74 class MPEngPresenceAttrManager |
|
75 { |
|
76 public: //Reference cleanup |
|
77 |
|
78 /** |
|
79 * Attribute Manager is reference counted singleton. |
|
80 * and clients must free all obtained instances by |
|
81 * calling this to each of them when the Attribute Manager |
|
82 * isn't anymore needed. |
|
83 * |
|
84 * @since 3.0 |
|
85 */ |
|
86 virtual void Close() = 0; |
|
87 |
|
88 |
|
89 |
|
90 public: //Attribute model |
|
91 |
|
92 |
|
93 |
|
94 /** |
|
95 * Instantiates attribute model. |
|
96 * |
|
97 * @since 3.0 |
|
98 * @param aModel On the return the instantiated attribute model. |
|
99 * Returned model is pushed on the CleanupStack. Returns ownership. |
|
100 * @param aPresenceID The attribute owners presence ID. |
|
101 * @param aType Presence attribute type. |
|
102 * @param aInstanceGenre The instance genre for new attribute instance. |
|
103 */ |
|
104 virtual void InstantiateAttributeLC( MPEngPresenceAttrModel2*& aModel, |
|
105 const TDesC& aPresenceID, |
|
106 TUint32 aType, |
|
107 TInt aInstanceOptions ) = 0; |
|
108 |
|
109 |
|
110 /** |
|
111 * Instantiates and loads attribute model. |
|
112 * |
|
113 * @since 3.0 |
|
114 * @param aModel On the return the loaded attribute model. |
|
115 * Returned model is pushed on the CleanupStack. Returns ownership. |
|
116 * @param aPresenceID The attribute owners presence ID. |
|
117 * @param aType Presence attribute type. |
|
118 * @param aInstanceGenre The instance genre for new attribute instance. |
|
119 * @return Was the model found from storage? |
|
120 * KErrNotFound if attribute wasn't found from storage. |
|
121 * Else KErrNone. |
|
122 */ |
|
123 virtual TInt LoadAttributeLC( MPEngPresenceAttrModel2*& aModel, |
|
124 const TDesC& aPresenceID, |
|
125 TUint32 aType, |
|
126 TInt aInstanceOptions ) = 0; |
|
127 |
|
128 |
|
129 /** |
|
130 * Stores attribute model to storage. |
|
131 * |
|
132 * @since 3.0 |
|
133 * @param aModel The model to store. |
|
134 */ |
|
135 virtual void StoreEditLockedAttributeL( const MPEngPresenceAttrModel2& aModel ) = 0; |
|
136 |
|
137 |
|
138 /** |
|
139 * Releases the edit support from the attribute model. |
|
140 * |
|
141 * @since 3.0 |
|
142 * @param aModel The model. |
|
143 * @return Error code. |
|
144 */ |
|
145 virtual TInt StopEditSupport( MPEngPresenceAttrModel2& aModel ) const = 0; |
|
146 |
|
147 |
|
148 /** |
|
149 * Checks is the attribute model edit locked from |
|
150 * the same slot as the Attribute Manager is connected. |
|
151 * |
|
152 * @since 3.0 |
|
153 * @param aModel The model. |
|
154 */ |
|
155 virtual void ModelEditLockedFromThisSlotL( |
|
156 const MPEngPresenceAttrModel2& aModel ) const = 0; |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 public: //Attribute type information |
|
162 |
|
163 /** |
|
164 * Tests is the passed attribute type id a valid network attribute |
|
165 * or not. Returns: |
|
166 * - KErrNone if the attribute type is a valid network attribute. |
|
167 * - KErrUnknown if the attribute id is unknown. |
|
168 * - KErrNotSupported if the attribute id is known, |
|
169 * but the attribute isn't a valid network attribute |
|
170 * (Attribute is a local attribute.) |
|
171 * |
|
172 * Attribute type is a valid network attribute if it's originator |
|
173 * is one of following: |
|
174 * - EPEngClientOriginated |
|
175 * - EPEngServerOriginated |
|
176 * - EPEngClientServerOriginated |
|
177 * |
|
178 * @since 3.0 |
|
179 * @param aType the type of the attribute. |
|
180 * @return KErrNone, KErrUnknown or KErrNotSupported. |
|
181 */ |
|
182 virtual TInt ValidNetworkAttribute( TUint32 aType ) const = 0; |
|
183 |
|
184 |
|
185 /** |
|
186 * Returns the generic array holding all known attribute types. |
|
187 * |
|
188 * @since 3.0 |
|
189 * @return The generic array holding all known attribute types. |
|
190 */ |
|
191 virtual TArray<TUint32> KnownAttributeTypes() const = 0; |
|
192 |
|
193 |
|
194 /** |
|
195 * Gets the XML name and XML namespace for certain attribute type. |
|
196 * If the attribute type isn't known, returns KErrUnknown and empty |
|
197 * string as name and namespace. |
|
198 * |
|
199 * @since 3.0 |
|
200 * @param aAttributeType The attribute type for which to get name and namespace. |
|
201 * @param aAttributeName On the return contains the asked attribute's XML name. |
|
202 * @param aAttributeName On the return contains the asked attribute's XML namespace. |
|
203 * @return KErrNone if the attribute type is known, else KErrUnknown. |
|
204 */ |
|
205 virtual TInt GetAttributeXmlNameAndNameSpace( TUint32 aType, |
|
206 TPtrC8& aAttributeName, |
|
207 TPtrC8& aAttributeNameSpace ) const = 0; |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 public: // Attribute request packing |
|
213 |
|
214 |
|
215 /** |
|
216 * Packs a attribute model array to buffer. |
|
217 * |
|
218 * @since 3.0 |
|
219 * @param aModels Models to pack. |
|
220 * @return Heap buffer containing models data. |
|
221 * Buffer ownership is returned to caller. |
|
222 */ |
|
223 virtual HBufC16* PackModelArrayL( |
|
224 const RPointerArray<MPEngPresenceAttrModel2>& aModels ) const = 0; |
|
225 |
|
226 |
|
227 /** |
|
228 * Extracts models from package. |
|
229 * |
|
230 * @since 3.0 |
|
231 * @param aModelPkg Model package to extract. |
|
232 * @param aInstanceOptions Instance options |
|
233 * for instantiated attribute models. |
|
234 * @param aModels On the return contains extracted attribute models. |
|
235 * Models are appended to array. |
|
236 */ |
|
237 virtual void UnpackModelArrayL( |
|
238 const TDesC16& aModelPkg, |
|
239 TInt aInstanceOptions, |
|
240 RPointerArray<MPEngPresenceAttrModel2>& aModels ) = 0; |
|
241 |
|
242 |
|
243 |
|
244 /** |
|
245 * Packs a attribute fetch request. |
|
246 * |
|
247 * @since 3.0 |
|
248 * @param aPresenceIDs Presence ID's to pack. |
|
249 * @param aTypes Attribute types to pack. |
|
250 * @return Heap buffer containing fetch request data. |
|
251 * Buffer ownership is returned to caller. |
|
252 */ |
|
253 virtual HBufC16* PackFetchRequestL( const MDesCArray& aPresenceIDs, |
|
254 const TArray<TUint32>& aTypes ) const = 0; |
|
255 |
|
256 |
|
257 /** |
|
258 * Extracts a attribute fetch request from package. |
|
259 * |
|
260 * @since 3.0 |
|
261 * @param aFetchRequestPkg Attribute fetch request package to extract. |
|
262 * @param aPresenceIDs On the return contains extracted Presence IDs. |
|
263 * Presence IDs are appended to the end of array. |
|
264 * @param aTypes On the return contains extracted attribute type IDs. |
|
265 * Attribute types are appended to the end of array. |
|
266 */ |
|
267 virtual void UnpackFetchRequestL( const TDesC16& aFetchRequestPkg, |
|
268 CDesCArray& aPresenceIDs, |
|
269 RArray<TUint32>& aTypes ) const = 0; |
|
270 |
|
271 |
|
272 public: // Attribute store ID handling |
|
273 |
|
274 /** |
|
275 * Generates a attribute store id from given |
|
276 * attribute type and presence id. Returns store id |
|
277 * in HBufC. HBufC's ownership is returned to caller. |
|
278 * |
|
279 * @since 3.0 |
|
280 * @param aAttributeType The type of the attribute |
|
281 * @param aPresenceID The presenceID of the attribute |
|
282 * @return Attribute StoreId. |
|
283 */ |
|
284 virtual HBufC* GenerateStoreIdL( TUint32 aAttributeType, |
|
285 const TDesC& aPresenceId ) const = 0; |
|
286 |
|
287 |
|
288 /** |
|
289 * Resolves attribute type and owner presence id |
|
290 * from store id. |
|
291 * |
|
292 * @since 3.0 |
|
293 * @param aStoreId The store id to resolve. |
|
294 * @param aAttributeType On succesful return contains resolved attribute type. |
|
295 * @param aPresenceId On successful return contains resolved presence id. |
|
296 * Returned aPresenceId is valid only for the lifetime of given source store id. |
|
297 * @return KErrNone if succesful. KErrCorrupt if given aStoreId |
|
298 * isn't valid attribute store id. |
|
299 */ |
|
300 virtual TInt ResolveStoreId( const TDesC& aStoreId, |
|
301 TUint32& aAttributeType, |
|
302 TPtrC& aPresenceId ) const = 0; |
|
303 |
|
304 |
|
305 |
|
306 public: // Batch operations |
|
307 |
|
308 /** |
|
309 * Stores an array of attribute models in a batch to storage. |
|
310 * Force stores the models, so edit locks are ignored. |
|
311 * |
|
312 * @since 3.0 |
|
313 * @param aModel The models to store. |
|
314 */ |
|
315 virtual void ForceStoreBatchL( |
|
316 const RPointerArray<MPEngPresenceAttrModel2> aModels ) = 0; |
|
317 |
|
318 |
|
319 /** |
|
320 * Removes an array of attribute models in a batch from storage. |
|
321 * Force removes the models, so edit locks are ignored. |
|
322 * |
|
323 * @since 3.0 |
|
324 * @param aModel The models to remove from the storage. |
|
325 */ |
|
326 virtual void ForceRemoveFromStoreBatchL( |
|
327 RPointerArray<MPEngPresenceAttrModel2> aModels ) = 0; |
|
328 |
|
329 |
|
330 protected: |
|
331 |
|
332 /** |
|
333 * Protected destructor. |
|
334 * |
|
335 * Concrete Attribute Manager can't be |
|
336 * deleted through this interface. |
|
337 */ |
|
338 virtual ~MPEngPresenceAttrManager() {}; |
|
339 |
|
340 }; |
|
341 |
|
342 #endif // __MPENGPRESENCEATTRMANAGER_H |
|
343 |
|
344 // End of File |