browserui/browser/FavouritesInc/BrowserBookmarksView.h
branchRCL_3
changeset 65 8e6fa1719340
equal deleted inserted replaced
64:6385c4c93049 65:8e6fa1719340
       
     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: 
       
    15 *      Declaration of class CBrowserBookmarksView.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef BROWSER_BOOKMARKS_VIEW_H
       
    22 #define BROWSER_BOOKMARKS_VIEW_H
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include "BrowserFavouritesView.h"
       
    26 #include "BrowserBookmarksGotoPane.h"
       
    27 #include "Preferences.h"
       
    28 #include <apchangeobserver.h>
       
    29 #include <brctlinterface.h>
       
    30 #include <AknToolbarObserver.h>
       
    31 
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 //FORWARD DECLARATION
       
    36 
       
    37 class CBrowserBookmarksContainer;
       
    38 class CRecentUrlStore;
       
    39 class CAsyncDownloadsListExecuter;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44 * Bookmarks View of the WML browser. Derived from CBrowserFavouritesView;
       
    45 * new methods mostly process Bookmark View specific commands.
       
    46 */
       
    47 class CBrowserBookmarksView:
       
    48                             public CBrowserFavouritesView, 
       
    49                             public MBookmarksGotoPaneObserver,
       
    50                             public MApChangeObserver,
       
    51                             public MPreferencesObserver,
       
    52                             public MBrCtlLoadEventObserver,
       
    53                             public MAknToolbarObserver
       
    54 	{
       
    55 	public:     // construction
       
    56 
       
    57         /**
       
    58         * Two-phased constructor. Leaves on failure.
       
    59         * @param aApiProvider The API provider.
       
    60         * @return The constructed view.
       
    61         */
       
    62         static CBrowserBookmarksView* NewLC( MApiProvider& aApiProvider,  CRecentUrlStore& aRecentUrlStore, TInt aInitialFolderUid = KFavouritesRootUid);
       
    63 
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         virtual ~CBrowserBookmarksView();
       
    68 
       
    69     public:     // new methods
       
    70 
       
    71         /**
       
    72         * Force updating the Goto Pane. Does nothing if Goto Pane is not
       
    73         * visible.
       
    74 		* @since 1.2
       
    75         */
       
    76         void UpdateGotoPaneL();
       
    77         
       
    78         /**
       
    79         * Exits Adaptive Bookmarks folder. Called also from BrowserAppUi when a page is
       
    80         * downloaded from Adaptive Bookmarks.
       
    81 		* @since 2.1
       
    82         */
       
    83         void ExitAdaptiveBookmarks();
       
    84 
       
    85         /**
       
    86         * Opens Adaptive Bookmarks folder.
       
    87 		* @since 3.1
       
    88         */
       
    89         inline void OpenAdaptiveBookmarksWhenActivated( )
       
    90         	{ iOpenAdaptiveBookmarksWhenActivated = ETrue; }
       
    91 
       
    92         /**
       
    93         * Gets the status of selection of the adaptive bookmarks folder.
       
    94 		* @since 3.1
       
    95         */
       
    96         inline TBool GetAdaptiveBookmarksFolderSelected( )
       
    97         	{ return iAdaptiveBookmarksFolderSelected; }
       
    98 
       
    99         inline TBool GetAdaptiveBookmarksFolderWasActive( )
       
   100         	{ return iAdaptiveBookmarksFolderWasActive; }
       
   101         	
       
   102         void DimToolbarButtons(TBool aDimButtons);
       
   103 
       
   104 	public:     // public methods from CBrowserFavouritesView
       
   105 
       
   106         /**
       
   107         * Handle command.
       
   108 		* @since 1.2
       
   109         * @param aCommand Command id.
       
   110         */
       
   111 		void HandleCommandL( TInt aCommand );
       
   112 
       
   113         /**
       
   114         * Get view id.
       
   115 		* @since 1.2
       
   116         * @return The view id for this view.
       
   117         */
       
   118 		TUid Id() const;
       
   119 
       
   120 	public:     // From MCbaSetter (CBrowserViewBase)
       
   121         
       
   122         /**
       
   123         * Return command set id, to be displayed.
       
   124 		* @since 1.2
       
   125         * @return The command set's resource id.
       
   126         */
       
   127         virtual TInt CommandSetResourceIdL();
       
   128         
       
   129 		/**
       
   130 		* Set command set lsk,rsk,msk dynamically via pointers.
       
   131 		* Derived classes should implement, though it can be empty.
       
   132 		* If it does nothing, empty softkeys will be assigned
       
   133 		* @since 5.0
       
   134 		*/
       
   135 		void CommandSetResourceDynL(TSKPair& /*lsk*/, TSKPair& /*rsk*/, TSKPair& /*msk*/);
       
   136 
       
   137 		/**
       
   138 		* Helper function to dynamically set LSK
       
   139 		* @since 5.0
       
   140 		*/
       
   141 		void SetLSKDynL(TSKPair& aLsk,
       
   142 			CBrowserBookmarksGotoPane* aTheGotoPane);
       
   143 
       
   144 		/**
       
   145 		* Helper function to dynamically set RSK
       
   146 		* @since 5.0
       
   147 		*/
       
   148 		void SetRSKDynL(TSKPair& aRsk,
       
   149 			CBrowserBookmarksGotoPane* aTheGotoPane);
       
   150 
       
   151 		/**
       
   152 		* Helper function to dynamically set MSK
       
   153 		* @since 5.0
       
   154 		*/
       
   155 		void SetMSKDynL(TSKPair& aMsk, const TSKPair aLsk,
       
   156 			CBrowserFavouritesContainer* aTheContainer,
       
   157 			CBrowserBookmarksGotoPane* aTheGotoPane);
       
   158         
       
   159 
       
   160     public:     // from MBookmarksGotoPaneObserver
       
   161 
       
   162         /**
       
   163         * Handle Goto Pane event.
       
   164 		* @since 1.2
       
   165         * @param aGotoPane The Goto Pane in which the event occurred.
       
   166         * @param aEvent Goto Pane event.
       
   167         */
       
   168         virtual void HandleBookmarksGotoPaneEventL
       
   169             (
       
   170             CBrowserBookmarksGotoPane* aGotoPane,
       
   171             MBookmarksGotoPaneObserver::TEvent aEvent
       
   172             );
       
   173 
       
   174     public: // MAknToolbarObserver
       
   175         /**
       
   176         * Called when toolbar events occur
       
   177         *
       
   178         * @since 5.0
       
   179         * @return void
       
   180         */
       
   181         void OfferToolbarEventL( TInt aCommand ) { HandleCommandL(aCommand); }
       
   182 
       
   183 	protected:  // construction
       
   184 
       
   185         /**
       
   186         * Constructor.
       
   187         * @param aApiProvider The API provider.
       
   188         */
       
   189         CBrowserBookmarksView( MApiProvider& aApiProvider, CRecentUrlStore& aRecentUrlStore, TInt aInitialFolderUid = KFavouritesRootUid );
       
   190 
       
   191         /**
       
   192         * Second phase constructor. Leaves on failure.
       
   193         * @param aViewResourceId Resource id for this view.
       
   194         * Derived classes should call this first during construction.
       
   195         */
       
   196 		void ConstructL( TInt aViewResourceId );
       
   197 
       
   198 	protected:	// protected CBrowserFavouritesView
       
   199 
       
   200         /**
       
   201         * Handle listbox event.
       
   202 		* @since 1.2
       
   203         * @param aListBox Listbox in which the event occurred.
       
   204         * @param aEventType Event.
       
   205         */
       
   206         void HandleListBoxEventL(
       
   207             CEikListBox* aListBox,
       
   208             MEikListBoxObserver::TListBoxEvent aEventType );
       
   209 
       
   210         /**
       
   211         * Initialize context-sensitive menu.
       
   212 		* @since 1.2
       
   213         * @param aResourceId Resource id of the menu pane.
       
   214         * @param aMenuPane Menu pane object being initialized.
       
   215         * @param aIndex Index into the visibility map.
       
   216         * @param aState Selection state.
       
   217         */
       
   218         virtual void DynInitMenuPaneL
       
   219                 (
       
   220                 TInt aResourceId,
       
   221                 CEikMenuPane* aMenuPane,
       
   222                 TCommandVisibility::TIndex /*aIndex*/,
       
   223                 const TBrowserFavouritesSelectionState& aState
       
   224                 );
       
   225 
       
   226         /**
       
   227         * Get resource id of text to be displayed in navi pane when
       
   228         * root folder is shown (TBUF).
       
   229 		* @since 1.2
       
   230         * @return Resource id.
       
   231         */
       
   232         TInt RootTitleResourceId() const;
       
   233 
       
   234         /**
       
   235         * Get resource id of Options menu (RESOURCE MENU_BAR).
       
   236 		* @since 1.2
       
   237         * @return Resource id.
       
   238         */
       
   239         TInt OptionsMenuResourceId() const;
       
   240 
       
   241         /**
       
   242         * Get resource id of OK-Options menu (RESOURCE MENU_BAR).
       
   243 		* @since 1.2
       
   244         * @return Resource id.
       
   245         */
       
   246         TInt OkOptionsMenuResourceId() const;
       
   247 
       
   248         /**
       
   249         * Create the model. Leave on failure. The model is owned by the
       
   250         * caller (this view, base class). The created model is really
       
   251         * a CBrowserBokmarksModel.
       
   252 		* @since 1.2
       
   253         * @return The constructed model.
       
   254         */
       
   255         virtual CBrowserFavouritesModel* CreateModelL();
       
   256 
       
   257         /**
       
   258         * Create the container (the main control of the view). The container
       
   259         * is owned by the caller (this view, base class). The created container
       
   260         * is really a CBrowserBookmarksContainer.
       
   261         * Leave on failure.
       
   262 		* @since 1.2
       
   263         * @return The constructed main control.
       
   264         */
       
   265         virtual CBrowserFavouritesContainer* CreateContainerL();
       
   266 
       
   267         /**
       
   268         * Get items to be displayed in a folder. Expects the model's db be
       
   269         * open.
       
   270 		* @since 1.2
       
   271         * @param aFolder Folder which contains the items.
       
   272         * @return List of items. Pushed on the cleanup stack.
       
   273         */
       
   274         virtual CFavouritesItemList* GetItemsLC( TInt aFolder );
       
   275 
       
   276         /**
       
   277         * Some displayed data has changed (Favourites database, AP-s, etc).
       
   278         * Update the view so changes become visible. Safe to call if the view
       
   279         * is not active; in this case it does nothing.
       
   280         * This method should not be called if the data change is due to direct
       
   281         * user activity (opening folders etc.); only for notification
       
   282         * processing.
       
   283         * (Same as base class method, except active Goto Pane is not reset if
       
   284         * downloading is in progress.)
       
   285 		* @since 1.2
       
   286         * @param aDbErrorNote If ETrue, unsuccesful database access will bring
       
   287         * up an error note.
       
   288         */
       
   289         virtual void RefreshL( TBool aDbErrorNote = EFalse );
       
   290         
       
   291         void HandleForegroundEventL( TBool aForeground );
       
   292 
       
   293 	protected:	// protected methods from CAknView
       
   294 
       
   295         /**
       
   296         * Activate the view.
       
   297 		* @since 1.2
       
   298         * @param aCustomMessageId Custom Message Id.
       
   299         * @param aCustomMessage Custom Message.
       
   300         */
       
   301         virtual void DoActivateL
       
   302             (
       
   303             const TVwsViewId& aPrevViewId,
       
   304             TUid aCustomMessageId,
       
   305             const TDesC8& aCustomMessage
       
   306             );
       
   307 
       
   308         /**
       
   309         * Deactivate the view.
       
   310 		* @since 1.2
       
   311         */
       
   312         virtual void DoDeactivate();
       
   313 
       
   314     private:    // command handling (additional commands)
       
   315 
       
   316         /**
       
   317         * Available only to process EWmlCmdDelete and EWmlCmdDeleteItems commands.Command "Go to" when the user is editing in the Goto Pane.
       
   318         */
       
   319         void DeleteItems( TInt aCommand );
       
   320 
       
   321         /**
       
   322         * Command "Go to" when the user is editing in the Goto Pane.
       
   323         * Go to the URL found in Goto Pane.
       
   324         * Does nothing if no Goto Pane.
       
   325         */
       
   326         void GotoUrlInGotoPaneL();
       
   327 
       
   328         /**
       
   329         * Command "Activate". Activate highlighted bookmark.
       
   330         * Does nothing if no bookmark is highlighted.
       
   331         */
       
   332         void ActivateCurrentBookmarkL();
       
   333 
       
   334         /**
       
   335         * Command "Add bookmark". Create new bookmark and launch
       
   336         * Edit bookmark dialog.
       
   337         */
       
   338         void AddNewBookmarkL();
       
   339 
       
   340         /**
       
   341         * Command "Edit bookmark". Edit highlighted bookmark.
       
   342         * Does nothing if no bookmark is highlighted.
       
   343         */
       
   344         void EditCurrentBookmarkL();
       
   345 
       
   346 
       
   347         /**
       
   348         * Command "Send via Unified Messaging".
       
   349         * Send selected bookmark(s).
       
   350         */
       
   351         void SendBookmarksL( );
       
   352 
       
   353 
       
   354     private:    // new methods
       
   355 
       
   356         /**
       
   357         * Get the container (as CBrowserBookmarksContainer).
       
   358         * @return The container.
       
   359         */
       
   360         CBrowserBookmarksContainer* TheContainer();
       
   361 
       
   362     private:    // from MApChangeObserver
       
   363         /**
       
   364         * Handle change in currently used Access Point.
       
   365         */
       
   366         void ApChangedL( TUint32 aNewAPId );
       
   367 
       
   368     private:    // from MPreferencesObserver
       
   369 
       
   370         /**
       
   371         * Handle preferences change.
       
   372         */
       
   373         void HandlePreferencesChangeL( 
       
   374                                     const TPreferencesEvent aEvent,            
       
   375                                     TPreferencesValues& aValues,
       
   376                                     TBrCtlDefs::TBrCtlSettings aSettingType );
       
   377 
       
   378     private:
       
   379 
       
   380         /**
       
   381         * Create Start Page bookmark. Db needs not be open (not used).
       
   382         * @return The Start Page bookmark, or NULL if no such.
       
   383         * Ownership passed to caller.
       
   384         */
       
   385         CFavouritesItem* CreateStartPageBookmarkL();
       
   386 
       
   387     private:    // from MBrCtlLoadEventObserver
       
   388 
       
   389         /**
       
   390         * A load events notification
       
   391         * @since 2.8
       
   392         * @param aLoadEvent The load event
       
   393         * @param aSize Size depends on the event
       
   394         * @param aTransactionId The transaction id of the transaction that had this event
       
   395         * @return void
       
   396         */
       
   397         void HandleBrowserLoadEventL( TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,
       
   398                                       TUint aSize,
       
   399                                       TUint16 aTransactionId );
       
   400     private:
       
   401 
       
   402         /**
       
   403         * Clear all adaptive bookmarks
       
   404         */
       
   405         void ClearAdaptiveBookmarksL();
       
   406 
       
   407     private:
       
   408 
       
   409         /**
       
   410         * To set empty text for folders. It is different in Adaptive Bookmarks
       
   411         */
       
   412 		void SetEmptyTextL();
       
   413 
       
   414 	    // from CBrowserFavouritesView
       
   415         TKeyResponse OfferKeyEventL
       
   416             ( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   417 
       
   418 //from CBrowserFavouritesView
       
   419         /**
       
   420         * Open next folder.
       
   421         * @param aForward Open next folder if ETrue, previous if EFalse.
       
   422         */
       
   423 		void OpenNextFolderL( TBool aForward );
       
   424 
       
   425         /**
       
   426         * Update and draw navi pane (show tabs for root, or "1/4" style text
       
   427         * for subfolders).
       
   428         * No sanity check; expects the model's table be open.
       
   429         */
       
   430         void UpdateNaviPaneL();
       
   431 
       
   432         /**
       
   433         * Sorts bookmark items into the saved manual order
       
   434         * associated to the given folder
       
   435         * @param aFolder The folder in which the items are stored
       
   436         * @param aItems The bookmark item list to sort
       
   437         */
       
   438         TBool ManualBMSortL( TInt aFolder, CFavouritesItemList* aItems );
       
   439 
       
   440         /**
       
   441         * Starts 'item moving mode', when softkeys are ok/cancel
       
   442         * and ok moves the selected items to the current position in 
       
   443         * bookmarks list
       
   444         */
       
   445         void StartMoveItemsL();
       
   446 
       
   447         /**
       
   448         * moves the selected items to the current position in 
       
   449         * bookmarks list
       
   450         */
       
   451         void MoveItemsL();
       
   452 
       
   453         /**
       
   454         * Cancels 'item moving mode', softkeys return to normal,
       
   455         * focus returns to the first selected item
       
   456         */
       
   457         void CancelMoveItemsL();
       
   458 
       
   459         /*
       
   460         * Adds the given uid to the last place in bookmarks list
       
   461         * @param aUid The uid to add
       
   462         */
       
   463         void AddUidToLastPlaceToCurrentListL( TInt aUid );
       
   464 
       
   465     public:
       
   466         /**
       
   467         * Dim or Un-dim Toolbar buttons.
       
   468         */
       
   469         void UpdateToolbarButtonsState();
       
   470         
       
   471         /**
       
   472         * Check to show downloads.
       
   473         */
       
   474         void CheckForDownloads();
       
   475 
       
   476         /**
       
   477         * Initiates update for favicons
       
   478         */
       
   479         void UpdateFavIconsL();
       
   480 
       
   481     private:    // data
       
   482         /**
       
   483          * Callback for completing the Browser App init. Normally only
       
   484          * BookmarksView is initialized first on startup. When bookmarks
       
   485          * view is shown then this callback is scheduled to complete the
       
   486          * remaining initialization. 
       
   487          */
       
   488         static TInt CompleteAppInitCallback( TAny* aApiProvider );        
       
   489         
       
   490         /**
       
   491         * Uid of AP which is to be used for creating Start Page bookmark.
       
   492         */
       
   493         TUint32 iStartPageApUid;
       
   494 
       
   495         /**
       
   496         * Storing current default AP, to be able to spot when it changes.
       
   497         * (We get notification when preferences change; but don't know
       
   498         * what changed in preferences. We are interested only in default AP
       
   499         * change.)
       
   500         */
       
   501         TUint32 iCurrentDefaultAp;
       
   502 
       
   503         /**
       
   504         * This flag is used in fetch observing: this differentiates events from
       
   505         * the newly started fetch from events of ongoing fetches (being
       
   506         * cancelled by the new one). It is ETrue when new fetch has been
       
   507         * initiated but not yet started (existing fetches will be cancelled
       
   508         * during this time).
       
   509         */
       
   510         TBool iFetchInit;
       
   511 
       
   512 		HBufC* iDomainFolderName;
       
   513 		CRecentUrlStore& iRecentUrlStore;
       
   514 		TBool iInAdaptiveBookmarksFolder;
       
   515 
       
   516 		TWmlSettingsAdaptiveBookmarks iAdaptiveBookmarksCurrentSetting;
       
   517 
       
   518 
       
   519 		// For Adaptive Bookmarks - to refresh title when 
       
   520 		// coming back from Preferences
       
   521 		TBool iPreferencesChanged;
       
   522 
       
   523         // For Manual BM Sorting
       
   524         // Indicates item moving mode
       
   525         TBool iManualItemMovingGoingOn;
       
   526 
       
   527         // list of uids of items to move
       
   528         CArrayFixFlat<TInt>* iItemsToMove;
       
   529 
       
   530         // Current order of bookmarks
       
   531         CBrowserBookmarksOrder* iCurrentOrder;
       
   532 
       
   533         // Flag to indicate that Adaptive BM folder has just been inserted to BM list
       
   534         TBool iInsertAdaptiveBookmarksFolder;
       
   535 
       
   536         // Flag to indicate that current BM order needs to be saved
       
   537         TBool iSaveBMOrder;
       
   538 
       
   539         // Flag to indicate the presence of Start Page item
       
   540         TBool iStartPagePresent;
       
   541 
       
   542         // Goto Pane's entered URL and cursor's position
       
   543         HBufC* iEnteredURL;
       
   544         TInt iCursorPos;
       
   545 
       
   546         TUint16 iTrId;
       
   547         
       
   548         CAsyncDownloadsListExecuter* iDownloadsListExecuter; // Owned.
       
   549         
       
   550         // True if the view will show the adaptive bookmarks folder
       
   551         // on activation, otherwise false.
       
   552         TBool iOpenAdaptiveBookmarksWhenActivated;
       
   553         
       
   554         // True if the user opned the Adaptive Bookmarks folder,
       
   555         // from bookmarks items, otherwise false.
       
   556         TBool iAdaptiveBookmarksFolderSelected;
       
   557         
       
   558         // True if the view was changed, and the adaptive bookmarks folder
       
   559         // was currently acive.
       
   560         TBool iAdaptiveBookmarksFolderWasActive;       
       
   561         
       
   562         // Pen enabled flag
       
   563         TBool iPenEnabled;
       
   564         
       
   565         // Re-Entry Gate flag for Delete Bookmark routine
       
   566         TBool iHandleDeleteInProgress;
       
   567 
       
   568         // Async callback object for delayed App init
       
   569         CIdle *iAsyncComplete;
       
   570         
       
   571         TBool iShowDownlods;
       
   572 	};
       
   573 
       
   574 #endif
       
   575 
       
   576 // End of file