105 |
107 |
106 // --------------------------------------------------------- |
108 // --------------------------------------------------------- |
107 // CWmPersistentWidgetOrder::StoreL |
109 // CWmPersistentWidgetOrder::StoreL |
108 // --------------------------------------------------------- |
110 // --------------------------------------------------------- |
109 // |
111 // |
110 void CWmPersistentWidgetOrder::StoreL( const RWidgetDataValues& aArray ) |
112 void CWmPersistentWidgetOrder::StoreL( const ROrderArray& aArray ) |
111 { |
113 { |
|
114 |
112 // 1. create stream for storing the data to a file |
115 // 1. create stream for storing the data to a file |
113 TFileName storeFileName; |
116 TFileName storeFileName; |
114 GetStoreFileNameL( storeFileName ); |
117 GetStoreFileNameL( storeFileName ); |
115 CPermanentFileStore* fileStore = NULL; |
118 CPermanentFileStore* fileStore = NULL; |
116 fileStore = CPermanentFileStore::ReplaceLC( |
119 fileStore = CPermanentFileStore::ReplaceLC( |
117 iFs, storeFileName, EFileWrite ); |
120 iFs, storeFileName, EFileWrite ); |
118 fileStore->SetTypeL( KPermanentFileStoreLayoutUid ); |
121 |
119 RStoreWriteStream writer; |
122 if ( fileStore ) |
120 TStreamId id = writer.CreateLC( *fileStore ); |
123 { |
121 // 2. write all content to the stream |
124 fileStore->SetTypeL( KPermanentFileStoreLayoutUid ); |
122 writer.WriteInt32L( aArray.Count() ); |
125 RStoreWriteStream writer; |
123 for( TInt i=0; i<aArray.Count(); ++i ) |
126 TStreamId id = writer.CreateLC( *fileStore ); |
124 { |
127 |
125 CWmWidgetData* data = aArray[i]; |
128 // 2. write all content to the stream |
126 if ( !data || !data->IsValid() ) |
129 writer.WriteInt32L( aArray.Count() ); |
|
130 for( TInt i=0; i<aArray.Count(); ++i ) |
127 { |
131 { |
128 User::Leave( KErrArgument ); |
132 CWmWidgetOrderData* data = aArray[i]; |
|
133 |
|
134 if ( !data ) |
|
135 { |
|
136 User::Leave( KErrArgument ); |
|
137 } |
|
138 TInt32 uid = data->Uid().iUid; |
|
139 const TDesC16& publisherId = data->PublisherId(); |
|
140 writer.WriteInt32L( uid ); |
|
141 writer.WriteInt32L( publisherId.Length() ); |
|
142 writer.WriteL( publisherId, publisherId.Length() ); |
|
143 |
129 } |
144 } |
130 TInt32 uid = data->Uid().iUid; |
145 // 3. check available space and commit the stream |
131 const TDesC16& publisherId = data->HsContentInfo().PublisherId(); |
146 TInt streamsize = writer.Sink()->SizeL(); |
132 writer.WriteInt32L( uid ); |
147 TBool belowCriticalLevel = SysUtil::DiskSpaceBelowCriticalLevelL( |
133 writer.WriteInt32L( publisherId.Length() ); |
148 &iFs, streamsize, EDriveC ); |
134 writer.WriteL( publisherId, publisherId.Length() ); |
149 |
135 } |
150 if( !belowCriticalLevel ) |
136 // 3. check available space and commit the stream |
151 { |
137 TInt streamsize = writer.Sink()->SizeL(); |
152 writer.CommitL(); |
138 TBool belowCriticalLevel = SysUtil::DiskSpaceBelowCriticalLevelL( |
153 fileStore->SetRootL(id); |
139 &iFs, streamsize, EDriveC ); |
154 fileStore->CommitL(); |
140 if( !belowCriticalLevel ) |
155 } |
141 { |
156 |
142 writer.CommitL(); |
157 // 4. cleanup |
143 fileStore->SetRootL(id); |
158 CleanupStack::PopAndDestroy( &writer ); |
144 fileStore->CommitL(); |
159 CleanupStack::PopAndDestroy( fileStore ); |
145 } |
160 } |
146 // 4. cleanup |
161 |
147 CleanupStack::PopAndDestroy( &writer ); |
|
148 CleanupStack::PopAndDestroy( fileStore ); |
|
149 } |
162 } |
150 |
163 |
151 // --------------------------------------------------------- |
164 // --------------------------------------------------------- |
152 // CWmPersistentWidgetOrder::CleanupArray |
165 // CWmPersistentWidgetOrder::CleanupArray |
153 // --------------------------------------------------------- |
166 // --------------------------------------------------------- |
209 { |
222 { |
210 return iTagArray.Count() == 0; |
223 return iTagArray.Count() == 0; |
211 } |
224 } |
212 |
225 |
213 // --------------------------------------------------------- |
226 // --------------------------------------------------------- |
|
227 // CWmPersistentWidgetOrder::IndexOf |
|
228 // --------------------------------------------------------- |
|
229 // |
|
230 TInt CWmPersistentWidgetOrder::IndexOf( |
|
231 const CWmWidgetOrderData& aWidgetOrder ) const |
|
232 { |
|
233 TInt found = KErrNotFound; |
|
234 for( TInt i=0; i<iTagArray.Count() && found<0; ++i ) |
|
235 { |
|
236 if ( iTagArray[i].Matches( aWidgetOrder ) ) |
|
237 found = i; |
|
238 } |
|
239 return found; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------- |
214 // CWmPersistentWidgetOrder::Tag::Tag |
243 // CWmPersistentWidgetOrder::Tag::Tag |
215 // --------------------------------------------------------- |
244 // --------------------------------------------------------- |
216 // |
245 // |
217 CWmPersistentWidgetOrder::Tag::Tag( |
246 CWmPersistentWidgetOrder::Tag::Tag( |
218 TInt32 aUid, HBufC16* aPublisherId ) |
247 TInt32 aUid, HBufC16* aPublisherId ) |