|
1 /* |
|
2 * Copyright (c) 2002-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 the License "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: Implementation of CBrowserBookmarksView. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <CDownloadMgrUiDownloadsList.h> |
|
21 #include <CDownloadMgrUiDownloadMenu.h> |
|
22 #include <eikmenup.h> |
|
23 #include <aknsfld.h> |
|
24 #include <smut.h> |
|
25 #include <IrcMTM.h> |
|
26 |
|
27 #ifndef AVERELL2_BLUETOOTH_MISSING |
|
28 #include <btmsgtypeuid.h> |
|
29 #endif |
|
30 |
|
31 #include <irmsgtypeuid.h> |
|
32 #include <FavouritesDb.h> |
|
33 |
|
34 #include <BrowserNG.rsg> |
|
35 |
|
36 #include <FavouritesItem.h> |
|
37 #include <FavouritesItemList.h> |
|
38 #include <ApEngineConsts.h> |
|
39 #include <ApListItem.h> |
|
40 #include <ApListItemList.h> |
|
41 #include <StringLoader.h> |
|
42 #include <FeatMgr.h> |
|
43 #include <Uri16.h> |
|
44 #include <akntoolbar.h> |
|
45 #ifdef RD_SCALABLE_UI_V2 |
|
46 #include <akntoolbarextension.h> |
|
47 #endif |
|
48 |
|
49 |
|
50 #include "BrowserDialogs.h" |
|
51 #include "BrowserBookmarksView.h" |
|
52 #include "BrowserBookmarksContainer.h" |
|
53 #include "BrowserBookmarksModel.h" |
|
54 #include "BrowserFavouritesListbox.h" |
|
55 #include "BrowserBookmarksEditDialog.h" |
|
56 #include "BrowserBookmarksGotoPane.h" |
|
57 #include "CommonConstants.h" |
|
58 #include "BrowserUtil.h" |
|
59 #include "BrowserAppUi.h" |
|
60 #include "Browser.hrh" |
|
61 #include "CommandVisibility.h" |
|
62 #include "BrowserBmOTABinSender.h" |
|
63 #include "CommsModel.h" |
|
64 #include <MConnection.h> |
|
65 #include "BrowserUiVariant.hrh" |
|
66 #include "BrowserWindowManager.h" |
|
67 #include "BrowserWindow.h" |
|
68 #include "BrowserDownloadUtil.h" |
|
69 #include "Display.h" |
|
70 #include "logger.h" |
|
71 |
|
72 #include "eikon.hrh" |
|
73 |
|
74 |
|
75 // CONSTANTS |
|
76 const TInt KAdaptiveBookmarksFirstPositionInBMView = 0; |
|
77 const TInt KAdaptiveBookmarksSecondPositionInBMView = 1; |
|
78 |
|
79 const TInt KBrowserDesCArrayGranularity = 8; |
|
80 |
|
81 // ================= MEMBER FUNCTIONS ======================= |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CBrowserBookmarksView::NewLC |
|
85 // ---------------------------------------------------------------------------- |
|
86 // |
|
87 CBrowserBookmarksView* CBrowserBookmarksView::NewLC( |
|
88 MApiProvider& aApiProvider, |
|
89 CRecentUrlStore& aRecentUrlStore, |
|
90 TInt aInitialFolderUid ) |
|
91 { |
|
92 CBrowserBookmarksView* view = new (ELeave) CBrowserBookmarksView( aApiProvider, |
|
93 aRecentUrlStore, |
|
94 aInitialFolderUid ); |
|
95 CleanupStack::PushL( view ); |
|
96 |
|
97 view->ConstructL( R_BROWSER_BOOKMARKS_VIEW ); |
|
98 |
|
99 return view; |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CBrowserBookmarksView::~CBrowserBookmarksView |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 CBrowserBookmarksView::~CBrowserBookmarksView() |
|
107 { |
|
108 LOG_ENTERFN("CBrowserBookmarksView::~CBrowserBookmarksView"); |
|
109 delete iDownloadsListExecuter; |
|
110 iDownloadsListExecuter = 0; |
|
111 |
|
112 if ( !ApiProvider().ExitInProgress() ) |
|
113 { |
|
114 // Remove observers only in destructor. See comment in ConstructL why. |
|
115 ApiProvider().Preferences().RemoveObserver( this ); |
|
116 ApiProvider().Connection().UnsetApChangeObserver(); |
|
117 } |
|
118 CBrowserBookmarksContainer* container = TheContainer(); |
|
119 if ( container ) |
|
120 { |
|
121 container->GotoPane()->SetGPObserver( NULL ); |
|
122 } |
|
123 delete iDomainFolderName; |
|
124 delete iItemsToMove; |
|
125 delete iCurrentOrder; |
|
126 delete iEnteredURL; |
|
127 iEnteredURL = NULL; |
|
128 BROWSER_LOG( ( _L("delete iEnteredUrl 1") ) ); |
|
129 iCursorPos = -1; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // CBrowserBookmarksView::UpdateGotoPaneL |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 void CBrowserBookmarksView::UpdateGotoPaneL() |
|
137 { |
|
138 LOG_ENTERFN("BookmarksView::UpdateGotoPaneL"); |
|
139 // Simulate cursor movement; that will cancel editing (if editing) |
|
140 // and refresh Goto Pane. |
|
141 if ( Container() ) |
|
142 { |
|
143 if ( iEnteredURL ) |
|
144 { |
|
145 BROWSER_LOG( ( _L("iEnteredUrl exists") ) ); |
|
146 if ( iCursorPos >=0 ) // update pane only once! |
|
147 { |
|
148 TheContainer()->GotoPane()->SetTextL( iEnteredURL->Des(), |
|
149 EFalse, |
|
150 EFalse ); |
|
151 |
|
152 CEikEdwin* editor = STATIC_CAST( CEikEdwin*, |
|
153 TheContainer()->GotoPane()->ComponentControl( 1 ) ); |
|
154 editor->SetCursorPosL( iCursorPos, EFalse ); |
|
155 iCursorPos = -1; |
|
156 TheContainer()->GotoPane()->SetFocus( ETrue ); |
|
157 } |
|
158 } |
|
159 else |
|
160 { |
|
161 Container()->HandleCursorChangedL( Container()->Listbox() ); |
|
162 } |
|
163 } |
|
164 } |
|
165 |
|
166 // -------------------------------------------------------------------------------- |
|
167 // CBrowserBookmarksView::DeleteItems |
|
168 // -------------------------------------------------------------------------------- |
|
169 // |
|
170 void CBrowserBookmarksView::DeleteItems( TInt aCommand ) |
|
171 { |
|
172 |
|
173 if (iHandleDeleteInProgress) |
|
174 return; |
|
175 |
|
176 iHandleDeleteInProgress = ETrue; |
|
177 |
|
178 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
179 |
|
180 if (!item) |
|
181 { |
|
182 return; |
|
183 } |
|
184 |
|
185 if ( item->ParentFolder() == KFavouritesAdaptiveItemsFolderUid ) |
|
186 { |
|
187 TBool confirm; |
|
188 CArrayPtr<const CFavouritesItem>* items = Container()->Listbox()->SelectedItemsLC(); |
|
189 |
|
190 if ( items->Count() == 1 ) |
|
191 { |
|
192 confirm = TBrowserDialogs::ConfirmQueryYesNoL( R_BROWSER_FAVOURITES_TEXT_QUERY_COMMON_CONF_DELETE, (*items)[0]->Name()); |
|
193 } |
|
194 else if (items->Count() > 1) |
|
195 { |
|
196 confirm = TBrowserDialogs::ConfirmQueryYesNoL( R_BROWSER_FAVOURITES_TEXT_DEL_ITEMS_QUERY, items->Count()); |
|
197 } |
|
198 else |
|
199 { |
|
200 confirm = EFalse; |
|
201 } |
|
202 |
|
203 if (confirm) |
|
204 { |
|
205 for ( TInt i = 0; i < items->Count(); i++ ) |
|
206 { |
|
207 iRecentUrlStore.DeleteData(items->At( i )->Url()); |
|
208 } |
|
209 Container()->Listbox()->View()->ClearSelection(); |
|
210 iSaveBMOrder = ETrue; |
|
211 RefreshL(); |
|
212 } |
|
213 |
|
214 CleanupStack::PopAndDestroy();//items |
|
215 } |
|
216 else |
|
217 { |
|
218 iSaveBMOrder = ETrue; |
|
219 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
220 } |
|
221 |
|
222 iHandleDeleteInProgress = EFalse; |
|
223 |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CBrowserBookmarksView::HandleCommandL |
|
228 // ---------------------------------------------------------------------------- |
|
229 // |
|
230 void CBrowserBookmarksView::HandleCommandL( TInt aCommand ) |
|
231 { |
|
232 LOG_ENTERFN("BookmarksView::HandleCommandL"); |
|
233 // |
|
234 // FIRST SWITCH Generic CBA commands to original commands |
|
235 // use ProcessCommandL to route through akn to make sure |
|
236 // command gets routed to the right place |
|
237 // |
|
238 // |
|
239 |
|
240 // Assume generic command unless default case, below. |
|
241 TBool genericCmdHandled = ETrue; |
|
242 |
|
243 switch ( aCommand ) |
|
244 { |
|
245 case EBrowserBookmarksCmdCancel: |
|
246 { |
|
247 if ( iManualItemMovingGoingOn ) |
|
248 { |
|
249 ProcessCommandL(EWmlCmdMoveCancel); |
|
250 } |
|
251 else if ( TheContainer() && TheContainer()->GotoPane()->IsEditing() ) |
|
252 { |
|
253 ProcessCommandL(EWmlCmdGotoPaneCancel); |
|
254 } |
|
255 break; |
|
256 } |
|
257 case EBrowserBookmarksCmdOpen: |
|
258 { |
|
259 const CFavouritesItem* item = NULL; |
|
260 if (Container()) |
|
261 { |
|
262 item = Container()->Listbox()->CurrentItem(); |
|
263 } |
|
264 |
|
265 if ( item && item->IsFolder() ) |
|
266 { |
|
267 ProcessCommandL(EWmlCmdOpenFolder); |
|
268 } |
|
269 else |
|
270 { |
|
271 ProcessCommandL(EWmlCmdDownload); |
|
272 } |
|
273 |
|
274 break; |
|
275 } |
|
276 case EBrowserBookmarksCmdBack: |
|
277 { |
|
278 // default remap is to say back from folder |
|
279 TInt cmd = EWmlCmdBackFromFolder; |
|
280 |
|
281 // unless we have these conditions |
|
282 if ( !iInAdaptiveBookmarksFolder ) |
|
283 { |
|
284 if ( iCurrentFolder == KFavouritesRootUid ) |
|
285 { |
|
286 if ( ApiProvider().IsPageLoaded() || ApiProvider().Fetching() ) |
|
287 { |
|
288 cmd = EWmlCmdBackToPage; |
|
289 } |
|
290 } |
|
291 } |
|
292 ProcessCommandL(cmd); |
|
293 break; |
|
294 } |
|
295 default: |
|
296 { |
|
297 genericCmdHandled = EFalse; |
|
298 break; |
|
299 } |
|
300 } |
|
301 |
|
302 if (genericCmdHandled) |
|
303 { |
|
304 return; |
|
305 } |
|
306 |
|
307 // |
|
308 // EXISTING (regular) command set |
|
309 // |
|
310 if ( TheContainer() ) |
|
311 { |
|
312 switch ( aCommand ) |
|
313 { |
|
314 // CBA commands. |
|
315 case EWmlCmdGotoPaneGoTo: |
|
316 { |
|
317 if (TheContainer()->GotoPane()->Editor()->TextLength()!= 0) |
|
318 { |
|
319 // Cancel editing and sets Goto Pane text back. |
|
320 if (TheContainer()->GotoPane()->PopupList() != NULL) |
|
321 { |
|
322 TheContainer()->GotoPane()->PopupList()->SetDirectoryModeL( ETrue ); |
|
323 TheContainer()->GotoPane()->PopupList()->HidePopupL(); |
|
324 } |
|
325 GotoUrlInGotoPaneL(); |
|
326 } |
|
327 break; |
|
328 } |
|
329 |
|
330 case EWmlCmdGotoPaneSelect: |
|
331 { |
|
332 if (TheContainer()->GotoPane()->Editor()->TextLength()!= 0) |
|
333 { |
|
334 // Cancel editing and sets Goto Pane text back. |
|
335 if (TheContainer()->GotoPane()->PopupList() != NULL) |
|
336 { |
|
337 TheContainer()->GotoPane()->PopupList()->SetDirectoryModeL( ETrue ); |
|
338 TheContainer()->GotoPane()->PopupList()->HidePopupL(); |
|
339 } |
|
340 // set LSK to GOTO now |
|
341 UpdateCbaL(); |
|
342 } |
|
343 break; |
|
344 } |
|
345 |
|
346 |
|
347 case EWmlCmdNewFolder: |
|
348 { |
|
349 TInt uid = CBrowserFavouritesView::AddNewFolderL( ); |
|
350 |
|
351 AddUidToLastPlaceToCurrentListL(uid); |
|
352 iRefresh = EFalse; |
|
353 Model().Database().SetData( CurrentFolder() , *iCurrentOrder ); |
|
354 break; |
|
355 } |
|
356 case EWmlCmdMove: |
|
357 { |
|
358 StartMoveItemsL(); |
|
359 break; |
|
360 } |
|
361 case EWmlCmdMoveOk: |
|
362 { |
|
363 MoveItemsL(); |
|
364 break; |
|
365 } |
|
366 case EWmlCmdMoveCancel: |
|
367 { |
|
368 CancelMoveItemsL(); |
|
369 break; |
|
370 } |
|
371 |
|
372 case EWmlCmdMoveToFolder: |
|
373 { |
|
374 iSaveBMOrder = ETrue; |
|
375 CBrowserFavouritesView::HandleCommandL(aCommand); |
|
376 break; |
|
377 } |
|
378 |
|
379 case EWmlCmdGotoPaneCancel: |
|
380 { |
|
381 // Cancel editing and sets Goto Pane text back. |
|
382 if (TheContainer()->GotoPane()->PopupList() != NULL) |
|
383 { |
|
384 TheContainer()->GotoPane()->PopupList()->SetDirectoryModeL( ETrue ); |
|
385 TheContainer()->GotoPane()->PopupList()->HidePopupL(); |
|
386 } |
|
387 delete iEnteredURL; |
|
388 iEnteredURL = NULL; |
|
389 BROWSER_LOG( ( _L("delete iEnteredUrl 2") ) ); |
|
390 iCursorPos = -1; |
|
391 |
|
392 TheContainer()->SetGotoInactiveL(); |
|
393 |
|
394 DimToolbarButtons(EFalse); |
|
395 |
|
396 break; |
|
397 } |
|
398 |
|
399 // Menu commands. |
|
400 case EWmlCmdFavourites: |
|
401 { |
|
402 if ( iInAdaptiveBookmarksFolder ) |
|
403 { |
|
404 ExitAdaptiveBookmarks(); |
|
405 } |
|
406 ApiProvider().SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId ); |
|
407 break; |
|
408 } |
|
409 |
|
410 case EWmlCmdBackToPage: |
|
411 { |
|
412 ApiProvider().SetViewToReturnOnClose( KUidBrowserBookmarksViewId ); |
|
413 ApiProvider().SetViewToBeActivatedIfNeededL( KUidBrowserContentViewId ); |
|
414 break; |
|
415 } |
|
416 |
|
417 case EWmlCmdDownload: |
|
418 case EWmlCmdDownloadPage: |
|
419 { |
|
420 ActivateCurrentBookmarkL(); |
|
421 break; |
|
422 } |
|
423 |
|
424 #ifdef __RSS_FEEDS |
|
425 case EWmlCmdOpenFeedsFolder: |
|
426 { |
|
427 ApiProvider().FeedsClientUtilities().ShowFolderViewL(); |
|
428 break; |
|
429 } |
|
430 #endif // __RSS_FEEDS |
|
431 |
|
432 |
|
433 case EWmlCmdLaunchHomePage: |
|
434 { |
|
435 AppUi()->HandleCommandL( aCommand ); |
|
436 break; |
|
437 } |
|
438 |
|
439 case EWmlCmdOpenItem: |
|
440 { |
|
441 // re-handle the open item command depending on whether a folder or an |
|
442 // item is selected. |
|
443 if ( Container() && Container()->Listbox() ) |
|
444 { |
|
445 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
446 if ( item && item->IsFolder() ) |
|
447 { |
|
448 HandleCommandL(EWmlCmdOpenFolder); |
|
449 } |
|
450 else |
|
451 { |
|
452 HandleCommandL(EWmlCmdDownload); |
|
453 } |
|
454 } |
|
455 break; |
|
456 } |
|
457 |
|
458 case EWmlCmdAddBookmark: |
|
459 { |
|
460 AddNewBookmarkL(); |
|
461 break; |
|
462 } |
|
463 |
|
464 case EWmlCmdGoToAddress: // MSK for Recent Url page |
|
465 case EWmlCmdSwitchToGotoActive: |
|
466 { |
|
467 DimToolbarButtons(ETrue); |
|
468 TheContainer()->SetGotoActiveL(); |
|
469 break; |
|
470 } |
|
471 |
|
472 |
|
473 case EWmlCmdEditBookmark: |
|
474 { |
|
475 EditCurrentBookmarkL(); |
|
476 break; |
|
477 } |
|
478 |
|
479 case EWmlCmdSetAsHomePage: |
|
480 { |
|
481 if ( Container() && Container()->Listbox() ) |
|
482 { |
|
483 const CFavouritesItem* item = |
|
484 Container()->Listbox()->CurrentItem(); |
|
485 if ( item && item->IsItem() && |
|
486 TBrowserDialogs::ConfirmQueryYesNoL( |
|
487 R_QTN_BROWSERBM_QUERY_SET_AS_HOME_PAGE ) ) |
|
488 { |
|
489 ApiProvider().Preferences().SetHomePageUrlL( item->Url() ); |
|
490 ApiProvider().Preferences().SetHomePageTypeL( EWmlSettingsHomePageAddress ); |
|
491 } |
|
492 } |
|
493 break; |
|
494 } |
|
495 |
|
496 case EWmlCmdPreferences: |
|
497 { |
|
498 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
499 break; |
|
500 } |
|
501 |
|
502 case EWmlCmdCopyToBookmarks: |
|
503 { |
|
504 CArrayPtr<const CFavouritesItem>* items = |
|
505 Container()->Listbox()->SelectedItemsLC(); |
|
506 if (items->Count()) |
|
507 { |
|
508 // Set WAP AP. |
|
509 CFavouritesItem* item; |
|
510 for (TInt i=0;i<items->Count();i++) |
|
511 { |
|
512 item = CFavouritesItem::NewL(); |
|
513 *item = *( items->At( i ) ); |
|
514 CleanupStack::PushL( item ); |
|
515 item->SetParentFolder( KFavouritesRootUid ); |
|
516 Model().AddL( *item, EFalse, CBrowserFavouritesModel::EAutoRename ); |
|
517 AddUidToLastPlaceToCurrentListL( item->Uid() ); |
|
518 CleanupStack::PopAndDestroy();//item |
|
519 } |
|
520 iRefresh = EFalse; |
|
521 Model().Database().SetData( CurrentFolder() , *iCurrentOrder ); |
|
522 Container()->Listbox()->View()->ClearSelection(); |
|
523 if (items->Count()==1) |
|
524 { |
|
525 TBrowserDialogs::InfoNoteL |
|
526 ( |
|
527 R_BROWSER_INFO_NOTE, |
|
528 R_BROWSER_ADAPTIVE_BOOKMARKS_ADAPTIVE_BOOKMARK_COPIED |
|
529 ); |
|
530 } |
|
531 else |
|
532 { |
|
533 TBrowserDialogs::InfoNoteL( |
|
534 R_BROWSER_INFO_NOTE, |
|
535 R_BROWSER_ADAPTIVE_BOOKMARKS_ADAPTIVE_BOOKMARKS_COPIED, |
|
536 items->Count() ); |
|
537 } |
|
538 } |
|
539 CleanupStack::PopAndDestroy();//items |
|
540 break; |
|
541 } |
|
542 |
|
543 case EWmlCmdRename: |
|
544 { |
|
545 // NO rename on menu |
|
546 { |
|
547 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
548 } |
|
549 break; |
|
550 } |
|
551 |
|
552 case EWmlCmdDelete: |
|
553 { |
|
554 DeleteItems( aCommand ); |
|
555 break; |
|
556 } // case |
|
557 |
|
558 |
|
559 case EWmlCmdClearAdaptiveBookmarks: |
|
560 { |
|
561 if ( TBrowserDialogs::ConfirmQueryYesNoL( |
|
562 R_BROWSER_ADAPTIVE_BOOKMARKS_DELETE_ALL_ADAPTIVE_BOOKMARKS) ) |
|
563 { |
|
564 ClearAdaptiveBookmarksL(); |
|
565 } |
|
566 break; |
|
567 } |
|
568 |
|
569 case EWmlCmdClearAdaptiveBookmarksNoPrompt: |
|
570 { |
|
571 ClearAdaptiveBookmarksL(); |
|
572 break; |
|
573 } |
|
574 |
|
575 case EWmlCmdOpenFolder: |
|
576 { |
|
577 if ( TheContainer()->GotoPane()->PopupList() ) |
|
578 { |
|
579 if ( TheContainer()->GotoPane()->PopupList()->IsPoppedUp() ) |
|
580 { |
|
581 TheContainer()->GotoPane()->PopupList()->SetDirectoryModeL( |
|
582 EFalse ); |
|
583 break; // This case is supposed to fall through into the next case in certain |
|
584 // conditions. |
|
585 } |
|
586 } |
|
587 } |
|
588 |
|
589 case EWmlCmdOpenMarkedFolder: |
|
590 { |
|
591 SetEmptyTextL(); |
|
592 if (Container()->Listbox()->CurrentItem()->Uid() == |
|
593 KFavouritesAdaptiveItemsFolderUid ) |
|
594 { |
|
595 iAdaptiveBookmarksFolderSelected = ETrue; |
|
596 iInAdaptiveBookmarksFolder = ETrue; |
|
597 SetEmptyTextL(); |
|
598 RefreshL(); |
|
599 } |
|
600 else |
|
601 { |
|
602 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
603 } |
|
604 break; |
|
605 } |
|
606 |
|
607 case EWmlCmdBackFromFolder: |
|
608 { |
|
609 Container()->Listbox()->ClearSelection(); |
|
610 if ( iDomainFolderName ) |
|
611 { |
|
612 HBufC* domainFolderNameToHighlight; |
|
613 domainFolderNameToHighlight = HBufC::NewL( |
|
614 iDomainFolderName->Length() ); |
|
615 CleanupStack::PushL( domainFolderNameToHighlight ); |
|
616 |
|
617 domainFolderNameToHighlight->Des().Append( *iDomainFolderName ); |
|
618 delete iDomainFolderName; |
|
619 iDomainFolderName = NULL; |
|
620 |
|
621 CFavouritesItemList* items = |
|
622 GetItemsLC( KFavouritesAdaptiveItemsFolderUid ); |
|
623 TInt indexToHighlight = 0; |
|
624 |
|
625 for ( TInt i = 0; i < items->Count(); i++ ) |
|
626 { |
|
627 if ( (*items)[i]->Name() == (*domainFolderNameToHighlight) ) |
|
628 { |
|
629 indexToHighlight = i; |
|
630 } |
|
631 } |
|
632 |
|
633 CleanupStack::PopAndDestroy(); // items |
|
634 CleanupStack::PopAndDestroy(); // domainFolderNameToHighlight |
|
635 |
|
636 HBufC* title; |
|
637 title=iCoeEnv->AllocReadResourceLC( |
|
638 R_BROWSER_ADAPTIVE_BOOKMARKS_TITLE ); |
|
639 ApiProvider().Display().SetTitleL( *title ); |
|
640 CleanupStack::PopAndDestroy(); // title |
|
641 RefreshL(); |
|
642 Container()->Listbox()->SetCurrentItemIndexAndDraw( |
|
643 indexToHighlight ); |
|
644 } |
|
645 else |
|
646 { |
|
647 if ( iInAdaptiveBookmarksFolder ) |
|
648 { |
|
649 iAdaptiveBookmarksFolderSelected = EFalse; |
|
650 iInAdaptiveBookmarksFolder=EFalse; |
|
651 SetEmptyTextL(); |
|
652 HBufC* title; |
|
653 title=iCoeEnv->AllocReadResourceLC( |
|
654 TheContainer()->TitleResourceId() ); |
|
655 UpdateNaviPaneL(); |
|
656 ApiProvider().Display().SetTitleL( *title ); |
|
657 iPreferredHighlightUid=KFavouritesAdaptiveItemsFolderUid; |
|
658 CleanupStack::PopAndDestroy(); // title |
|
659 RefreshL(); |
|
660 } |
|
661 else |
|
662 { |
|
663 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
664 } |
|
665 } |
|
666 // Back from a folder may require change in toolbar button state |
|
667 UpdateToolbarButtonsState(); |
|
668 break; |
|
669 } |
|
670 |
|
671 case EWmlCmdSendBookmarkViaUnifiedMessage: |
|
672 { |
|
673 // Both case can be handled alike - SendBookmarksL |
|
674 // uses SelectedItemsLC - this always what we want (if there is |
|
675 // something marked, those; if no marked, the highlighted one). |
|
676 SendBookmarksL( ); |
|
677 break; |
|
678 } |
|
679 |
|
680 |
|
681 #ifdef __SERIES60_HELP |
|
682 case EAknCmdHelp: |
|
683 { |
|
684 STATIC_CAST(CBrowserAppUi*, AppUi())->HandleCommandL(EAknCmdHelp); |
|
685 break; |
|
686 } |
|
687 #endif //__SERIES60_HELP |
|
688 |
|
689 case EWmlCmdDownloads: |
|
690 { |
|
691 ApiProvider().BrCtlInterface().HandleCommandL( |
|
692 (TInt)TBrCtlDefs::ECommandShowDownloads + |
|
693 (TInt)TBrCtlDefs::ECommandIdBase ); |
|
694 break; |
|
695 } |
|
696 |
|
697 case EWmlCmdDownloadPageNewWindow: |
|
698 { |
|
699 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
700 if ( item ) |
|
701 { |
|
702 CBrowserAppUi::Static()->OpenLinkInNewWindowL( *item ); |
|
703 } |
|
704 break; |
|
705 } |
|
706 |
|
707 default: |
|
708 { |
|
709 if (aCommand == EWmlCmdDelete && |
|
710 (Container()->Listbox()->CurrentItem()->ParentFolder()==KFavouritesAdaptiveItemsFolderUid)) |
|
711 { |
|
712 DeleteItems( aCommand ); |
|
713 break; |
|
714 } |
|
715 CBrowserFavouritesView::HandleCommandL( aCommand ); |
|
716 break; |
|
717 } |
|
718 } |
|
719 } |
|
720 } |
|
721 |
|
722 // ---------------------------------------------------------------------------- |
|
723 // CBrowserBookmarksView::SetEmptyTextL |
|
724 // ---------------------------------------------------------------------------- |
|
725 // |
|
726 void CBrowserBookmarksView::SetEmptyTextL() |
|
727 { |
|
728 HBufC* buf; |
|
729 if (iInAdaptiveBookmarksFolder) |
|
730 { |
|
731 HBufC* title; |
|
732 if (iDomainFolderName != NULL) |
|
733 { |
|
734 ApiProvider().Display().SetTitleL( *iDomainFolderName ); |
|
735 } |
|
736 else |
|
737 { |
|
738 title=iCoeEnv->AllocReadResourceLC( R_BROWSER_ADAPTIVE_BOOKMARKS_TITLE ); |
|
739 ApiProvider().Display().SetTitleL( *title ); |
|
740 CleanupStack::PopAndDestroy(); // title |
|
741 } |
|
742 buf = iCoeEnv->AllocReadResourceLC( R_BROWSER_ADAPTIVE_BOOKMARKS_NO_ADAPTIVE_BOOKMARKS ); |
|
743 } |
|
744 else |
|
745 { |
|
746 buf = iCoeEnv->AllocReadResourceLC( TheContainer()->ListboxEmptyTextResourceId() ); |
|
747 } |
|
748 TheContainer()->Listbox()->View()->SetListEmptyTextL( *buf ); |
|
749 CleanupStack::PopAndDestroy(); // buf |
|
750 } |
|
751 |
|
752 // ---------------------------------------------------------------------------- |
|
753 // CBrowserBookmarksView::Id |
|
754 // ---------------------------------------------------------------------------- |
|
755 // |
|
756 TUid CBrowserBookmarksView::Id() const |
|
757 { |
|
758 return KUidBrowserBookmarksViewId; |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------------------------- |
|
762 // CBrowserBookmarksView::CommandSetResourceIdL |
|
763 // ---------------------------------------------------------------------------- |
|
764 // |
|
765 TInt CBrowserBookmarksView::CommandSetResourceIdL() |
|
766 { |
|
767 // massive re-work for 5.0, to dynamically assign CBA |
|
768 return(R_BROWSER_BUTTONS_CBA_DYNAMIC); |
|
769 } |
|
770 |
|
771 // ---------------------------------------------------------------------------- |
|
772 // CBrowserBookmarksView::CommandSetResourceDynL |
|
773 // ---------------------------------------------------------------------------- |
|
774 // |
|
775 |
|
776 void CBrowserBookmarksView::CommandSetResourceDynL(TSKPair& aLsk, TSKPair& aRsk, TSKPair& aMsk) |
|
777 { |
|
778 // |
|
779 // Get gotoPane pointer and appropriate Container pointer. |
|
780 // |
|
781 // These are passed in to the LSK, RSK, MSK dynamic setting functions |
|
782 // and used to help chose the appropriate softkeys |
|
783 // |
|
784 CBrowserBookmarksGotoPane* gotoPanePtr = NULL; |
|
785 CBrowserBookmarksContainer* theContainer = TheContainer(); |
|
786 |
|
787 // if the container doesn't exist, leave gotoPanePtr at NULL |
|
788 if (theContainer) |
|
789 { |
|
790 gotoPanePtr = theContainer->GotoPane(); |
|
791 } |
|
792 |
|
793 // set LSK, RSK, MSK respectively |
|
794 SetLSKDynL(aLsk, gotoPanePtr); |
|
795 SetRSKDynL(aRsk, gotoPanePtr); |
|
796 SetMSKDynL(aMsk, aLsk, theContainer, gotoPanePtr); |
|
797 |
|
798 // |
|
799 // Finally, if the contextual menu command was assigned to the MSK, |
|
800 // we need to set up the menu now |
|
801 // |
|
802 if ( aMsk.id() == EAknSoftkeyContextOptions ) |
|
803 { |
|
804 ConfigContextMenu(); |
|
805 } |
|
806 } |
|
807 |
|
808 // ---------------------------------------------------------------------------- |
|
809 // CBrowserBookmarksView::SetLSKDynL |
|
810 // ---------------------------------------------------------------------------- |
|
811 // |
|
812 |
|
813 void CBrowserBookmarksView::SetLSKDynL(TSKPair& aLsk, |
|
814 CBrowserBookmarksGotoPane* aGotoPane) |
|
815 { |
|
816 // Default lsk is option |
|
817 aLsk.setPair(EAknSoftkeyOptions, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OPTION); |
|
818 |
|
819 if ( iManualItemMovingGoingOn ) |
|
820 { |
|
821 aLsk.setPair(EWmlCmdMoveOk, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OK); |
|
822 } |
|
823 else if ( aGotoPane && aGotoPane->IsEditing() ) |
|
824 { |
|
825 // default for goto is go |
|
826 aLsk.setPair(EWmlCmdGotoPaneGoTo, R_BROWSER_BOOKMARKS_DYN_SK_QTN_WML_SOFTK_GO); |
|
827 |
|
828 // special goto cases |
|
829 if ( ApiProvider().Fetching() ) |
|
830 { |
|
831 // No assignment. Set as default |
|
832 aLsk.setPair(EBrowserBookmarksCmdSoftkeyEmpty, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_EMPTY); |
|
833 } |
|
834 else if (aGotoPane->PopupList() && |
|
835 aGotoPane->PopupList()->IsOpenDirToShow() ) |
|
836 { |
|
837 aLsk.setPair(EBrowserBookmarksCmdOpen, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OPEN); |
|
838 } |
|
839 else if (aGotoPane->PopupList() && |
|
840 aGotoPane->PopupList()->IsPoppedUp() && |
|
841 !iPenEnabled) |
|
842 { |
|
843 // LSK Select is only for non-touch devices |
|
844 aLsk.setPair(EWmlCmdGotoPaneSelect, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_SELECT); |
|
845 } |
|
846 } |
|
847 } |
|
848 |
|
849 // ---------------------------------------------------------------------------- |
|
850 // CBrowserBookmarksView::SetRSKDynL |
|
851 // ---------------------------------------------------------------------------- |
|
852 // |
|
853 |
|
854 void CBrowserBookmarksView::SetRSKDynL(TSKPair& aRsk, |
|
855 CBrowserBookmarksGotoPane* aGotoPane) |
|
856 { |
|
857 if ( iManualItemMovingGoingOn ) |
|
858 { |
|
859 aRsk.setPair(EBrowserBookmarksCmdCancel, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_CANCEL); |
|
860 } |
|
861 else if ( aGotoPane && aGotoPane->IsEditing() ) |
|
862 { |
|
863 // default for goto is cancel |
|
864 aRsk.setPair(EBrowserBookmarksCmdCancel, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_CANCEL); |
|
865 } |
|
866 else |
|
867 { |
|
868 // default case for everything else is Back |
|
869 aRsk.setPair(EBrowserBookmarksCmdBack, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_BACK); |
|
870 |
|
871 // OR, it could be exit under these conditions |
|
872 if ( !iInAdaptiveBookmarksFolder && !ApiProvider().IsPageLoaded() && !ApiProvider().Fetching() ) |
|
873 { |
|
874 if ( iCurrentFolder == KFavouritesRootUid ) |
|
875 { |
|
876 aRsk.setPair(EAknSoftkeyExit, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_EXIT); |
|
877 } |
|
878 } |
|
879 } |
|
880 } |
|
881 |
|
882 // ---------------------------------------------------------------------------- |
|
883 // CBrowserBookmarksView::SetMSKDynL |
|
884 // ---------------------------------------------------------------------------- |
|
885 // |
|
886 |
|
887 void CBrowserBookmarksView::SetMSKDynL(TSKPair& aMsk, const TSKPair aLsk, |
|
888 CBrowserFavouritesContainer* aContainer, |
|
889 CBrowserBookmarksGotoPane* aGotoPane) |
|
890 { |
|
891 // setup any marked items flag for convenience |
|
892 // also verify that container is defined |
|
893 TBool anyMarkedItems = EFalse; |
|
894 if ( aContainer) |
|
895 { |
|
896 anyMarkedItems = aContainer->Listbox()->SelectionStateL().AnyMarked(); |
|
897 } |
|
898 else |
|
899 { |
|
900 return; |
|
901 } |
|
902 |
|
903 // |
|
904 // Usually, MSK is context menu if marked items. |
|
905 // The exception is if moving is in progress (and marked items).. then its the dot (in place of OK). |
|
906 // Otherwise, the Open Command is thrown. |
|
907 // |
|
908 if ( anyMarkedItems ) |
|
909 { |
|
910 if ( iManualItemMovingGoingOn ) |
|
911 { |
|
912 aMsk.setPair(EWmlCmdMoveOk, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OK); |
|
913 } |
|
914 else |
|
915 { |
|
916 aMsk.setPair(EAknSoftkeyContextOptions, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OPTION); |
|
917 } |
|
918 } |
|
919 else |
|
920 { |
|
921 aMsk.setPair(EBrowserBookmarksCmdOpen, R_BROWSER_BOOKMARKS_DYN_SK_TEXT_SOFTKEY_OPEN); |
|
922 } |
|
923 |
|
924 // |
|
925 // UNDER these special conditions, the msk is set differently: |
|
926 // |
|
927 if ( aGotoPane && aGotoPane->IsEditing() ) |
|
928 { |
|
929 // follow whatever the lsk is set to |
|
930 aMsk = aLsk; |
|
931 } |
|
932 else |
|
933 { |
|
934 if ( iInAdaptiveBookmarksFolder ) |
|
935 { |
|
936 if ( aContainer->Listbox()->UnfilteredNumberOfItems() <= 0 ) |
|
937 { |
|
938 aMsk.setPair( EWmlCmdGoToAddress, R_BROWSER_BOOKMARKS_DYN_SK_QTN_BROWSER_MSK_GOTO ); |
|
939 } |
|
940 } |
|
941 else |
|
942 { |
|
943 if ( (reinterpret_cast <CBrowserAppUi*>(AppUi())->IsEmbeddedModeOn()) || |
|
944 iCurrentFolder == KFavouritesRootUid ) |
|
945 { |
|
946 if ( aContainer->Listbox()->UnfilteredNumberOfItems() <= 0 ) |
|
947 { |
|
948 aMsk.setPair( EWmlCmdAddBookmark, R_BROWSER_BOOKMARKS_DYN_SK_QTN_MSK_ADD ); |
|
949 } |
|
950 } |
|
951 else |
|
952 { |
|
953 if ( aContainer->Listbox()->UnfilteredNumberOfItems() <= 0 ) |
|
954 { |
|
955 aMsk.setPair( EWmlCmdAddBookmark, R_BROWSER_BOOKMARKS_DYN_SK_QTN_MSK_ADD ); |
|
956 } |
|
957 } |
|
958 } |
|
959 } |
|
960 } |
|
961 |
|
962 // ---------------------------------------------------------------------------- |
|
963 // CBrowserBookmarksView::HandleBookmarksGotoPaneEventL |
|
964 // ---------------------------------------------------------------------------- |
|
965 // |
|
966 void CBrowserBookmarksView::HandleBookmarksGotoPaneEventL |
|
967 ( |
|
968 CBrowserBookmarksGotoPane* |
|
969 #ifdef _DEBUG |
|
970 aGotoPane // used only for debugging purposes |
|
971 #endif |
|
972 , |
|
973 MBookmarksGotoPaneObserver::TEvent aEvent |
|
974 ) |
|
975 { |
|
976 #ifdef _DEBUG |
|
977 __ASSERT_DEBUG( aGotoPane == TheContainer()->GotoPane(), \ |
|
978 Util::Panic( Util::EFavouritesInternal ) ); |
|
979 #endif |
|
980 |
|
981 switch ( aEvent ) |
|
982 { |
|
983 case MBookmarksGotoPaneObserver::EEventEnterKeyPressed: |
|
984 { |
|
985 HandleCommandL( EWmlCmdGotoPaneGoTo ); |
|
986 break; |
|
987 } |
|
988 |
|
989 case MBookmarksGotoPaneObserver::EEventEditingModeChanged: |
|
990 { |
|
991 UpdateCbaL(); |
|
992 break; |
|
993 } |
|
994 |
|
995 default: |
|
996 { |
|
997 break; |
|
998 } |
|
999 } |
|
1000 } |
|
1001 |
|
1002 // ---------------------------------------------------------------------------- |
|
1003 // CBrowserBookmarksView::CBrowserBookmarksView |
|
1004 // ---------------------------------------------------------------------------- |
|
1005 // |
|
1006 CBrowserBookmarksView::CBrowserBookmarksView ( MApiProvider& aApiProvider, |
|
1007 CRecentUrlStore& aRecentUrlStore, |
|
1008 TInt aInitialFolderUid ) |
|
1009 : CBrowserFavouritesView( aApiProvider, aInitialFolderUid ), |
|
1010 iFetchInit( EFalse ), |
|
1011 |
|
1012 iRecentUrlStore (aRecentUrlStore) |
|
1013 |
|
1014 |
|
1015 |
|
1016 { |
|
1017 // Initially start with default AP as Start Page AP. |
|
1018 iCurrentDefaultAp = iStartPageApUid = |
|
1019 ApiProvider().Preferences().DefaultAccessPoint(); |
|
1020 iPenEnabled = AknLayoutUtils::PenEnabled(); |
|
1021 iHandleDeleteInProgress = EFalse; |
|
1022 } |
|
1023 |
|
1024 // ---------------------------------------------------------------------------- |
|
1025 // CBrowserBookmarksView::ConstructL |
|
1026 // ---------------------------------------------------------------------------- |
|
1027 // |
|
1028 void CBrowserBookmarksView::ConstructL( TInt aViewResourceId ) |
|
1029 { |
|
1030 LOG_ENTERFN("BookmarksView::ConstructL"); |
|
1031 CBrowserFavouritesView::ConstructL( aViewResourceId ); |
|
1032 // Begin observing changes in active AP and default AP. Note that we |
|
1033 // set/unset observers here, not in DoActivateL/DoDeactivate: we do the |
|
1034 // observing even if the view is not active. This is needed, because |
|
1035 // preferences and the active AP can be changed from other views also. |
|
1036 // If notification kicks in when the view is not active, display RefreshL |
|
1037 // is, of course, suppressed (in base class). |
|
1038 ApiProvider().Preferences().AddObserverL( this ); |
|
1039 ApiProvider().Connection().SetApChangeObserver( *this ); |
|
1040 iOpenAdaptiveBookmarksWhenActivated = EFalse; |
|
1041 iAdaptiveBookmarksFolderSelected = EFalse; |
|
1042 iInAdaptiveBookmarksFolder=EFalse; |
|
1043 iAdaptiveBookmarksCurrentSetting = |
|
1044 ApiProvider().Preferences().AdaptiveBookmarks(); |
|
1045 iEnteredURL = NULL; |
|
1046 BROWSER_LOG( ( _L("delete iEnteredUrl 3") ) ); |
|
1047 iCursorPos = -1; |
|
1048 |
|
1049 // The following code gets all bookmarks and saves them back in the correct |
|
1050 // order in Favourites db. It was important to add this piece of code here |
|
1051 // in the constructor so that the first time when a bookmark is added |
|
1052 // through content view the correct index is used to insert the bookmark. |
|
1053 // TSW Error report id# MLEN-6Z8HMM |
|
1054 |
|
1055 iSaveBMOrder = ETrue; |
|
1056 |
|
1057 if ( Model().BeginL( /*aWrite=*/ETrue, /*aDbErrorNote*/ EFalse ) == |
|
1058 KErrNone ) |
|
1059 { |
|
1060 CFavouritesItemList* items = GetItemsLC( KFavouritesRootUid ); |
|
1061 CleanupStack::PopAndDestroy(); |
|
1062 Model().CommitL(); |
|
1063 } |
|
1064 |
|
1065 //Since the webcore will be reading the bookmark information in background |
|
1066 //thread, its important to refresh when the thread notifies the fresh data. |
|
1067 //Call to GetItemsLC above, which inturn calls ManualBMSortL will set iRefresh to false |
|
1068 //Make it true so that latest FavIcon db info is shown |
|
1069 iRefresh = ETrue; |
|
1070 |
|
1071 if (iPenEnabled) |
|
1072 { |
|
1073 Toolbar()->SetToolbarObserver(this); |
|
1074 } |
|
1075 |
|
1076 } |
|
1077 |
|
1078 // ---------------------------------------------------------------------------- |
|
1079 // CBrowserBookmarksView::HandleListBoxEventL |
|
1080 // ---------------------------------------------------------------------------- |
|
1081 // |
|
1082 void CBrowserBookmarksView::HandleListBoxEventL( |
|
1083 CEikListBox* aListBox, |
|
1084 MEikListBoxObserver::TListBoxEvent aEventType ) |
|
1085 { |
|
1086 if ( aListBox == Container()->Listbox() ) |
|
1087 { |
|
1088 switch ( aEventType ) |
|
1089 { |
|
1090 case MEikListBoxObserver::EEventEnterKeyPressed: |
|
1091 case MEikListBoxObserver::EEventItemDoubleClicked: |
|
1092 { |
|
1093 if ( iManualItemMovingGoingOn ) |
|
1094 { |
|
1095 MoveItemsL(); |
|
1096 return; |
|
1097 } |
|
1098 else if ( Container()->Listbox()->CurrentItem() ) |
|
1099 { |
|
1100 if ( Container()->Listbox()->CurrentItem()->IsItem()) |
|
1101 { |
|
1102 ActivateCurrentBookmarkL(); |
|
1103 return; |
|
1104 } |
|
1105 else |
|
1106 { |
|
1107 if (Container()->Listbox()->CurrentItem()->Uid()==KFavouritesAdaptiveItemsFolderUid) |
|
1108 { |
|
1109 iAdaptiveBookmarksFolderSelected = ETrue; |
|
1110 iInAdaptiveBookmarksFolder=ETrue; |
|
1111 SetEmptyTextL(); |
|
1112 RefreshL(); |
|
1113 |
|
1114 iPreviousViewID = KUidBrowserBookmarksViewId; |
|
1115 return; |
|
1116 } |
|
1117 } |
|
1118 } |
|
1119 break; |
|
1120 } |
|
1121 default: |
|
1122 { |
|
1123 break; |
|
1124 } |
|
1125 } |
|
1126 } |
|
1127 |
|
1128 if ( TheContainer()->Listbox()->CurrentItem()->IsFolder() ) |
|
1129 { |
|
1130 SetEmptyTextL(); |
|
1131 } |
|
1132 |
|
1133 CBrowserFavouritesView::HandleListBoxEventL( aListBox, aEventType ); |
|
1134 UpdateToolbarButtonsState(); |
|
1135 } |
|
1136 |
|
1137 // ---------------------------------------------------------------------------- |
|
1138 // CBrowserBookmarksView::DynInitMenuPaneL |
|
1139 // ---------------------------------------------------------------------------- |
|
1140 // |
|
1141 void CBrowserBookmarksView::DynInitMenuPaneL |
|
1142 ( |
|
1143 TInt aResourceId, |
|
1144 CEikMenuPane* aMenuPane, |
|
1145 TCommandVisibility::TIndex /*aIndex */, |
|
1146 const TBrowserFavouritesSelectionState& aState |
|
1147 ) |
|
1148 { |
|
1149 LOG_ENTERFN("CBrowserBookmarksView::DynInitMenuPaneL"); |
|
1150 |
|
1151 __ASSERT_DEBUG( (aMenuPane != NULL), Util::Panic( Util::EUninitializedData )); |
|
1152 |
|
1153 const CFavouritesItem* item = TheContainer()->Listbox()->CurrentItem(); |
|
1154 |
|
1155 switch ( aResourceId ) |
|
1156 { |
|
1157 case R_BROWSER_BOOKMARKS_MENU_PANE: |
|
1158 { |
|
1159 // downloads |
|
1160 aMenuPane->SetItemDimmed( EWmlCmdDownloads, !ApiProvider().BrCtlInterface().BrowserSettingL( TBrCtlDefs::ESettingsNumOfDownloads ) ); |
|
1161 |
|
1162 // edit |
|
1163 if ( !item || (iInAdaptiveBookmarksFolder && aState.IsEmpty() )) |
|
1164 { |
|
1165 aMenuPane->SetItemDimmed( EWmlCmdManageBookmarks, ETrue ); |
|
1166 } |
|
1167 |
|
1168 if ( iInAdaptiveBookmarksFolder && aState.IsEmpty() ) |
|
1169 { |
|
1170 aMenuPane->SetItemDimmed( EWmlCmdBmActions, ETrue ); |
|
1171 } |
|
1172 |
|
1173 if (!item) |
|
1174 { |
|
1175 aMenuPane->SetItemDimmed( EWmlCmdMarkUnmark, ETrue ); |
|
1176 } |
|
1177 /* |
|
1178 if (BRDO_BROWSER_UPDATE_UI_FF) |
|
1179 { |
|
1180 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
1181 } |
|
1182 else |
|
1183 { |
|
1184 aMenuPane->SetItemDimmed( EWmlCmdHelpMenu, ETrue ); |
|
1185 } |
|
1186 */ |
|
1187 break; |
|
1188 } |
|
1189 case R_GOTO_SUBMENU: |
|
1190 { |
|
1191 // back to page |
|
1192 if ( !ApiProvider().IsPageLoaded() && !ApiProvider().Fetching()) |
|
1193 { |
|
1194 aMenuPane->SetItemDimmed( EWmlCmdBackToPage, ETrue ); |
|
1195 } |
|
1196 |
|
1197 // bookmarks |
|
1198 aMenuPane->SetItemDimmed( EWmlCmdFavourites, ETrue ); |
|
1199 |
|
1200 // web feeds |
|
1201 if (ApiProvider().IsEmbeddedModeOn()) |
|
1202 { |
|
1203 aMenuPane->SetItemDimmed( EWmlCmdOpenFeedsFolder, ETrue ); |
|
1204 } |
|
1205 |
|
1206 // history |
|
1207 aMenuPane->SetItemDimmed( EWmlCmdHistory, ETrue ); |
|
1208 |
|
1209 // home |
|
1210 aMenuPane->SetItemDimmed( EWmlCmdLaunchHomePage, ETrue ); |
|
1211 |
|
1212 break; |
|
1213 } |
|
1214 case R_BMACTIONS_SUBMENU: |
|
1215 { |
|
1216 // send |
|
1217 aMenuPane->SetItemDimmed( EWmlCmdSendAddressViaUnifiedMessage, ETrue ); |
|
1218 |
|
1219 if (!item) |
|
1220 { |
|
1221 aMenuPane->SetItemDimmed( EWmlCmdSendBookmarkViaUnifiedMessage, ETrue ); |
|
1222 } |
|
1223 else if ( (item && (item->IsFolder() || |
|
1224 item->Uid() == KFavouritesAdaptiveItemsFolderUid || |
|
1225 item->ContextId()))) |
|
1226 { |
|
1227 aMenuPane->SetItemDimmed( EWmlCmdSendBookmarkViaUnifiedMessage, ETrue ); |
|
1228 } |
|
1229 |
|
1230 // copy to bookmarks |
|
1231 if ( !iInAdaptiveBookmarksFolder ) |
|
1232 { |
|
1233 aMenuPane->SetItemDimmed( EWmlCmdCopyToBookmarks, ETrue ); |
|
1234 } |
|
1235 |
|
1236 // set as homepage |
|
1237 if ( ApiProvider().Preferences().UiLocalFeatureSupported( KBrowserUiHomePageSetting ) ) |
|
1238 { |
|
1239 TBool dimSaveAsHomePage = EFalse; |
|
1240 |
|
1241 if ( (item && (item->IsFolder() || |
|
1242 item->Uid() == KFavouritesAdaptiveItemsFolderUid || |
|
1243 item->ContextId()))) |
|
1244 { |
|
1245 dimSaveAsHomePage = ETrue; |
|
1246 } |
|
1247 else |
|
1248 { |
|
1249 dimSaveAsHomePage = ApiProvider().IsEmbeddedModeOn() || !aState.CurrentIsItem() |
|
1250 || ( aState.MarkedCount() > 1 ); |
|
1251 } |
|
1252 |
|
1253 aMenuPane->SetItemDimmed( EWmlCmdSetAsHomePage, dimSaveAsHomePage ); |
|
1254 } |
|
1255 |
|
1256 // add bookmark |
|
1257 if ( iInAdaptiveBookmarksFolder ) |
|
1258 { |
|
1259 aMenuPane->SetItemDimmed( EWmlCmdAddBookmark, ETrue ); |
|
1260 } |
|
1261 |
|
1262 // set preferred/unpreferred |
|
1263 if ( !iContainer->Listbox()->CurrentItem() ) |
|
1264 { |
|
1265 aMenuPane->SetItemDimmed( EWmlCmdSetPreferredBookmark, ETrue ); |
|
1266 aMenuPane->SetItemDimmed( EWmlCmdSetUnPreferredBookmark, ETrue ); |
|
1267 } |
|
1268 else |
|
1269 { |
|
1270 if ( ( iCurrentFolder == KFavouritesRootUid )|| |
|
1271 !iContainer->Listbox()->GetDefaultData().iInSeamlessFolder || |
|
1272 ( iContainer->Listbox()->GetDefaultData().iPreferedId == |
|
1273 iContainer->Listbox()->CurrentItem()->Uid() ) |
|
1274 ) |
|
1275 { |
|
1276 aMenuPane->SetItemDimmed( EWmlCmdSetPreferredBookmark, ETrue ); |
|
1277 } |
|
1278 |
|
1279 if ( ( iCurrentFolder == KFavouritesRootUid ) || |
|
1280 !iContainer->Listbox()->GetDefaultData().iInSeamlessFolder || |
|
1281 !( iContainer->Listbox()->GetDefaultData().iPreferedId == |
|
1282 iContainer->Listbox()->CurrentItem()->Uid() ) |
|
1283 ) |
|
1284 { |
|
1285 aMenuPane->SetItemDimmed( EWmlCmdSetUnPreferredBookmark, |
|
1286 ETrue ); |
|
1287 } |
|
1288 } |
|
1289 |
|
1290 break; |
|
1291 } |
|
1292 case R_BOOKMARKS_EDIT_SUBMENU: |
|
1293 { |
|
1294 // edit bookmark |
|
1295 if (!item || aState.MarkedCount() > 0) |
|
1296 { |
|
1297 aMenuPane->SetItemDimmed( EWmlCmdEditBookmark, ETrue ); |
|
1298 } |
|
1299 else if ( (item && (item->IsFolder() || |
|
1300 item->Uid() == KFavouritesAdaptiveItemsFolderUid || |
|
1301 item->ContextId() || aState.CurrentIsSpecial() || iInAdaptiveBookmarksFolder))) |
|
1302 { |
|
1303 aMenuPane->SetItemDimmed( EWmlCmdEditBookmark, ETrue ); |
|
1304 } |
|
1305 |
|
1306 // rename |
|
1307 |
|
1308 // Can't rename recent urls and seamless folders - can only rename basic folders |
|
1309 if ( item->IsFolder() && |
|
1310 (item->Uid() != KFavouritesAdaptiveItemsFolderUid) && |
|
1311 (item->ContextId() == NULL) ) |
|
1312 { |
|
1313 // more item is marked -> dim rename |
|
1314 if ( aState.MarkedCount() > 0 ) |
|
1315 { |
|
1316 aMenuPane->SetItemDimmed( EWmlCmdRename, ETrue ); |
|
1317 } |
|
1318 } |
|
1319 else |
|
1320 { |
|
1321 aMenuPane->SetItemDimmed( EWmlCmdRename, ETrue ); |
|
1322 } |
|
1323 |
|
1324 |
|
1325 // delete |
|
1326 if (!item) |
|
1327 { |
|
1328 aMenuPane->SetItemDimmed( EWmlCmdDelete, ETrue ); |
|
1329 } |
|
1330 else if ( item->Uid() == KFavouritesAdaptiveItemsFolderUid || |
|
1331 item->ContextId() || |
|
1332 !aState.AnyDeletable() ) |
|
1333 { |
|
1334 aMenuPane->SetItemDimmed( EWmlCmdDelete, ETrue ); |
|
1335 } |
|
1336 |
|
1337 // move |
|
1338 if ( iInAdaptiveBookmarksFolder || (TheContainer()->Listbox()->UnfilteredNumberOfItems() < 2 ) ) |
|
1339 { |
|
1340 aMenuPane->SetItemDimmed( EWmlCmdMove, ETrue ); |
|
1341 } |
|
1342 |
|
1343 // move to folder |
|
1344 if ( !aState.AnyPlainItem() || (iCurrentFolder == KFavouritesRootUid && |
|
1345 iContainer && iContainer->Listbox() && !iContainer->Listbox()->AnyFoldersL()) ) |
|
1346 { |
|
1347 aMenuPane->SetItemDimmed( EWmlCmdMoveToFolder, ETrue ); |
|
1348 } |
|
1349 |
|
1350 // create folder |
|
1351 if ( iCurrentFolder != KFavouritesRootUid || iInAdaptiveBookmarksFolder ) |
|
1352 { |
|
1353 aMenuPane->SetItemDimmed( EWmlCmdNewFolder, ETrue ); |
|
1354 } |
|
1355 |
|
1356 |
|
1357 break; |
|
1358 } |
|
1359 case R_BROWSER_FAVOURITES_MENU_PANE_MARK_UNMARK: |
|
1360 { |
|
1361 // For items and folders, show "Mark" or "Unmark". |
|
1362 aMenuPane->SetItemDimmed ( aState.CurrentIsMarked() ? EWmlCmdMark : EWmlCmdUnmark, ETrue ); |
|
1363 #ifndef SHOW_UNMARK_ALL_ALWAYS |
|
1364 |
|
1365 // We must show "Unmark all", even if nothing is marked. |
|
1366 // |
|
1367 // The case when there are no items at all, is not handled here: |
|
1368 // in that case we don't have "Edit list" menu. |
|
1369 if ( aState.NoneIsMarked() ) |
|
1370 { |
|
1371 aMenuPane->SetItemDimmed( EWmlCmdUnmarkAll, ETrue ); |
|
1372 } |
|
1373 #endif // SHOW_UNMARK_ALL_ALWAYS |
|
1374 |
|
1375 #ifndef SHOW_MARK_ALL_ALWAYS |
|
1376 // As for "mark all", consider items only. |
|
1377 if ( aState.iVisibleItemCount == aState.iMarkedItemCount ) |
|
1378 { |
|
1379 aMenuPane->SetItemDimmed( EWmlCmdMarkAll, ETrue ); |
|
1380 } |
|
1381 #endif // SHOW_MARK_ALL_ALWAYS |
|
1382 break; |
|
1383 } |
|
1384 case R_BROWSER_BOOKMARKS_MENU_PANE_OK: |
|
1385 { |
|
1386 // Bookmark-specific handling. |
|
1387 if ( aState.IsEmpty() || (TheContainer()->Listbox()->UnfilteredNumberOfItems() < 2) ) |
|
1388 { |
|
1389 aMenuPane->SetItemDimmed( EWmlCmdMove, ETrue ); |
|
1390 } |
|
1391 else |
|
1392 { |
|
1393 aMenuPane->SetItemDimmed( EWmlCmdMove, EFalse ); |
|
1394 } |
|
1395 const CFavouritesItem* item = TheContainer()->Listbox()->CurrentItem(); |
|
1396 if ( ( item ) && |
|
1397 ( ( item->Uid() == KFavouritesAdaptiveItemsFolderUid ) || |
|
1398 ( item->ContextId() != NULL ) ) |
|
1399 ) |
|
1400 { |
|
1401 // We can't delete adaptive bookmarks folder, |
|
1402 // or seamless folders |
|
1403 aMenuPane->SetItemDimmed( EWmlCmdDelete, ETrue ); |
|
1404 } |
|
1405 |
|
1406 if (!iPenEnabled) |
|
1407 { |
|
1408 aMenuPane->SetItemDimmed( EWmlCmdAddBookmark, ETrue ); |
|
1409 aMenuPane->SetItemDimmed( EWmlCmdCopyToBookmarks, ETrue ); |
|
1410 aMenuPane->SetItemDimmed( EWmlCmdSwitchToGotoActive, ETrue ); |
|
1411 aMenuPane->SetItemDimmed( EWmlCmdNewFolder, ETrue ); |
|
1412 } |
|
1413 |
|
1414 break; |
|
1415 } |
|
1416 default: |
|
1417 { |
|
1418 break; |
|
1419 } |
|
1420 } |
|
1421 } |
|
1422 |
|
1423 // ---------------------------------------------------------------------------- |
|
1424 // CBrowserBookmarksView::RootTitleResourceId |
|
1425 // ---------------------------------------------------------------------------- |
|
1426 // |
|
1427 TInt CBrowserBookmarksView::RootTitleResourceId() const |
|
1428 { |
|
1429 if ( iOpenAdaptiveBookmarksWhenActivated ) |
|
1430 { |
|
1431 return R_BROWSER_ADAPTIVE_BOOKMARKS_TITLE; |
|
1432 } |
|
1433 else |
|
1434 { |
|
1435 return R_BROWSER_OPTION_BOOKMARKS; |
|
1436 } |
|
1437 } |
|
1438 |
|
1439 // ---------------------------------------------------------------------------- |
|
1440 // CBrowserBookmarksView::OptionsMenuResourceId |
|
1441 // ---------------------------------------------------------------------------- |
|
1442 // |
|
1443 TInt CBrowserBookmarksView::OptionsMenuResourceId() const |
|
1444 { |
|
1445 return ( R_BROWSER_BOOKMARKS_MENU_BAR ); |
|
1446 } |
|
1447 |
|
1448 // ---------------------------------------------------------------------------- |
|
1449 // CBrowserBookmarksView::OkOptionsMenuResourceId |
|
1450 // ---------------------------------------------------------------------------- |
|
1451 // |
|
1452 TInt CBrowserBookmarksView::OkOptionsMenuResourceId() const |
|
1453 { |
|
1454 return R_BROWSER_BOOKMARKS_MENU_BAR_OK; |
|
1455 } |
|
1456 |
|
1457 // ---------------------------------------------------------------------------- |
|
1458 // CBrowserBookmarksView::CreateModelL |
|
1459 // ---------------------------------------------------------------------------- |
|
1460 // |
|
1461 CBrowserFavouritesModel* CBrowserBookmarksView::CreateModelL() |
|
1462 { |
|
1463 return CBrowserBookmarksModel::NewL(ApiProvider()); |
|
1464 } |
|
1465 |
|
1466 // ---------------------------------------------------------------------------- |
|
1467 // CBrowserBookmarksView::CreateContainerL |
|
1468 // ---------------------------------------------------------------------------- |
|
1469 |
|
1470 CBrowserFavouritesContainer* CBrowserBookmarksView::CreateContainerL() |
|
1471 { |
|
1472 CBrowserBookmarksContainer* container = |
|
1473 CBrowserBookmarksContainer::NewL( ClientRect(), *this ); |
|
1474 container->GotoPane()->SetGPObserver( this ); |
|
1475 return container; |
|
1476 } |
|
1477 |
|
1478 // ---------------------------------------------------------------------------- |
|
1479 // CBrowserBookmarksView::MoveItemsL |
|
1480 // ---------------------------------------------------------------------------- |
|
1481 void CBrowserBookmarksView::MoveItemsL() |
|
1482 { |
|
1483 // Get a copy of the ordered array, it may contain visible and hidden items. |
|
1484 CArrayFixFlat<TInt>* orderArray = |
|
1485 new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh); |
|
1486 CleanupStack::PushL( orderArray ); |
|
1487 |
|
1488 orderArray->AppendL( & ( iCurrentOrder->GetBookMarksOrder()[0] ), |
|
1489 iCurrentOrder->GetBookMarksOrder().Count() ); |
|
1490 |
|
1491 // Create a sorted "bookmarks to be moved" array |
|
1492 CArrayFixFlat<TInt>* sortedItemsToMove = |
|
1493 new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh); |
|
1494 CleanupStack::PushL( sortedItemsToMove ); |
|
1495 |
|
1496 // Get the Uid of currently highlighted bookmark item from listbox. |
|
1497 // NOTE: Listbox indexes is based on "visible" items in list box, our order |
|
1498 // array has visible and invisible items, we have to use Uid to find items. |
|
1499 const CFavouritesItem* toItem = Container()->Listbox()->CurrentItem(); |
|
1500 TInt toUid( (*orderArray)[orderArray->Count()-1] ); |
|
1501 if ( toItem ) { |
|
1502 toUid = toItem->Uid(); |
|
1503 } |
|
1504 |
|
1505 // Walk our copy of the ordered bookmark array and |
|
1506 // 1. Delete the bookmark items to be moved from the ordered array |
|
1507 // 2. Sort the bookmark items to be moved to match the visible order of the list |
|
1508 TInt i( 0 ); // index into order bookmark list |
|
1509 TInt j( 0 ); // index into sorted iItemsToMove |
|
1510 for ( i=0; i < orderArray->Count(); i++ ) { |
|
1511 TInt orderArrayUid = (*orderArray)[i]; |
|
1512 |
|
1513 // Find bookmark to be moved, sort and remove |
|
1514 for ( j=0; j < iItemsToMove->Count(); j++ ) { |
|
1515 if ( (*iItemsToMove)[j] == orderArrayUid ) { |
|
1516 sortedItemsToMove->AppendL( (*iItemsToMove)[j] ); |
|
1517 orderArray->Delete( i ); |
|
1518 break; |
|
1519 } |
|
1520 } |
|
1521 |
|
1522 // Stop sorting, if we're done |
|
1523 if ( iItemsToMove->Count() == sortedItemsToMove->Count() ) { |
|
1524 break; |
|
1525 } |
|
1526 } |
|
1527 |
|
1528 // Find the highlighted bookmark item and insert the newly ordered |
|
1529 // "bookmark items to be moved" in there |
|
1530 for ( i=0; i < orderArray->Count(); i++ ) { |
|
1531 if ( toUid == (*orderArray)[ i ] ) { |
|
1532 for ( j=0; j < sortedItemsToMove->Count(); j++ ) { |
|
1533 orderArray->InsertL( i+j, (*sortedItemsToMove)[j] ); |
|
1534 } |
|
1535 break; |
|
1536 } |
|
1537 } |
|
1538 |
|
1539 iCurrentOrder->SetBookMarksOrderL( *orderArray ); |
|
1540 Model().Database().SetData( CurrentFolder(), *iCurrentOrder ); |
|
1541 |
|
1542 iManualItemMovingGoingOn = EFalse; |
|
1543 Container()->Listbox()->ClearSelection(); |
|
1544 iPreferredHighlightUid = (*sortedItemsToMove)[0]; |
|
1545 |
|
1546 // Delete our arrays sortedItemsToMove, orderArray |
|
1547 CleanupStack::PopAndDestroy( 2 ); |
|
1548 delete iItemsToMove; |
|
1549 iItemsToMove = NULL; |
|
1550 |
|
1551 UpdateCbaL(); |
|
1552 // UnDim Toolbar buttons |
|
1553 DimToolbarButtons(EFalse); |
|
1554 |
|
1555 } |
|
1556 |
|
1557 // ---------------------------------------------------------------------------- |
|
1558 // CBrowserBookmarksView::CancelMoveItems |
|
1559 // ---------------------------------------------------------------------------- |
|
1560 // |
|
1561 void CBrowserBookmarksView::CancelMoveItemsL() |
|
1562 { |
|
1563 iManualItemMovingGoingOn = EFalse; |
|
1564 HandleCommandL(EWmlCmdUnmarkAll); |
|
1565 UpdateCbaL(); |
|
1566 // UnDim Toolbar buttons |
|
1567 DimToolbarButtons(EFalse); |
|
1568 iPreferredHighlightUid = ( *iItemsToMove )[0]; |
|
1569 delete iItemsToMove; |
|
1570 iItemsToMove = NULL; |
|
1571 RefreshL(); |
|
1572 } |
|
1573 |
|
1574 |
|
1575 // ---------------------------------------------------------------------------- |
|
1576 // CBrowserBookmarksView::StartMoveItems |
|
1577 // ---------------------------------------------------------------------------- |
|
1578 // |
|
1579 void CBrowserBookmarksView::StartMoveItemsL() |
|
1580 { |
|
1581 iManualItemMovingGoingOn = ETrue; |
|
1582 |
|
1583 TInt moveFrom = ( *Container()->Listbox()->SelectedRealIndexesLC() )[0]; |
|
1584 CleanupStack::PopAndDestroy(); //SelectedRealIndexesLC |
|
1585 TInt count = Container()->Listbox()->SelectedRealIndexesLC()->Count(); |
|
1586 CleanupStack::PopAndDestroy(); //SelectedRealIndexesLC |
|
1587 if ( ( count == 1 ) |
|
1588 && ( Container()->Listbox()->CurrentItemRealIndex() == moveFrom ) ) |
|
1589 { |
|
1590 HandleCommandL(EWmlCmdMark); |
|
1591 } |
|
1592 |
|
1593 |
|
1594 if (iItemsToMove) |
|
1595 { |
|
1596 delete iItemsToMove; |
|
1597 iItemsToMove = NULL; |
|
1598 } |
|
1599 iItemsToMove = new (ELeave) CArrayFixFlat<TInt>( KGranularityHigh ); |
|
1600 |
|
1601 CArrayPtr<const CFavouritesItem>* items = |
|
1602 Container()->Listbox()->SelectedItemsLC(); |
|
1603 |
|
1604 for ( TInt i = 0; i < items->Count(); i++ ) |
|
1605 { |
|
1606 iItemsToMove->AppendL( (*(*items)[i]).Uid() ); |
|
1607 } |
|
1608 CleanupStack::PopAndDestroy(items); |
|
1609 UpdateCbaL(); |
|
1610 // Dim Toolbar buttons |
|
1611 DimToolbarButtons(ETrue); |
|
1612 } |
|
1613 |
|
1614 // ---------------------------------------------------------------------------- |
|
1615 // CBrowserBookmarksView::ManualBMSortL |
|
1616 // ---------------------------------------------------------------------------- |
|
1617 // |
|
1618 TBool CBrowserBookmarksView::ManualBMSortL( TInt aFolder, |
|
1619 CFavouritesItemList* aItems ) |
|
1620 { |
|
1621 __ASSERT_DEBUG( (aItems != NULL), Util::Panic( Util::EUninitializedData )); |
|
1622 |
|
1623 delete iCurrentOrder; |
|
1624 iCurrentOrder = NULL; |
|
1625 iCurrentOrder = CBrowserBookmarksOrder::NewLC(); |
|
1626 CleanupStack::Pop(); |
|
1627 if ( aItems->Count() ) |
|
1628 { |
|
1629 CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh); |
|
1630 CleanupStack::PushL(orderArray); |
|
1631 |
|
1632 if ( !Model().Database().GetData( aFolder ,*iCurrentOrder ) ) |
|
1633 { |
|
1634 if ( iCurrentOrder->GetBookMarksOrder().Count() > 0 ) |
|
1635 { |
|
1636 orderArray->AppendL( & ( iCurrentOrder->GetBookMarksOrder()[0] ), |
|
1637 iCurrentOrder->GetBookMarksOrder().Count()); |
|
1638 |
|
1639 if ( aFolder == KFavouritesRootUid ) |
|
1640 { |
|
1641 TInt i = 0; |
|
1642 |
|
1643 while ( i < orderArray->Count() && |
|
1644 !( (*orderArray)[i] == KFavouritesStartPageUid )) |
|
1645 { |
|
1646 i++; |
|
1647 } |
|
1648 |
|
1649 if ( i == orderArray->Count() ) |
|
1650 { |
|
1651 if ( iStartPagePresent ) |
|
1652 { |
|
1653 orderArray->InsertL( 0, KFavouritesStartPageUid ); |
|
1654 iSaveBMOrder = ETrue; |
|
1655 } |
|
1656 } |
|
1657 else |
|
1658 { |
|
1659 if ( !iStartPagePresent ) |
|
1660 { |
|
1661 orderArray->Delete(i); |
|
1662 iSaveBMOrder = ETrue; |
|
1663 } |
|
1664 } |
|
1665 if ( iInsertAdaptiveBookmarksFolder ) |
|
1666 { |
|
1667 iInsertAdaptiveBookmarksFolder = EFalse; |
|
1668 i = 0; |
|
1669 |
|
1670 while ( i < orderArray->Count() && |
|
1671 !( (*orderArray)[i] == |
|
1672 KFavouritesAdaptiveItemsFolderUid )) |
|
1673 { |
|
1674 i++; |
|
1675 } |
|
1676 |
|
1677 if ( i < orderArray->Count() ) |
|
1678 { |
|
1679 orderArray->Delete(i); |
|
1680 } |
|
1681 if ( orderArray->Count() ) |
|
1682 { |
|
1683 if ( (*orderArray)[0] == KFavouritesStartPageUid ) |
|
1684 { |
|
1685 orderArray->InsertL( 1, |
|
1686 KFavouritesAdaptiveItemsFolderUid ); |
|
1687 } |
|
1688 else |
|
1689 { |
|
1690 orderArray->InsertL( 0, |
|
1691 KFavouritesAdaptiveItemsFolderUid ); |
|
1692 } |
|
1693 } |
|
1694 } |
|
1695 else |
|
1696 if ( (ADAPTIVEBOOKMARKS) && |
|
1697 ( ApiProvider().Preferences().AdaptiveBookmarks() == |
|
1698 EWmlSettingsAdaptiveBookmarksOn ) ) |
|
1699 { |
|
1700 i = 0; |
|
1701 |
|
1702 while ( i < orderArray->Count() && |
|
1703 !( (*orderArray)[i] == |
|
1704 KFavouritesAdaptiveItemsFolderUid )) |
|
1705 { |
|
1706 i++; |
|
1707 } |
|
1708 |
|
1709 if ( i == orderArray->Count() != 0 ) |
|
1710 { |
|
1711 if ( (*orderArray)[0] == KFavouritesStartPageUid ) |
|
1712 { |
|
1713 orderArray->InsertL( 1, |
|
1714 KFavouritesAdaptiveItemsFolderUid ); |
|
1715 } |
|
1716 else |
|
1717 { |
|
1718 orderArray->InsertL( 0, |
|
1719 KFavouritesAdaptiveItemsFolderUid ); |
|
1720 } |
|
1721 } |
|
1722 } |
|
1723 |
|
1724 //add new items to the beginning of the list, if there is any |
|
1725 for ( TInt j = 0; j < aItems->Count(); j++ ) |
|
1726 { |
|
1727 i = 0; |
|
1728 while ( i < orderArray->Count() && |
|
1729 !( (*orderArray)[i] == aItems->At(j)->Uid() )) |
|
1730 { |
|
1731 i++; |
|
1732 } |
|
1733 |
|
1734 if ( i == orderArray->Count() && |
|
1735 !(aItems->At(j)->IsFactoryItem() ) && |
|
1736 !(aItems->At(j)->Uid() == |
|
1737 KFavouritesAdaptiveItemsFolderUid) && |
|
1738 !(aItems->At(j)->Uid() == KFavouritesStartPageUid) ) |
|
1739 { |
|
1740 Model().AddUidToLastPlaceL( aItems->At(j)->Uid(), |
|
1741 orderArray, iCurrentOrder ); |
|
1742 } |
|
1743 } |
|
1744 } |
|
1745 Model().ManualSortL(aFolder, iCurrentOrder, orderArray, aItems); |
|
1746 orderArray->Reset(); |
|
1747 } |
|
1748 } |
|
1749 |
|
1750 orderArray->Reset(); |
|
1751 |
|
1752 if ( aItems->Count() ) |
|
1753 { |
|
1754 for ( TInt i = 0; i < aItems->Count(); i++ ) |
|
1755 { |
|
1756 orderArray->AppendL( (*aItems)[i]->Uid() ); |
|
1757 } |
|
1758 iCurrentOrder->SetBookMarksOrderL( *orderArray ); |
|
1759 } |
|
1760 if ( iSaveBMOrder ) |
|
1761 { |
|
1762 iRefresh = EFalse; |
|
1763 iSaveBMOrder = EFalse; |
|
1764 Model().Database().SetData( aFolder, *iCurrentOrder ); |
|
1765 } |
|
1766 CleanupStack::PopAndDestroy( orderArray ); |
|
1767 } |
|
1768 return ETrue; |
|
1769 } |
|
1770 |
|
1771 // ---------------------------------------------------------------------------- |
|
1772 // CBrowserBookmarksView::GetItemsLC |
|
1773 // ---------------------------------------------------------------------------- |
|
1774 // |
|
1775 CFavouritesItemList* CBrowserBookmarksView::GetItemsLC( TInt aFolder ) |
|
1776 { |
|
1777 PERFLOG_LOCAL_INIT |
|
1778 PERFLOG_STOPWATCH_START |
|
1779 CFavouritesItemList* items; |
|
1780 if ( iInAdaptiveBookmarksFolder ) |
|
1781 { |
|
1782 items= new (ELeave) CFavouritesItemList(); |
|
1783 CleanupStack::PushL(items);//1 |
|
1784 CDesCArrayFlat* aditems = new ( ELeave ) |
|
1785 CDesCArrayFlat( KBrowserDesCArrayGranularity ); |
|
1786 aditems->Reset(); |
|
1787 CleanupStack::PushL(aditems);//2 |
|
1788 |
|
1789 CDesCArrayFlat* adnames = new ( ELeave ) |
|
1790 CDesCArrayFlat( KBrowserDesCArrayGranularity ); |
|
1791 adnames->Reset(); |
|
1792 CleanupStack::PushL(adnames);//3 |
|
1793 |
|
1794 CFavouritesItem* adaptiveItem; |
|
1795 |
|
1796 if ( !iRecentUrlStore.GetData( *aditems, *adnames) ) |
|
1797 { |
|
1798 for (TInt i=0;i<aditems->MdcaCount(); i++) |
|
1799 { |
|
1800 adaptiveItem= CFavouritesItem::NewL(); |
|
1801 CleanupStack::PushL(adaptiveItem);//4 |
|
1802 adaptiveItem->SetUrlL( aditems->MdcaPoint(i) ); |
|
1803 adaptiveItem->SetNameL(adnames->MdcaPoint(i).Left(KFavouritesMaxName)); |
|
1804 adaptiveItem->SetType(CFavouritesItem::EItem); |
|
1805 adaptiveItem->SetParentFolder(KFavouritesAdaptiveItemsFolderUid); |
|
1806 items->AppendL(adaptiveItem); |
|
1807 CleanupStack::Pop(); // adaptiveItem |
|
1808 } |
|
1809 } |
|
1810 CleanupStack::PopAndDestroy( 2 );// aditems, adnames |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 items = new (ELeave) CFavouritesItemList(); |
|
1815 CleanupStack::PushL( items ); |
|
1816 Model().Database().GetAll( *items, aFolder ); |
|
1817 TInt aBMPosition = KAdaptiveBookmarksFirstPositionInBMView; // Adaptive BM folder is first if there is no startpage |
|
1818 if ( aFolder == KFavouritesRootUid ) |
|
1819 { |
|
1820 // Create Start Page item to be displayed in root folder (if exist). |
|
1821 // (Start Page does not really exist in the database.) |
|
1822 CFavouritesItem* startPage = CreateStartPageBookmarkL(); |
|
1823 if ( startPage ) |
|
1824 { |
|
1825 if (!iStartPagePresent) |
|
1826 { |
|
1827 iStartPagePresent = ETrue; |
|
1828 iSaveBMOrder = ETrue; |
|
1829 } |
|
1830 CleanupStack::PushL( startPage ); // ownersip is here. |
|
1831 items->InsertL( 0, startPage ); |
|
1832 CleanupStack::Pop(); // startPage: owner is the list now. |
|
1833 aBMPosition=KAdaptiveBookmarksSecondPositionInBMView; // Adaptive BM folder is second if there is a startpage item |
|
1834 } |
|
1835 else |
|
1836 { |
|
1837 if (iStartPagePresent) |
|
1838 { |
|
1839 iStartPagePresent = EFalse; |
|
1840 iSaveBMOrder = ETrue; |
|
1841 } |
|
1842 } |
|
1843 } |
|
1844 |
|
1845 if ( aFolder == KFavouritesRootUid ) |
|
1846 { |
|
1847 // Create Adaptive Items Folder item to be displayed in root folder (if exist). |
|
1848 // (Start Page does not really exist in the database.) |
|
1849 if ( ( ADAPTIVEBOOKMARKS ) && |
|
1850 ( ApiProvider().Preferences().AdaptiveBookmarks() == |
|
1851 EWmlSettingsAdaptiveBookmarksOn )) |
|
1852 { |
|
1853 CFavouritesItem* adaptiveItemsFolder = |
|
1854 Model().Database().CreateAdaptiveItemsFolderL(); |
|
1855 CleanupStack::PushL(adaptiveItemsFolder); |
|
1856 HBufC* folderName=StringLoader::LoadLC( |
|
1857 R_BROWSER_ADAPTIVE_BOOKMARKS_FOLDER); |
|
1858 adaptiveItemsFolder->SetNameL(*folderName); |
|
1859 |
|
1860 CleanupStack::PopAndDestroy();//folderName |
|
1861 items->InsertL( aBMPosition , adaptiveItemsFolder ); |
|
1862 CleanupStack::Pop(); // adaptiveItemsFolder: owner is the list now. |
|
1863 } |
|
1864 } |
|
1865 ManualBMSortL( aFolder, items ); |
|
1866 } |
|
1867 PERFLOG_STOP_WRITE("\t\t\t\t BM View GetItemsLC" ); |
|
1868 return items; |
|
1869 } |
|
1870 |
|
1871 // ---------------------------------------------------------------------------- |
|
1872 // CBrowserBookmarksView::RefreshL |
|
1873 // ---------------------------------------------------------------------------- |
|
1874 // |
|
1875 void CBrowserBookmarksView::RefreshL( TBool aDbErrorNote ) |
|
1876 { |
|
1877 // Same as base class method, except that refreshing Goto Pane is |
|
1878 // disallowed when fetching is in progress. |
|
1879 // Base class call is TRAP-ped to make sure that frozen state of the Goto |
|
1880 // Pane does not stay in due to a leave; but after removing the frozen |
|
1881 // state, we trow up the catched leave again (if any). |
|
1882 TBool fetching = ApiProvider().Fetching(); |
|
1883 |
|
1884 if ( (fetching && TheContainer() && TheContainer()->GotoPane() ) |
|
1885 || ( TheContainer() && TheContainer()->GotoPane() && TheContainer()->GotoPane()->IsEditing() )) |
|
1886 { |
|
1887 TheContainer()->GotoPane()->Freeze( ETrue ); |
|
1888 } |
|
1889 |
|
1890 TRAPD( err, CBrowserFavouritesView::RefreshL( aDbErrorNote ) ); |
|
1891 |
|
1892 |
|
1893 if ( TheContainer() && TheContainer()->GotoPane() ) |
|
1894 { |
|
1895 TheContainer()->GotoPane()->Freeze( EFalse ); |
|
1896 } |
|
1897 User::LeaveIfError( err ); |
|
1898 // Refresh (i.e. bookmark creation in an empty folder) may cause the need |
|
1899 // for toolbar button state to change. |
|
1900 UpdateToolbarButtonsState(); |
|
1901 } |
|
1902 |
|
1903 // ---------------------------------------------------------------------------- |
|
1904 // CBrowserBookmarksView::DoActivateL |
|
1905 // ---------------------------------------------------------------------------- |
|
1906 // |
|
1907 void CBrowserBookmarksView::DoActivateL ( |
|
1908 const TVwsViewId& aPrevViewId, |
|
1909 TUid aCustomMessageId, |
|
1910 const TDesC8& aCustomMessage |
|
1911 ) |
|
1912 { |
|
1913 PERFLOG_LOCAL_INIT |
|
1914 PERFLOG_STOPWATCH_START |
|
1915 LOG_ENTERFN("CBrowserBookmarksView::DoActivateL"); |
|
1916 LOG_WRITE_FORMAT(" aCustomMessageId: %d", aCustomMessageId); |
|
1917 |
|
1918 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
1919 StatusPane()->MakeVisible( ETrue ); |
|
1920 ApiProvider().Display().ClearMessageInfo(); |
|
1921 |
|
1922 iAdaptiveBookmarksFolderWasActive = EFalse; |
|
1923 |
|
1924 if ( iOpenAdaptiveBookmarksWhenActivated ) |
|
1925 { |
|
1926 iInAdaptiveBookmarksFolder = ETrue; |
|
1927 } |
|
1928 |
|
1929 CBrowserFavouritesView::DoActivateL |
|
1930 ( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
1931 ApiProvider().BrCtlInterface().AddLoadEventObserverL( this ); |
|
1932 |
|
1933 if ( iPreferencesChanged ) |
|
1934 { |
|
1935 iPreferencesChanged=EFalse; |
|
1936 if ( iInAdaptiveBookmarksFolder ) |
|
1937 { |
|
1938 SetEmptyTextL(); |
|
1939 RefreshL(); |
|
1940 } |
|
1941 } |
|
1942 |
|
1943 if ( aCustomMessageId == KUidCustomMsgDownloadsList ) |
|
1944 { |
|
1945 LOG_WRITE(" KUidCustomMsgDownloadsList"); |
|
1946 // open the downloads list asynchronously not to block DoActivateL! |
|
1947 if ( iDownloadsListExecuter == 0 ) |
|
1948 { |
|
1949 iDownloadsListExecuter = new (ELeave) CAsyncDownloadsListExecuter( ApiProvider() ); |
|
1950 } |
|
1951 iDownloadsListExecuter->Start(); |
|
1952 } |
|
1953 if ( iOpenAdaptiveBookmarksWhenActivated ) |
|
1954 { |
|
1955 iInAdaptiveBookmarksFolder = ETrue; |
|
1956 SetEmptyTextL(); |
|
1957 RefreshL(); |
|
1958 iOpenAdaptiveBookmarksWhenActivated = EFalse; |
|
1959 } |
|
1960 |
|
1961 UpdateToolbarButtonsState(); |
|
1962 |
|
1963 PERFLOG_STOP_WRITE("BMView DoActivate") |
|
1964 // LOG_LEAVEFN("CBrowserBookmarksView::DoActivateL"); |
|
1965 } |
|
1966 |
|
1967 // ---------------------------------------------------------------------------- |
|
1968 // CBrowserBookmarksView::DoDeactivate |
|
1969 // ---------------------------------------------------------------------------- |
|
1970 // |
|
1971 void CBrowserBookmarksView::DoDeactivate() |
|
1972 { |
|
1973 if ( !iSaveStateOnDeactivate ) |
|
1974 { |
|
1975 ExitAdaptiveBookmarks(); |
|
1976 } |
|
1977 |
|
1978 if ( !ApiProvider().ExitInProgress() ) |
|
1979 { |
|
1980 ApiProvider().BrCtlInterface().RemoveLoadEventObserver( this ); |
|
1981 } |
|
1982 CBrowserFavouritesView::DoDeactivate(); |
|
1983 iManualItemMovingGoingOn = EFalse; |
|
1984 // UnDim Toolbar buttons |
|
1985 DimToolbarButtons(EFalse); |
|
1986 } |
|
1987 |
|
1988 // ---------------------------------------------------------------------------- |
|
1989 // CBrowserBookmarksView::GotoUrlInGotoPaneL |
|
1990 // ---------------------------------------------------------------------------- |
|
1991 // |
|
1992 void CBrowserBookmarksView::GotoUrlInGotoPaneL() |
|
1993 { |
|
1994 LOG_ENTERFN("BookmarksView::GotoUrlInGotoPaneL"); |
|
1995 CBrowserBookmarksContainer* container = TheContainer(); |
|
1996 if ( container->GotoPane()->IsEditing() ) |
|
1997 { |
|
1998 // Dim Toolbar buttons |
|
1999 DimToolbarButtons(EFalse); |
|
2000 |
|
2001 delete iEnteredURL; |
|
2002 iEnteredURL = NULL; |
|
2003 BROWSER_LOG( ( _L("delete iEnteredUrl 4") ) ); |
|
2004 |
|
2005 iEnteredURL = container->GotoPane()->GetTextL(); |
|
2006 if ( iEnteredURL ) |
|
2007 { |
|
2008 iTrId = 0; |
|
2009 CEikEdwin* editor = STATIC_CAST(CEikEdwin*, container->GotoPane()->ComponentControl(1)); |
|
2010 iCursorPos = editor->CursorPos(); |
|
2011 |
|
2012 UpdateCbaL(); |
|
2013 // Cancel editing, but leave entered text in place. |
|
2014 container->GotoPane()->CancelEditingL(); |
|
2015 |
|
2016 ApiProvider().FetchL( iEnteredURL->Des(), CBrowserLoadObserver::ELoadUrlTypeOther ); |
|
2017 } |
|
2018 } |
|
2019 } |
|
2020 // ---------------------------------------------------------------------------- |
|
2021 // CBrowserBookmarksView::ExitAdaptiveBookmarks() |
|
2022 // ---------------------------------------------------------------------------- |
|
2023 // |
|
2024 void CBrowserBookmarksView::ExitAdaptiveBookmarks() |
|
2025 { |
|
2026 if (iInAdaptiveBookmarksFolder) |
|
2027 { |
|
2028 iAdaptiveBookmarksFolderWasActive = ETrue; |
|
2029 iInAdaptiveBookmarksFolder=EFalse; |
|
2030 delete iDomainFolderName; |
|
2031 iDomainFolderName=NULL; |
|
2032 } |
|
2033 } |
|
2034 |
|
2035 // ---------------------------------------------------------------------------- |
|
2036 // CBrowserBookmarksView::DimToolbarButtons() |
|
2037 // ---------------------------------------------------------------------------- |
|
2038 // |
|
2039 void CBrowserBookmarksView::DimToolbarButtons(TBool aDimButtons) |
|
2040 { |
|
2041 Toolbar()->SetDimmed(aDimButtons); |
|
2042 if (!aDimButtons) |
|
2043 { |
|
2044 // when undimming buttons we may not want them all back on |
|
2045 UpdateToolbarButtonsState(); |
|
2046 } |
|
2047 Toolbar()->DrawNow(); |
|
2048 } |
|
2049 |
|
2050 // ---------------------------------------------------------------------------- |
|
2051 // CBrowserBookmarksView::ActivateCurrentBookmarkL |
|
2052 // ---------------------------------------------------------------------------- |
|
2053 // |
|
2054 void CBrowserBookmarksView::ActivateCurrentBookmarkL() |
|
2055 { |
|
2056 if ( Container() && Container()->Listbox() ) |
|
2057 { |
|
2058 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
2059 if ( item && item->IsItem() ) |
|
2060 { |
|
2061 ApiProvider().FetchBookmarkL( *item ); |
|
2062 } |
|
2063 } |
|
2064 } |
|
2065 |
|
2066 // ---------------------------------------------------------------------------- |
|
2067 // CBrowserBookmarksView::AddNewBookmarkL |
|
2068 // ---------------------------------------------------------------------------- |
|
2069 // |
|
2070 void CBrowserBookmarksView::AddNewBookmarkL() |
|
2071 { |
|
2072 // Make an item and fill it with default values. |
|
2073 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
2074 item->SetType( CFavouritesItem::EItem ); |
|
2075 item->SetParentFolder( CurrentFolder() ); |
|
2076 item->SetUrlL( KHttpString ); |
|
2077 Model().SetNameToDefaultL( *item ); |
|
2078 TInt err = Model().MakeUniqueNameL( *item ); |
|
2079 if ( !err ) |
|
2080 { |
|
2081 // to prevent faded statuspane at the begining of dialog activation |
|
2082 CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, |
|
2083 CEikonEnv::Static()->EikAppUi() ) |
|
2084 ->StatusPane(); |
|
2085 sp->DrawNow(); |
|
2086 |
|
2087 // Dim Toolbar buttons |
|
2088 DimToolbarButtons(ETrue); |
|
2089 |
|
2090 // We have the item with a default unique name. Let the user edit it. |
|
2091 CBrowserBookmarkEditDialog* dialog = |
|
2092 CBrowserBookmarkEditDialog::NewL |
|
2093 ( |
|
2094 *item, |
|
2095 Model(), |
|
2096 //ApiProvider().CommsModel() |
|
2097 ApiProvider() |
|
2098 ); |
|
2099 dialog->ExecuteLD( R_BROWSER_BOOKMARKS_DIALOG_EDIT ); |
|
2100 |
|
2101 // Un-Dim Toolbar buttons |
|
2102 DimToolbarButtons(EFalse); |
|
2103 |
|
2104 // If the bookmark was added to the database, highlight it. |
|
2105 // Unlike in AddNewFolderL, adding the item to the database |
|
2106 // and setting highlight uid (next line of code) runs in the RunL |
|
2107 // method of different active objects. So the database notification |
|
2108 // may have came in or may not by now. |
|
2109 // This way of doing the highlight (setting a preferred and calling |
|
2110 // HighlightPreferred works in both cases. |
|
2111 iPreferredHighlightUid = item->Uid(); |
|
2112 // If not added, iPreferredHighlightUid is now KFavouritesNullUid, |
|
2113 // so the following does nothing. |
|
2114 if ( iPreferredHighlightUid != KFavouritesNullUid ) |
|
2115 { |
|
2116 // Highlight newly added item. |
|
2117 HighlightPreferredL(); |
|
2118 } |
|
2119 } |
|
2120 AddUidToLastPlaceToCurrentListL( item->Uid() ); |
|
2121 iRefresh = EFalse; |
|
2122 Model().Database().SetData( CurrentFolder() , *iCurrentOrder ); |
|
2123 CleanupStack::PopAndDestroy(); // item |
|
2124 } |
|
2125 |
|
2126 |
|
2127 // ---------------------------------------------------------------------------- |
|
2128 // CBrowserBookmarksView::AddUidToLastPlaceToCurrentListL |
|
2129 // ---------------------------------------------------------------------------- |
|
2130 // |
|
2131 void CBrowserBookmarksView::AddUidToLastPlaceToCurrentListL( TInt aUid ) |
|
2132 { |
|
2133 if ( iCurrentOrder ) |
|
2134 { |
|
2135 CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh); |
|
2136 CleanupStack::PushL( orderArray ); |
|
2137 |
|
2138 if (iCurrentOrder->GetBookMarksOrder().Count()) |
|
2139 { |
|
2140 orderArray->AppendL( &( iCurrentOrder->GetBookMarksOrder()[0] ), |
|
2141 iCurrentOrder->GetBookMarksOrder().Count()); |
|
2142 } |
|
2143 |
|
2144 Model().AddUidToLastPlaceL(aUid, orderArray, iCurrentOrder); |
|
2145 |
|
2146 iCurrentOrder->SetBookMarksOrderL( *orderArray ); |
|
2147 CleanupStack::PopAndDestroy( orderArray ); |
|
2148 } |
|
2149 } |
|
2150 |
|
2151 // ---------------------------------------------------------------------------- |
|
2152 // CBrowserBookmarks::EditCurrentBookmarkL |
|
2153 // ---------------------------------------------------------------------------- |
|
2154 // |
|
2155 void CBrowserBookmarksView::EditCurrentBookmarkL() |
|
2156 { |
|
2157 if ( Container() && Container()->Listbox() ) |
|
2158 { |
|
2159 const CFavouritesItem* listboxItem = |
|
2160 Container()->Listbox()->CurrentItem(); |
|
2161 if ( listboxItem && listboxItem->IsItem() ) |
|
2162 { |
|
2163 // to prevent faded statuspane at the begining of dialog activation |
|
2164 CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, |
|
2165 CEikonEnv::Static()->EikAppUi() ) |
|
2166 ->StatusPane(); |
|
2167 sp->DrawNow(); |
|
2168 |
|
2169 // Dim Toolbar buttons |
|
2170 DimToolbarButtons(ETrue); |
|
2171 |
|
2172 CFavouritesItem* item = CFavouritesItem::NewLC(); |
|
2173 *item = *listboxItem; |
|
2174 CBrowserBookmarkEditDialog* dialog = |
|
2175 CBrowserBookmarkEditDialog::NewL |
|
2176 ( |
|
2177 *item, |
|
2178 Model(), |
|
2179 ApiProvider(), |
|
2180 listboxItem->Uid() |
|
2181 ); |
|
2182 dialog->ExecuteLD( R_BROWSER_BOOKMARKS_DIALOG_EDIT ); |
|
2183 CleanupStack::PopAndDestroy(); // item |
|
2184 |
|
2185 // unDim Toolbar buttons |
|
2186 DimToolbarButtons(EFalse); |
|
2187 |
|
2188 iPreferredHighlightUid = item->Uid(); |
|
2189 |
|
2190 // Force a refresh of database changes. |
|
2191 iRefresh = ETrue; |
|
2192 } |
|
2193 } |
|
2194 } |
|
2195 |
|
2196 // ---------------------------------------------------------------------------- |
|
2197 // CBrowserBookmarksView::SendBookmarksL |
|
2198 // ---------------------------------------------------------------------------- |
|
2199 // |
|
2200 void CBrowserBookmarksView::SendBookmarksL( ) |
|
2201 { |
|
2202 CArrayPtr<const CFavouritesItem>* items = |
|
2203 Container()->Listbox()->SelectedItemsLC(); |
|
2204 |
|
2205 MBmOTABinSender& sender = ApiProvider().BmOTABinSenderL(); |
|
2206 |
|
2207 sender.ResetAndDestroy(); |
|
2208 |
|
2209 TBool result( ETrue ); |
|
2210 TInt index( 0 ); |
|
2211 TInt count( items->Count() ); |
|
2212 |
|
2213 #ifndef _BOOKMARK_SENT_ASCII |
|
2214 for ( index = 0; index < count; ++index ) |
|
2215 { |
|
2216 if ( ( *items )[ index ]->Url().Length() > KMaxUrlLenghtInOTA ) |
|
2217 { |
|
2218 #pragma message ( __FILE__ ": TODO: Length of bookmark address cannot exceed 255bytes!") |
|
2219 result = EFalse; |
|
2220 } |
|
2221 } |
|
2222 #endif // _BOOKMARK_SENT_ASCII |
|
2223 |
|
2224 if ( result ) |
|
2225 { |
|
2226 for ( index = 0; index < count; ++index ) |
|
2227 { |
|
2228 sender.AppendL( ( *items )[ index ]->Url(), |
|
2229 ( *items )[ index ]->Name() ); |
|
2230 } |
|
2231 } |
|
2232 |
|
2233 // to save memory |
|
2234 CleanupStack::PopAndDestroy(); // items; |
|
2235 |
|
2236 if ( result ) |
|
2237 { |
|
2238 sender.SendAddressL( ); |
|
2239 } |
|
2240 |
|
2241 Container()->Listbox()->ClearSelection(); |
|
2242 Container()->Listbox()->SetCurrentItemIndexAndDraw( 0 ); |
|
2243 } |
|
2244 |
|
2245 |
|
2246 // ---------------------------------------------------------------------------- |
|
2247 // CBrowserBookmarksView::TheContainer |
|
2248 // ---------------------------------------------------------------------------- |
|
2249 // |
|
2250 CBrowserBookmarksContainer* CBrowserBookmarksView::TheContainer() |
|
2251 { |
|
2252 return STATIC_CAST( CBrowserBookmarksContainer*, Container() ); |
|
2253 } |
|
2254 |
|
2255 // ---------------------------------------------------------------------------- |
|
2256 // CBrowserBookmarksView::ApChangedL |
|
2257 // ---------------------------------------------------------------------------- |
|
2258 // |
|
2259 void CBrowserBookmarksView::ApChangedL( TUint32 aNewAPId ) |
|
2260 { |
|
2261 if ( aNewAPId != iStartPageApUid ) |
|
2262 { |
|
2263 // New AP has been taken into use. Set Start Page to that. |
|
2264 iStartPageApUid = aNewAPId; |
|
2265 // Redraw view. Note that this does nothing if view is not activated. |
|
2266 RefreshL( EFalse ); |
|
2267 } |
|
2268 } |
|
2269 |
|
2270 // ---------------------------------------------------------------------------- |
|
2271 // CBrowserBookmarksView::HandlePreferencesChangeL |
|
2272 // ---------------------------------------------------------------------------- |
|
2273 // |
|
2274 void CBrowserBookmarksView::HandlePreferencesChangeL( |
|
2275 const TPreferencesEvent /*aEvent*/, |
|
2276 TPreferencesValues& /*aValues*/, |
|
2277 TBrCtlDefs::TBrCtlSettings /*aSettingType*/ ) |
|
2278 { |
|
2279 // adaptive bookmarks setting changed |
|
2280 if ( iAdaptiveBookmarksCurrentSetting != |
|
2281 ApiProvider().Preferences().AdaptiveBookmarks() ) |
|
2282 { |
|
2283 iAdaptiveBookmarksCurrentSetting = |
|
2284 ApiProvider().Preferences().AdaptiveBookmarks(); |
|
2285 |
|
2286 if ( iAdaptiveBookmarksCurrentSetting != |
|
2287 EWmlSettingsAdaptiveBookmarksOn ) |
|
2288 { |
|
2289 if ( iPreferredHighlightUid == KFavouritesAdaptiveItemsFolderUid ) |
|
2290 { |
|
2291 Container()->Listbox()->View()->SetCurrentItemIndex( 0 ); |
|
2292 } |
|
2293 |
|
2294 ExitAdaptiveBookmarks(); |
|
2295 |
|
2296 if ( iAdaptiveBookmarksCurrentSetting == |
|
2297 EWmlSettingsAdaptiveBookmarksOff ) |
|
2298 { |
|
2299 if ( TBrowserDialogs::ConfirmQueryYesNoL( |
|
2300 R_BROWSER_ADAPTIVE_BOOKMARKS_DELETE_ALL_ADAPTIVE_BOOKMARKS ) ) |
|
2301 { |
|
2302 iRecentUrlStore.ClearData(); |
|
2303 } |
|
2304 } |
|
2305 } |
|
2306 else |
|
2307 { |
|
2308 iInsertAdaptiveBookmarksFolder = ETrue; |
|
2309 iSaveBMOrder = ETrue; |
|
2310 } |
|
2311 } |
|
2312 |
|
2313 TUint32 defaultAp = ApiProvider().Preferences().DefaultAccessPoint(); |
|
2314 |
|
2315 if ( defaultAp != iCurrentDefaultAp ) |
|
2316 { |
|
2317 // Default AP changed. Set Start Page bookmark to that. |
|
2318 iCurrentDefaultAp = iStartPageApUid = defaultAp; |
|
2319 // Redraw view. Note that this does nothing if view is not activated. |
|
2320 RefreshL( EFalse ); |
|
2321 } |
|
2322 |
|
2323 iPreferencesChanged=ETrue; |
|
2324 } |
|
2325 |
|
2326 // ---------------------------------------------------------------------------- |
|
2327 // CBrowserBookmarksView::CreateStartPageBookmarkL |
|
2328 // ---------------------------------------------------------------------------- |
|
2329 // |
|
2330 CFavouritesItem* CBrowserBookmarksView::CreateStartPageBookmarkL() |
|
2331 { |
|
2332 LOG_ENTERFN("CBrowserBookmarksView::CreateStartPageBookmarkL"); |
|
2333 // no HomePage if Type is Bookmarks |
|
2334 // or 'Always ask' feature is selected |
|
2335 TWmlSettingsHomePage pgtype = ApiProvider().Preferences().HomePageType(); |
|
2336 TBool accessPointSelectionMode( |
|
2337 (ApiProvider().Preferences().AccessPointSelectionMode() == EAlwaysAsk) && |
|
2338 ( EWmlSettingsHomePageAccessPoint == pgtype ) ); |
|
2339 LOG_WRITE_FORMAT(" pgType: %d", pgtype ); |
|
2340 LOG_WRITE_FORMAT(" selection mode: %d", accessPointSelectionMode ); |
|
2341 if ( accessPointSelectionMode || (pgtype == EWmlSettingsHomePageBookmarks) ) |
|
2342 { |
|
2343 return NULL; |
|
2344 } |
|
2345 |
|
2346 CFavouritesItem* startPage = NULL; |
|
2347 TUint defaultAp = ApiProvider().Preferences().DefaultAccessPoint(); |
|
2348 LOG_WRITE_FORMAT(" defaultAp: %d", defaultAp ); |
|
2349 if ( defaultAp != KWmlNoDefaultAccessPoint ) // There is an access point defined |
|
2350 { |
|
2351 // Get pointer to Start Page AP (or NULL if no such); |
|
2352 /* |
|
2353 Modified by MOG |
|
2354 --------------------- Performance Changes ---------------------- |
|
2355 remove dependency from CommsModel becasue the cached list may not be pre |
|
2356 CApListItem* apItem = |
|
2357 ApiProvider().CommsModel().AccessPoints()->ItemForUid( defaultAp ); |
|
2358 ---------------------- Performance Changes ---------------------- |
|
2359 */ |
|
2360 CApAccessPointItem* apItem = iApiProvider.Preferences().AllPreferencesL().iDefaultAPDetails; |
|
2361 if ( apItem ) |
|
2362 { |
|
2363 const HBufC* defaultHP = apItem->ReadConstLongTextL( EApWapStartPage ); |
|
2364 if ( defaultHP->Length() ) |
|
2365 { |
|
2366 // Have AP and the AP has Start Page address. Hurray. |
|
2367 startPage = Model().Database().CreateStartPageItemL(); |
|
2368 CleanupStack::PushL( startPage ); |
|
2369 TBuf<KFavouritesMaxName> name; |
|
2370 apItem->ReadTextL(EApWapAccessPointName, name); |
|
2371 startPage->SetNameL( name ); |
|
2372 startPage->SetUrlL( *defaultHP ); |
|
2373 TFavouritesWapAp ap; |
|
2374 ap.SetApId( defaultAp ); |
|
2375 startPage->SetWapAp( ap ); |
|
2376 CleanupStack::Pop(); // startPage: owner is the caller. |
|
2377 } |
|
2378 } |
|
2379 } |
|
2380 //LOG_LEAVEFN("CBrowserBookmarksView::CreateStartPageBookmarkL"); |
|
2381 return startPage; |
|
2382 } |
|
2383 |
|
2384 // ---------------------------------------------------------------------------- |
|
2385 // CBrowserBookmarksView::OfferKeyEventL |
|
2386 // ---------------------------------------------------------------------------- |
|
2387 // |
|
2388 TKeyResponse CBrowserBookmarksView::OfferKeyEventL( |
|
2389 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
2390 { |
|
2391 // This method is called back from the container, to process the keypresses |
|
2392 // that cannot be handled by the container. Those are (currently) the |
|
2393 // left/right arrow keypresses, since the container does not know anything |
|
2394 // about what folder is open, which knowledge is required to process |
|
2395 // arrow presses. So we do that here. |
|
2396 // Any other key processing is still in the container. |
|
2397 TKeyResponse result = EKeyWasNotConsumed; |
|
2398 switch ( aKeyEvent.iCode ) |
|
2399 { |
|
2400 |
|
2401 case EKeyLeftArrow: // West |
|
2402 { |
|
2403 if ( ( CurrentFolder() != KFavouritesRootUid ) || ( iInAdaptiveBookmarksFolder ) ) |
|
2404 { |
|
2405 // We are in some folder. Move between subfolders in the leftwards direction. |
|
2406 if ( !ApiProvider().IsEmbeddedModeOn() && !iManualItemMovingGoingOn ) |
|
2407 { |
|
2408 OpenNextFolderL( /*aForward=*/EFalse ); |
|
2409 } |
|
2410 result = EKeyWasConsumed; |
|
2411 } |
|
2412 break; |
|
2413 } |
|
2414 |
|
2415 case EKeyRightArrow: // East |
|
2416 { |
|
2417 if ( ( CurrentFolder() != KFavouritesRootUid ) || ( iInAdaptiveBookmarksFolder ) ) |
|
2418 { |
|
2419 // We are in some folder. Move between subfolders in the rightwards direction. |
|
2420 if ( !ApiProvider().IsEmbeddedModeOn() && !iManualItemMovingGoingOn ) |
|
2421 { |
|
2422 OpenNextFolderL( /*aForward=*/ETrue ); |
|
2423 } |
|
2424 result = EKeyWasConsumed; |
|
2425 } |
|
2426 break; |
|
2427 } |
|
2428 |
|
2429 case EKeyRightUpArrow: // Northeast |
|
2430 case EStdKeyDevice11: // : Extra KeyEvent supports diagonal event simulator wedge |
|
2431 case EKeyRightDownArrow: // Southeast |
|
2432 case EStdKeyDevice12: // : Extra KeyEvent supports diagonal event simulator wedge |
|
2433 case EKeyLeftDownArrow: // Southwest |
|
2434 case EStdKeyDevice13: // : Extra KeyEvent supports diagonal event simulator wedge |
|
2435 case EKeyLeftUpArrow: // Northwest |
|
2436 case EStdKeyDevice10: // : Extra KeyEvent supports diagonal event simulator wedge |
|
2437 { // Here, "eat" all of the diagonals so they have no effect |
|
2438 result = EKeyWasConsumed; |
|
2439 break; |
|
2440 } |
|
2441 |
|
2442 case EKeyBackspace: |
|
2443 case EKeyDelete: |
|
2444 { |
|
2445 TBrowserFavouritesSelectionState state = |
|
2446 iContainer->Listbox()->SelectionStateL(); |
|
2447 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
2448 |
|
2449 if ( ( state.AnyDeletable() ) && |
|
2450 // We can't delete adaptive bookmarks folder or seamless folders' |
|
2451 ( item ) && |
|
2452 ( item->Uid() != KFavouritesAdaptiveItemsFolderUid ) && |
|
2453 ( item->ContextId() == NULL ) |
|
2454 ) |
|
2455 { |
|
2456 // Clear key deletes the selection (or highlighted items). |
|
2457 if (iInAdaptiveBookmarksFolder) |
|
2458 { |
|
2459 HandleCommandL(EWmlCmdDelete); |
|
2460 result = EKeyWasConsumed; |
|
2461 } |
|
2462 else if (iManualItemMovingGoingOn) |
|
2463 // Manual Move in progress -- disable delete key |
|
2464 { |
|
2465 result = EKeyWasConsumed; |
|
2466 } |
|
2467 else |
|
2468 { |
|
2469 result =CBrowserFavouritesView::OfferKeyEventL(aKeyEvent,aType); |
|
2470 } |
|
2471 |
|
2472 } |
|
2473 break; |
|
2474 } |
|
2475 |
|
2476 case EKeyOK: |
|
2477 // OK key is handled through MSK handling |
|
2478 result = EKeyWasConsumed; |
|
2479 break; |
|
2480 |
|
2481 case EKeyEnter: |
|
2482 { |
|
2483 if ( iManualItemMovingGoingOn ) |
|
2484 { |
|
2485 MoveItemsL(); |
|
2486 result = EKeyWasConsumed; |
|
2487 } |
|
2488 else |
|
2489 { |
|
2490 result = CBrowserFavouritesView::OfferKeyEventL(aKeyEvent,aType); |
|
2491 } |
|
2492 break; |
|
2493 } |
|
2494 |
|
2495 default: |
|
2496 { |
|
2497 result =CBrowserFavouritesView::OfferKeyEventL(aKeyEvent,aType); |
|
2498 break; |
|
2499 } |
|
2500 } |
|
2501 |
|
2502 return result; |
|
2503 } |
|
2504 |
|
2505 // ---------------------------------------------------------------------------- |
|
2506 // CBrowserBookmarksView::OpenNextFolderL |
|
2507 // ---------------------------------------------------------------------------- |
|
2508 // |
|
2509 void CBrowserBookmarksView::OpenNextFolderL( TBool aForward ) |
|
2510 { |
|
2511 if ( !Model().BeginL( EFalse, ETrue ) ) |
|
2512 { |
|
2513 TInt nextFolder; |
|
2514 if ( iInAdaptiveBookmarksFolder ) |
|
2515 { |
|
2516 // If in domain then forget about it |
|
2517 if (iDomainFolderName) |
|
2518 { |
|
2519 delete iDomainFolderName; |
|
2520 iDomainFolderName = NULL; |
|
2521 } |
|
2522 |
|
2523 nextFolder = Model().NextFolderL( KFavouritesAdaptiveItemsFolderUid, |
|
2524 aForward ); |
|
2525 if ( nextFolder != KFavouritesNullUid ) |
|
2526 { |
|
2527 iInAdaptiveBookmarksFolder = EFalse; |
|
2528 } |
|
2529 } |
|
2530 else |
|
2531 { |
|
2532 nextFolder = Model().NextFolderL( CurrentFolder(), aForward ); |
|
2533 } |
|
2534 |
|
2535 if ( nextFolder != KFavouritesNullUid ) |
|
2536 { |
|
2537 if ( nextFolder != KFavouritesAdaptiveItemsFolderUid ) |
|
2538 { |
|
2539 SetEmptyTextL(); |
|
2540 OpenFolderL( nextFolder ); |
|
2541 } |
|
2542 } |
|
2543 Model().CommitL(); |
|
2544 if ( nextFolder == KFavouritesAdaptiveItemsFolderUid ) |
|
2545 { |
|
2546 iInAdaptiveBookmarksFolder=ETrue; |
|
2547 SetEmptyTextL(); |
|
2548 SetRootFolderForAdaptiveBookmarks(); |
|
2549 SetEmptyTextL(); |
|
2550 RefreshL(); |
|
2551 } |
|
2552 } |
|
2553 // Changing folder may require change in toolbar button state |
|
2554 UpdateToolbarButtonsState(); |
|
2555 } |
|
2556 |
|
2557 // ---------------------------------------------------------------------------- |
|
2558 // CBrowserBookmarksView::UpdateNaviPaneL |
|
2559 // ---------------------------------------------------------------------------- |
|
2560 // |
|
2561 void CBrowserBookmarksView::UpdateNaviPaneL() |
|
2562 { |
|
2563 if (iInAdaptiveBookmarksFolder) |
|
2564 { |
|
2565 // In other folder, show "1/4" style text. |
|
2566 TInt folderIndex; |
|
2567 TInt folderCount; |
|
2568 TInt err; |
|
2569 err = Model().FolderInfoL( KFavouritesAdaptiveItemsFolderUid, |
|
2570 folderCount, folderIndex ); |
|
2571 if ( !err ) |
|
2572 { |
|
2573 TheContainer()->ShowFolderNaviPaneL( folderIndex, folderCount ); |
|
2574 } |
|
2575 } |
|
2576 else |
|
2577 { |
|
2578 CBrowserFavouritesView::UpdateNaviPaneL(); |
|
2579 } |
|
2580 } |
|
2581 |
|
2582 // --------------------------------------------------------------------------- |
|
2583 // CBrowserBookmarksView::HandleBrowserLoadEventL |
|
2584 // --------------------------------------------------------------------------- |
|
2585 // |
|
2586 void CBrowserBookmarksView::HandleBrowserLoadEventL( |
|
2587 TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, |
|
2588 TUint /* aSize */, |
|
2589 TUint16 aTransactionId ) |
|
2590 { |
|
2591 LOG_ENTERFN("BookmarksView::HandleBrowserLoadEventL"); |
|
2592 // only GotoPane is interested in LoadEvents! |
|
2593 if ( Container() ) |
|
2594 { |
|
2595 if ( aLoadEvent != TBrCtlDefs::EEventThumbnailAvailable) |
|
2596 { |
|
2597 // If in bookmarks view, a background page load is in |
|
2598 // progress, just update the soft keys when page load is finished. |
|
2599 // (ie. RSK would be "Stop" while page loading but change to "Exit" |
|
2600 // when page load finished) |
|
2601 if ( aLoadEvent == TBrCtlDefs::EEventLoadFinished ) |
|
2602 { |
|
2603 UpdateCbaL(); |
|
2604 } |
|
2605 } |
|
2606 // save transaction id |
|
2607 if ( aLoadEvent == TBrCtlDefs::EEventUrlLoadingStart && iTrId == 0 ) |
|
2608 { |
|
2609 iTrId = aTransactionId; |
|
2610 } |
|
2611 // first content chunk arrived |
|
2612 else if ( aLoadEvent == TBrCtlDefs::EEventNewUrlContentArrived && |
|
2613 iTrId == aTransactionId ) |
|
2614 { |
|
2615 if ( iEnteredURL ) |
|
2616 { |
|
2617 delete iEnteredURL; |
|
2618 iEnteredURL = NULL; |
|
2619 BROWSER_LOG( ( _L("delete iEnteredUrl 5") ) ); |
|
2620 } |
|
2621 iCursorPos = -1; |
|
2622 } |
|
2623 } |
|
2624 } |
|
2625 |
|
2626 |
|
2627 // --------------------------------------------------------------------------- |
|
2628 // CBrowserBookmarksView::ClearAdaptiveBookmarksL |
|
2629 // --------------------------------------------------------------------------- |
|
2630 // |
|
2631 void CBrowserBookmarksView::ClearAdaptiveBookmarksL() |
|
2632 { |
|
2633 iRecentUrlStore.ClearData(); |
|
2634 Container()->Listbox()->View()->ClearSelection(); |
|
2635 RefreshL(); |
|
2636 } |
|
2637 |
|
2638 // --------------------------------------------------------------------------- |
|
2639 // CBrowserBookmarksView::UpdateToolbarButtonsState |
|
2640 // --------------------------------------------------------------------------- |
|
2641 // |
|
2642 void CBrowserBookmarksView::UpdateToolbarButtonsState() |
|
2643 { |
|
2644 if ( Container() && Container()->Listbox() ) |
|
2645 { |
|
2646 const CFavouritesItem* item = Container()->Listbox()->CurrentItem(); |
|
2647 |
|
2648 // Button: EWmlCmdDelete |
|
2649 // Default case: un-dim the delete Button |
|
2650 // Case: Not an item so dim delete button |
|
2651 // Special Case: dim button for adaptive folder and |
|
2652 // seamless links |
|
2653 TBrowserFavouritesSelectionState state = iContainer->Listbox()->SelectionStateL(); |
|
2654 |
|
2655 TBool needToDimDeleteBtn = !item |
|
2656 || ( item->Uid() == KFavouritesAdaptiveItemsFolderUid ) |
|
2657 || ( item->ContextId() != NULL ) |
|
2658 || (!state.AnyDeletable()); |
|
2659 |
|
2660 Toolbar()->SetItemDimmed( EWmlCmdDelete, needToDimDeleteBtn, ETrue ); |
|
2661 } |
|
2662 } |
|
2663 // End of File |