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