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