|
1 /* |
|
2 * Copyright (c) 2009 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 * Defines an ordered list of widget id's with persistence capability |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef WMPERSISTENTWIDGETORDER_H |
|
20 #define WMPERSISTENTWIDGETORDER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "wmwidgetdata.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class RFs; |
|
28 |
|
29 // CLASS DECLARATION |
|
30 /** |
|
31 * CWmPersistentWidgetOrder |
|
32 * This class is an ordered list of widget identifiers. The list can be |
|
33 * serialised and extract from stream and persisted. The list can be used |
|
34 * in sorting a pointer array of CWmWidgetData. |
|
35 */ |
|
36 NONSHARABLE_CLASS( CWmPersistentWidgetOrder ) : public CBase |
|
37 { |
|
38 |
|
39 public: // Constructors and destructor |
|
40 /** |
|
41 * static constructor. |
|
42 */ |
|
43 static CWmPersistentWidgetOrder* NewL( RFs& aFs ); |
|
44 |
|
45 /** Destructor. */ |
|
46 ~CWmPersistentWidgetOrder(); |
|
47 |
|
48 private: // private construction |
|
49 |
|
50 /** |
|
51 * constructor |
|
52 */ |
|
53 CWmPersistentWidgetOrder( RFs& aFs ); |
|
54 |
|
55 /** |
|
56 * 2nd phase constructor |
|
57 */ |
|
58 void ConstructL(); |
|
59 |
|
60 |
|
61 public: // API |
|
62 |
|
63 /** |
|
64 * Loads the persistent widget list from storage. |
|
65 * This is typically done once after construction. |
|
66 */ |
|
67 void LoadL(); |
|
68 |
|
69 /** |
|
70 * Stores a sorted array of WmWidgetData types as the persistent list. |
|
71 * The instance can now be used to sort widget data. |
|
72 * |
|
73 * @param aArray the array of widget daya types |
|
74 */ |
|
75 void StoreL( const RWidgetDataValues& aArray ); |
|
76 |
|
77 /** |
|
78 * Retrieves an index of given widget data object within the list. |
|
79 * This index can be used to sort and organise. |
|
80 * |
|
81 * @param aWidgetData data to seek index of in the sorted order |
|
82 * @return the index found, or KErrNotFound if widget is new |
|
83 */ |
|
84 TInt IndexOf( const CWmWidgetData& aWidgetData ) const; |
|
85 |
|
86 /** |
|
87 * checks if the persistent widget order is empty. In this case it does |
|
88 * not make any sense to use the object to sort anything. |
|
89 * Note that before loading the object is always empty. |
|
90 */ |
|
91 TBool IsEmpty() const; |
|
92 |
|
93 protected: |
|
94 |
|
95 /** |
|
96 * Cleans up the array |
|
97 */ |
|
98 void CleanupArray(); |
|
99 |
|
100 /** |
|
101 * build the storage file path and name. The storage file will be located |
|
102 * in host process private directory. |
|
103 * @param aPathBuf a buffer to receive the complete file path |
|
104 */ |
|
105 void GetStoreFileNameL( TDes& aPathBuf ); |
|
106 |
|
107 /** |
|
108 * Unique tag of a widget |
|
109 */ |
|
110 class Tag |
|
111 { |
|
112 public: |
|
113 /** constructs a tag from parameters */ |
|
114 Tag( TInt32 aUid, HBufC16* aPublisherId ); |
|
115 |
|
116 /** compares a tag agains a widget data */ |
|
117 TBool Matches( const CWmWidgetData& aWidgetData ) const; |
|
118 |
|
119 /** widget uid */ |
|
120 TInt32 iUid; |
|
121 |
|
122 /** widget publisher id */ |
|
123 HBufC16* iPublisherId; |
|
124 }; |
|
125 |
|
126 private: // data members |
|
127 |
|
128 /** the file session */ |
|
129 RFs& iFs; |
|
130 |
|
131 /** array of widget tags for sorting */ |
|
132 RArray<Tag> iTagArray; |
|
133 |
|
134 }; |
|
135 |
|
136 |
|
137 #endif // WMPERSISTENTWIDGETORDER_H |