1 /* |
|
2 * Copyright (c) 2010 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <FavouritesWapAp.h> |
|
20 |
|
21 #include "engine.h" |
|
22 #include "enginewrapper.h" |
|
23 #include "creator_browser.h" |
|
24 #include "creator_traces.h" |
|
25 |
|
26 |
|
27 static const TInt KBrowserFieldLength = 128; |
|
28 |
|
29 _LIT(KCreatorBrowserPrefixName, "CR_"); |
|
30 _LIT(KCreatorBrowserPrefixFolderName, "CR_FLDR_"); |
|
31 |
|
32 //---------------------------------------------------------------------------- |
|
33 |
|
34 CBrowserParameters::CBrowserParameters() |
|
35 { |
|
36 LOGSTRING("Creator: CBrowserParameters::CBrowserParameters"); |
|
37 |
|
38 iBookmarkName = HBufC::New(KBrowserFieldLength); |
|
39 iBookmarkAddress = HBufC::New(KBrowserFieldLength); |
|
40 iBookmarkUsername = HBufC::New(KBrowserFieldLength); |
|
41 iBookmarkPassword = HBufC::New(KBrowserFieldLength); |
|
42 iBookmarkFolderName = HBufC::New(KBrowserFieldLength); |
|
43 iSavedDeckLinkName = HBufC::New(KBrowserFieldLength); |
|
44 iSavedDeckLocalAddress = HBufC::New(KBrowserFieldLength); |
|
45 iSavedDeckFolderName = HBufC::New(KBrowserFieldLength); |
|
46 } |
|
47 |
|
48 CBrowserParameters::~CBrowserParameters() |
|
49 { |
|
50 LOGSTRING("Creator: CBrowserParameters::~CBrowserParameters"); |
|
51 |
|
52 delete iSavedDeckFolderName; |
|
53 delete iSavedDeckLocalAddress; |
|
54 delete iSavedDeckLinkName; |
|
55 delete iBookmarkFolderName; |
|
56 delete iBookmarkPassword; |
|
57 delete iBookmarkUsername; |
|
58 delete iBookmarkAddress; |
|
59 delete iBookmarkName; |
|
60 |
|
61 } |
|
62 |
|
63 //---------------------------------------------------------------------------- |
|
64 |
|
65 CCreatorBrowser* CCreatorBrowser::NewL(CCreatorEngine* aEngine) |
|
66 { |
|
67 CCreatorBrowser* self = CCreatorBrowser::NewLC(aEngine); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 CCreatorBrowser* CCreatorBrowser::NewLC(CCreatorEngine* aEngine) |
|
73 { |
|
74 CCreatorBrowser* self = new (ELeave) CCreatorBrowser; |
|
75 CleanupStack::PushL(self); |
|
76 self->ConstructL(aEngine); |
|
77 return self; |
|
78 } |
|
79 |
|
80 CCreatorBrowser::CCreatorBrowser() |
|
81 { |
|
82 } |
|
83 |
|
84 void CCreatorBrowser::ConstructL(CCreatorEngine* aEngine) |
|
85 { |
|
86 LOGSTRING("Creator: CCreatorBrowser::ConstructL"); |
|
87 |
|
88 iEngine = aEngine; |
|
89 } |
|
90 |
|
91 CCreatorBrowser::~CCreatorBrowser() |
|
92 { |
|
93 LOGSTRING("Creator: CCreatorBrowser::~CCreatorBrowser"); |
|
94 if ( iEngine && iBmEntryIds.Count() ) |
|
95 { |
|
96 TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmEntryIds, KUidDictionaryUidBrowserBookmarks ) ); |
|
97 } |
|
98 iBmEntryIds.Reset(); |
|
99 iBmEntryIds.Close(); |
|
100 |
|
101 if ( iEngine && iBmFEntryIds.Count() ) |
|
102 { |
|
103 TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmFEntryIds, KUidDictionaryUidBrowserBookmarkF ) ); |
|
104 } |
|
105 iBmFEntryIds.Reset(); |
|
106 iBmFEntryIds.Close(); |
|
107 |
|
108 if ( iEngine && iSpEntryIds.Count() ) |
|
109 { |
|
110 TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpEntryIds, KUidDictionaryUidBrowserSavedPg ) ); |
|
111 } |
|
112 iSpEntryIds.Reset(); |
|
113 iSpEntryIds.Close(); |
|
114 |
|
115 if ( iEngine && iSpFEntryIds.Count() ) |
|
116 { |
|
117 TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpFEntryIds, KUidDictionaryUidBrowserSavedPgF ) ); |
|
118 } |
|
119 iSpFEntryIds.Reset(); |
|
120 iSpFEntryIds.Close(); |
|
121 |
|
122 delete iParameters; |
|
123 } |
|
124 |
|
125 //---------------------------------------------------------------------------- |
|
126 |
|
127 TBool CCreatorBrowser::AskDataFromUserL(TInt aCommand) |
|
128 { |
|
129 LOGSTRING("Creator: CCreatorBrowser::AskDataFromUserL"); |
|
130 |
|
131 CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval |
|
132 |
|
133 TBool result( EFalse ); |
|
134 switch ( aCommand ) |
|
135 { |
|
136 case ECmdDeleteBrowserBookmarks: |
|
137 { |
|
138 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks?"), this, ECreatorModuleDelete ); |
|
139 break; |
|
140 } |
|
141 case ECmdDeleteCreatorBrowserBookmarks: |
|
142 { |
|
143 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks created with Creator?"), this, ECreatorModuleDelete ); |
|
144 break; |
|
145 } |
|
146 case ECmdDeleteBrowserBookmarkFolders: |
|
147 { |
|
148 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders?"), this, ECreatorModuleDelete ); |
|
149 break; |
|
150 } |
|
151 case ECmdDeleteCreatorBrowserBookmarkFolders: |
|
152 { |
|
153 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders created with Creator?"), this, ECreatorModuleDelete ); |
|
154 break; |
|
155 } |
|
156 case ECmdDeleteBrowserSavedPages: |
|
157 { |
|
158 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages?"), this, ECreatorModuleDelete ); |
|
159 break; |
|
160 } |
|
161 case ECmdDeleteCreatorBrowserSavedPages: |
|
162 { |
|
163 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages created with Creator?"), this, ECreatorModuleDelete ); |
|
164 break; |
|
165 } |
|
166 case ECmdDeleteBrowserSavedPageFolders: |
|
167 { |
|
168 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders?"), this, ECreatorModuleDelete ); |
|
169 break; |
|
170 } |
|
171 case ECmdDeleteCreatorBrowserSavedPageFolders: |
|
172 { |
|
173 result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders created with Creator?"), this, ECreatorModuleDelete ); |
|
174 break; |
|
175 } |
|
176 default: |
|
177 { |
|
178 result = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); |
|
179 break; |
|
180 } |
|
181 } |
|
182 return result; |
|
183 } |
|
184 |
|
185 |
|
186 //---------------------------------------------------------------------------- |
|
187 |
|
188 TInt CCreatorBrowser::CreateBookmarkEntryL(CBrowserParameters *aParameters) |
|
189 { |
|
190 LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkEntryL"); |
|
191 |
|
192 // clear any existing parameter definations |
|
193 delete iParameters; |
|
194 iParameters = NULL; |
|
195 |
|
196 CBrowserParameters* parameters = aParameters; |
|
197 |
|
198 // random data needed if no predefined data available |
|
199 if( !parameters ) |
|
200 { |
|
201 iParameters = new(ELeave) CBrowserParameters; |
|
202 parameters = iParameters; |
|
203 |
|
204 TFileName userAndPassword = iEngine->RandomString(CCreatorEngine::EFirstName); |
|
205 TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); |
|
206 TFileName url = name; |
|
207 url.Insert(0, _L("http://www.")); |
|
208 url.Append(_L(".com/")); |
|
209 name.Insert(0, KCreatorBrowserPrefixName); |
|
210 |
|
211 parameters->iBookmarkName->Des() = name; |
|
212 parameters->iBookmarkAddress->Des() = url; |
|
213 parameters->iBookmarkUsername->Des() = userAndPassword; |
|
214 parameters->iBookmarkPassword->Des() = userAndPassword; |
|
215 } |
|
216 |
|
217 TInt err = KErrNone; |
|
218 |
|
219 RFavouritesSession session; |
|
220 User::LeaveIfError( session.Connect() ); |
|
221 CleanupClosePushL<RFavouritesSession>(session); |
|
222 RFavouritesDb db; |
|
223 User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); |
|
224 CleanupClosePushL<RFavouritesDb>(db); |
|
225 |
|
226 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
227 item->SetType( CFavouritesItem::EItem ); |
|
228 item->SetParentFolder( KFavouritesRootUid ) ; |
|
229 item->SetNameL( parameters->iBookmarkName->Des() ); |
|
230 item->SetUrlL( parameters->iBookmarkAddress->Des() ); |
|
231 item->SetUserNameL( parameters->iBookmarkUsername->Des() ); |
|
232 item->SetPasswordL( parameters->iBookmarkPassword->Des() ); |
|
233 err = db.Add(*item, /*aAutoRename=*/ETrue); |
|
234 if (err) |
|
235 db.Commit(); |
|
236 |
|
237 // id has been generated, store it for being able to delete |
|
238 // only entries created with Creator |
|
239 iBmEntryIds.Append( item->Uid() ); |
|
240 |
|
241 CleanupStack::PopAndDestroy(3); //db, session, item |
|
242 |
|
243 return err; |
|
244 } |
|
245 |
|
246 //---------------------------------------------------------------------------- |
|
247 |
|
248 TInt CCreatorBrowser::CreateBookmarkFolderEntryL(CBrowserParameters *aParameters) |
|
249 { |
|
250 LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkFolderEntryL"); |
|
251 |
|
252 // clear any existing parameter definations |
|
253 delete iParameters; |
|
254 iParameters = NULL; |
|
255 |
|
256 CBrowserParameters* parameters = aParameters; |
|
257 |
|
258 // random data needed if no predefined data available |
|
259 if (!parameters) |
|
260 { |
|
261 iParameters = new(ELeave) CBrowserParameters; |
|
262 parameters = iParameters; |
|
263 |
|
264 TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); |
|
265 name.Insert(0, KCreatorBrowserPrefixFolderName); |
|
266 |
|
267 parameters->iBookmarkFolderName->Des() = name; |
|
268 } |
|
269 |
|
270 TInt err = KErrNone; |
|
271 |
|
272 RFavouritesSession session; |
|
273 User::LeaveIfError( session.Connect() ); |
|
274 CleanupClosePushL<RFavouritesSession>(session); |
|
275 RFavouritesDb db; |
|
276 User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); |
|
277 CleanupClosePushL<RFavouritesDb>(db); |
|
278 |
|
279 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
280 item->SetType( CFavouritesItem::EFolder ); |
|
281 item->SetParentFolder( KFavouritesRootUid ) ; |
|
282 item->SetNameL( parameters->iBookmarkFolderName->Des() ); |
|
283 |
|
284 err = db.Add(*item, /*aAutoRename=*/ETrue); |
|
285 if (err) |
|
286 db.Commit(); |
|
287 |
|
288 // id has been generated, store it for being able to delete |
|
289 // only entries created with Creator |
|
290 iBmFEntryIds.Append( item->Uid() ); |
|
291 |
|
292 CleanupStack::PopAndDestroy(3); //db, session, item |
|
293 |
|
294 |
|
295 return err; |
|
296 |
|
297 } |
|
298 |
|
299 //---------------------------------------------------------------------------- |
|
300 |
|
301 TInt CCreatorBrowser::CreateSavedDeckEntryL(CBrowserParameters *aParameters) |
|
302 { |
|
303 LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckEntryL"); |
|
304 |
|
305 // clear any existing parameter definations |
|
306 delete iParameters; |
|
307 iParameters = NULL; |
|
308 |
|
309 CBrowserParameters* parameters = aParameters; |
|
310 |
|
311 // random data needed if no predefined data available |
|
312 if (!parameters) |
|
313 { |
|
314 iParameters = new(ELeave) CBrowserParameters; |
|
315 parameters = iParameters; |
|
316 |
|
317 TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); |
|
318 name.Insert(0, KCreatorBrowserPrefixName); |
|
319 |
|
320 parameters->iSavedDeckLinkName->Des() = name; |
|
321 parameters->iSavedDeckLocalAddress->Des() = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); |
|
322 } |
|
323 |
|
324 TInt err = KErrNone; |
|
325 |
|
326 // check the deck address is correct |
|
327 if ( parameters->iSavedDeckLocalAddress->Des().Length() == 0 || |
|
328 !BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des() )) |
|
329 { |
|
330 // not found, use a default deck instead |
|
331 delete parameters->iSavedDeckLocalAddress; |
|
332 parameters->iSavedDeckLocalAddress = 0; |
|
333 TPtrC tmp = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); |
|
334 parameters->iSavedDeckLocalAddress = HBufC::NewL(tmp.Length()); |
|
335 parameters->iSavedDeckLocalAddress->Des() = tmp; |
|
336 } |
|
337 |
|
338 |
|
339 RFavouritesSession session; |
|
340 User::LeaveIfError( session.Connect() ); |
|
341 CleanupClosePushL<RFavouritesSession>(session); |
|
342 RFavouritesDb db; |
|
343 User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); |
|
344 CleanupClosePushL<RFavouritesDb>(db); |
|
345 |
|
346 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
347 item->SetType( CFavouritesItem::EItem ); |
|
348 item->SetParentFolder( KFavouritesRootUid ) ; |
|
349 item->SetNameL( parameters->iSavedDeckLinkName->Des() ); |
|
350 item->SetUrlL( _L(" ") ); |
|
351 |
|
352 TFavouritesWapAp favouritesAp; |
|
353 favouritesAp.SetDefault(); |
|
354 item->SetWapAp( favouritesAp ); |
|
355 |
|
356 |
|
357 err = db.Add(*item, /*aAutoRename=*/ETrue); |
|
358 if (err) |
|
359 db.Commit(); |
|
360 |
|
361 // read the source deck to buffer |
|
362 RFile sourceFile; |
|
363 User::LeaveIfError( sourceFile.Open(CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des(), EFileRead) ); |
|
364 CleanupClosePushL<RFile>(sourceFile); |
|
365 TInt sourceFileSize(0); |
|
366 err = sourceFile.Size(sourceFileSize); |
|
367 HBufC8* sourceBuf = HBufC8::NewLC(sourceFileSize); |
|
368 TPtr8 sourcePtr = sourceBuf->Des(); |
|
369 sourceFile.Read(sourcePtr); |
|
370 |
|
371 // write the deck |
|
372 RFavouritesFile destinationFile; |
|
373 User::LeaveIfError( destinationFile.Replace(db, item->Uid() )); |
|
374 CleanupClosePushL<RFavouritesFile>(destinationFile); |
|
375 err = destinationFile.Write(sourceBuf->Des()); |
|
376 |
|
377 // id has been generated, store it for being able to delete |
|
378 // only entries created with Creator |
|
379 iSpEntryIds.Append( item->Uid() ); |
|
380 |
|
381 |
|
382 CleanupStack::PopAndDestroy(6); //db, session, item, sourceFile, destinationFile, sourceBuf |
|
383 |
|
384 return err; |
|
385 } |
|
386 |
|
387 //---------------------------------------------------------------------------- |
|
388 |
|
389 TInt CCreatorBrowser::CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters) |
|
390 { |
|
391 LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckFolderEntryL"); |
|
392 |
|
393 // clear any existing parameter definations |
|
394 delete iParameters; |
|
395 iParameters = NULL; |
|
396 |
|
397 CBrowserParameters* parameters = aParameters; |
|
398 // random data needed if no predefined data available |
|
399 if (!parameters) |
|
400 { |
|
401 iParameters = new(ELeave) CBrowserParameters; |
|
402 parameters = iParameters; |
|
403 |
|
404 TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); |
|
405 name.Insert(0, KCreatorBrowserPrefixFolderName); |
|
406 |
|
407 parameters->iSavedDeckFolderName->Des() = name; |
|
408 } |
|
409 |
|
410 TInt err = KErrNone; |
|
411 |
|
412 RFavouritesSession session; |
|
413 User::LeaveIfError( session.Connect() ); |
|
414 CleanupClosePushL<RFavouritesSession>(session); |
|
415 RFavouritesDb db; |
|
416 User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); |
|
417 CleanupClosePushL<RFavouritesDb>(db); |
|
418 |
|
419 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
420 item->SetType( CFavouritesItem::EFolder ); |
|
421 item->SetParentFolder( KFavouritesRootUid ) ; |
|
422 item->SetNameL( parameters->iSavedDeckFolderName->Des() ); |
|
423 |
|
424 err = db.Add(*item, /*aAutoRename=*/ETrue); |
|
425 if (err) |
|
426 db.Commit(); |
|
427 |
|
428 // id has been generated, store it for being able to delete |
|
429 // only entries created with Creator |
|
430 iSpFEntryIds.Append( item->Uid() ); |
|
431 |
|
432 CleanupStack::PopAndDestroy(3); //db, session, item |
|
433 |
|
434 return err; |
|
435 |
|
436 } |
|
437 |
|
438 |
|
439 //---------------------------------------------------------------------------- |
|
440 void CCreatorBrowser::DeleteAllL() |
|
441 { |
|
442 LOGSTRING("Creator: CCreatorBrowser::DeleteAllL"); |
|
443 User::Leave( KErrNotSupported ); |
|
444 // will not be supported, see separate implementations below |
|
445 } |
|
446 |
|
447 //---------------------------------------------------------------------------- |
|
448 void CCreatorBrowser::DeleteAllCreatedByCreatorL() |
|
449 { |
|
450 LOGSTRING("Creator: CCreatorBrowser::DeleteAllCreatedByCreatorL"); |
|
451 User::Leave( KErrNotSupported ); |
|
452 // will not be supported, see separate implementations below |
|
453 } |
|
454 |
|
455 //---------------------------------------------------------------------------- |
|
456 void CCreatorBrowser::DeleteAllBookmarksL() |
|
457 { |
|
458 LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksL"); |
|
459 DeleteAllItemsL( KBrowserBookmarks, |
|
460 CFavouritesItem::EItem, |
|
461 EFalse, |
|
462 iBmEntryIds, // ignored, because deleting all |
|
463 KUidDictionaryUidBrowserBookmarks ); |
|
464 } |
|
465 |
|
466 //---------------------------------------------------------------------------- |
|
467 void CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL() |
|
468 { |
|
469 LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL"); |
|
470 DeleteAllItemsL( KBrowserBookmarks, |
|
471 CFavouritesItem::EItem, |
|
472 ETrue, |
|
473 iBmEntryIds, |
|
474 KUidDictionaryUidBrowserBookmarks ); |
|
475 } |
|
476 |
|
477 //---------------------------------------------------------------------------- |
|
478 void CCreatorBrowser::DeleteAllBookmarkFoldersL() |
|
479 { |
|
480 LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersL"); |
|
481 DeleteAllItemsL( KBrowserBookmarks, |
|
482 CFavouritesItem::EFolder, |
|
483 EFalse, |
|
484 iBmFEntryIds, // ignored, because deleting all |
|
485 KUidDictionaryUidBrowserBookmarkF ); |
|
486 } |
|
487 |
|
488 //---------------------------------------------------------------------------- |
|
489 void CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL() |
|
490 { |
|
491 LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL"); |
|
492 DeleteAllItemsL( KBrowserBookmarks, |
|
493 CFavouritesItem::EFolder, |
|
494 ETrue, |
|
495 iBmFEntryIds, |
|
496 KUidDictionaryUidBrowserBookmarkF ); |
|
497 } |
|
498 |
|
499 //---------------------------------------------------------------------------- |
|
500 void CCreatorBrowser::DeleteAllSavedPagesL() |
|
501 { |
|
502 LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesL"); |
|
503 DeleteAllItemsL( KBrowserSavedPages, |
|
504 CFavouritesItem::EItem, |
|
505 EFalse, |
|
506 iSpEntryIds, // ignored, because deleting all |
|
507 KUidDictionaryUidBrowserSavedPg ); |
|
508 } |
|
509 |
|
510 //---------------------------------------------------------------------------- |
|
511 void CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL() |
|
512 { |
|
513 LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL"); |
|
514 DeleteAllItemsL( KBrowserSavedPages, |
|
515 CFavouritesItem::EItem, |
|
516 ETrue, |
|
517 iSpEntryIds, |
|
518 KUidDictionaryUidBrowserSavedPg ); |
|
519 } |
|
520 |
|
521 //---------------------------------------------------------------------------- |
|
522 void CCreatorBrowser::DeleteAllSavedPageFoldersL() |
|
523 { |
|
524 LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFoldersL"); |
|
525 DeleteAllItemsL( KBrowserSavedPages, |
|
526 CFavouritesItem::EFolder, |
|
527 EFalse, |
|
528 iSpFEntryIds, // ignored, because deleting all |
|
529 KUidDictionaryUidBrowserSavedPgF ); |
|
530 } |
|
531 |
|
532 //---------------------------------------------------------------------------- |
|
533 void CCreatorBrowser::DeleteAllSavedPageFoldersCreatedByCreatorL() |
|
534 { |
|
535 LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFolderssCreatedByCreatorL"); |
|
536 DeleteAllItemsL( KBrowserSavedPages, |
|
537 CFavouritesItem::EFolder, |
|
538 ETrue, |
|
539 iSpFEntryIds, |
|
540 KUidDictionaryUidBrowserSavedPgF ); |
|
541 } |
|
542 |
|
543 //---------------------------------------------------------------------------- |
|
544 void CCreatorBrowser::DeleteAllItemsL( const TDesC& aDbName, |
|
545 CFavouritesItem::TType aTypeFilter, |
|
546 TBool aOnlyCreatedWithCreator, |
|
547 RArray<TInt>& aEntryIds, |
|
548 const TUid aDictUid ) |
|
549 { |
|
550 LOGSTRING("Creator: CCreatorBrowser::DeleteItemL"); |
|
551 RFavouritesSession session; |
|
552 User::LeaveIfError( session.Connect() ); |
|
553 CleanupClosePushL( session ); |
|
554 RFavouritesDb db; |
|
555 User::LeaveIfError( db.Open( session, aDbName ) ); |
|
556 CleanupClosePushL( db ); |
|
557 |
|
558 if ( aOnlyCreatedWithCreator ) |
|
559 { |
|
560 // read uids from Creator internal store |
|
561 aEntryIds.Reset(); |
|
562 iEngine->ReadEntryIdsFromStoreL( aEntryIds, aDictUid ); |
|
563 |
|
564 // delete entries from db |
|
565 for ( TInt i = 0; i < aEntryIds.Count(); i++ ) |
|
566 { |
|
567 db.Delete( aEntryIds[i] ); |
|
568 } |
|
569 } |
|
570 else |
|
571 { |
|
572 CArrayFixFlat<TInt>* uids = new (ELeave) CArrayFixFlat<TInt>(64); |
|
573 CleanupStack::PushL( uids ); |
|
574 |
|
575 // read uids from browser db |
|
576 User::LeaveIfError( db.GetUids( *uids, KFavouritesRootUid, aTypeFilter ) ); |
|
577 |
|
578 // delete entries from db |
|
579 for ( TInt i = 0; i < uids->Count(); i++ ) |
|
580 { |
|
581 db.Delete( uids->At(i) ); |
|
582 } |
|
583 |
|
584 // db.Commit() seems to panic with EFavouritesNoTransaction |
|
585 // deletion is successful even without commit, so not calling it |
|
586 CleanupStack::PopAndDestroy( uids ); |
|
587 } |
|
588 |
|
589 // entries deleted, remove the Browser related registry |
|
590 aEntryIds.Reset(); |
|
591 iEngine->RemoveStoreL( aDictUid ); |
|
592 |
|
593 CleanupStack::PopAndDestroy( &db ); |
|
594 CleanupStack::PopAndDestroy( &session ); |
|
595 } |
|