idlefw/plugins/shortcutplugin/inc/caiscutsettingsmodel.h
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Shrortcut settings plug-in model.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAISCUTSETTINGSMODEL_H
       
    20 #define CAISCUTSETTINGSMODEL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <bamdesca.h>               // For MDesCArray
       
    24 #include <apgcli.h>                 // For RApaLsSession
       
    25 #include <favouritesdb.h>           // For RFavouritesDb
       
    26 #include <favouritesitemlist.h>     // For CFavouritesItemList
       
    27 
       
    28 #include "caiscutsettingsapplist.h"
       
    29 #include "caiscutsettingsbkmlist.h"
       
    30 
       
    31 class CCoeEnv;
       
    32 class CRepository;
       
    33 class CAiScutSettingsItem;
       
    34 class CAiScutSettingsContainer;
       
    35 class CAiScutRepositoryWatcher;
       
    36 class CAiScutSettings;
       
    37 
       
    38 /**
       
    39  * Shrortcut settings plug-in model
       
    40  *
       
    41  * @lib aiscutsettings.lib
       
    42  * @since S60 v3.2
       
    43  */
       
    44 class CAiScutSettingsModel : public CBase
       
    45                            , public MDesCArray
       
    46                            , public MAiScutListObserver
       
    47 {
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      *
       
    53      */
       
    54     static CAiScutSettingsModel* NewL(CAiScutSettings& aPlugin, CCoeEnv* aEnv);
       
    55 
       
    56     /**
       
    57      *
       
    58      */
       
    59     virtual ~CAiScutSettingsModel();
       
    60 
       
    61 public: // from MDesCArray
       
    62 
       
    63     /**
       
    64      * Returns the number of descriptor elements in a descriptor array.
       
    65      *
       
    66      * @since S60 v3.2
       
    67      * @return The number of descriptor elements in a descriptor array.
       
    68      */
       
    69     TInt MdcaCount() const;
       
    70 
       
    71     /**
       
    72      * Indexes into a descriptor array.
       
    73      *
       
    74      * @since S60 v3.2
       
    75      * @param aIndex The position of the descriptor element within a descriptor array.
       
    76      * @return A 16 bit non-modifiable pointer descriptor representing the descriptor
       
    77      *         element located at position aIndex within a descriptor array.
       
    78      */
       
    79     TPtrC MdcaPoint(TInt aIndex) const;
       
    80 
       
    81     /**
       
    82      * Handle Shortcuts changed
       
    83      */
       
    84     static TInt HandleShortcutsChanged(TAny* aPtr);
       
    85 
       
    86     /**
       
    87      * Handle hidden Applications changed
       
    88      */
       
    89     static TInt HandleHiddenAppsChanged(TAny* aPtr);
       
    90 
       
    91 public: // from MAiScutListObserver
       
    92 
       
    93     /**
       
    94      * From MAiScutListObserver
       
    95      * Callback for application list events
       
    96      *
       
    97      * @since S60 v3.2
       
    98      * @param aEvent AppList event code
       
    99      * @param aAdded ETrue if applications were added, EFalse if removed
       
   100      */
       
   101     void HandleScutListEventL(TScutListEvent aEvent, TBool aAdded);
       
   102 
       
   103     /**
       
   104      * Find application is hidden using Uid
       
   105      */
       
   106     TBool IsHidden(const TUid& aAppUid) const;
       
   107 
       
   108 public:
       
   109 
       
   110     /**
       
   111      * Tells the application list and bookmark list to start or stop observing for changes
       
   112      */
       
   113     void ActivateObservers(TBool aActivate);
       
   114 
       
   115     /**
       
   116      * Returns a setting item for the given index
       
   117      *
       
   118      * @since S60 v3.2
       
   119      * @param aIndex Index of the setting item
       
   120      * @return Pointer to a setting item
       
   121      */
       
   122     CAiScutSettingsItem* Item(TInt aIndex) const;
       
   123 
       
   124     /**
       
   125      * Utility function to retrieve an appliation caption from an uid
       
   126      *
       
   127      * @since S60 v3.2
       
   128      * @param aUid Application uid
       
   129      * @return Pointer descriptor to the application caption
       
   130      */
       
   131     TInt GetAppCaption(const TUid aUid, TDes& aCaption);
       
   132 
       
   133     /**
       
   134      * Utility function to retrieve a bookmark caption from an uid
       
   135      *
       
   136      * @since S60 v3.2
       
   137      * @param aUid Bookmark uid
       
   138      * @return Pointer descriptor to the bookmark caption
       
   139      */
       
   140     TInt GetBkmCaptionL(const TUid aUid, TDes& aCaption);
       
   141 
       
   142     /**
       
   143      * Returns a pointer to the coe environment
       
   144      *
       
   145      * @since S60 v3.2
       
   146      * @return Pointer to coe environment
       
   147      */
       
   148     CCoeEnv* Env();
       
   149 
       
   150     /**
       
   151      * Handles saving a setting item to central repository
       
   152      *
       
   153      * @since S60 v3.2
       
   154      * @param aItem Item to save
       
   155      */
       
   156     void SaveItemL(CAiScutSettingsItem& aItem);
       
   157 
       
   158     /**
       
   159      * Sets pointer to settings plug-in container.
       
   160      *
       
   161      * @since S60 v3.2
       
   162      * @param aContainer Pointer to settings plug-in container.
       
   163      */
       
   164     void SetContainer(CAiScutSettingsContainer* aContainer);
       
   165 
       
   166     /**
       
   167      * Read bookmarks from favourites engine.
       
   168      *
       
   169      */
       
   170     void ReadBookmarksL();
       
   171 
       
   172     /**
       
   173      * Return bookmark count.
       
   174      */
       
   175     TInt BookmarkCount() const;
       
   176 
       
   177     /**
       
   178      * Get bookmark from index aIndex.
       
   179      */
       
   180     CFavouritesItem* GetBookmark(TInt aIndex);
       
   181 
       
   182     /**
       
   183      * Returns reference to the bookmark database owned by the engine
       
   184      *
       
   185      * @return Reference to RFavouritesDb
       
   186      */
       
   187     RFavouritesDb& FavouritesDb();
       
   188 
       
   189     /**
       
   190      *
       
   191      */
       
   192     CAiScutSettingsAppList* AppList();
       
   193 
       
   194     /**
       
   195      *
       
   196      */
       
   197     CAiScutSettingsBkmList* BkmList();
       
   198     
       
   199     /**
       
   200      *
       
   201      */
       
   202     void SetSettingsKeys(RArray<TUint32>& aKeys);
       
   203     
       
   204     /**
       
   205      *
       
   206      */
       
   207     void UpdateSettingsL();    
       
   208 
       
   209     /**
       
   210      *
       
   211      */
       
   212     void UpdateSettingsContainerL();
       
   213 
       
   214 private:
       
   215 
       
   216     /**
       
   217      *
       
   218      */
       
   219     CAiScutSettingsModel(CAiScutSettings& aPlugin, CCoeEnv* aEnv);
       
   220 
       
   221     /**
       
   222      *
       
   223      */
       
   224     void ConstructL();
       
   225 
       
   226 
       
   227     /**
       
   228      *
       
   229      */
       
   230     void GetHiddenAppsL();
       
   231 
       
   232 private:  // data
       
   233 
       
   234     /**
       
   235      * Array of setting items.
       
   236      * Own.
       
   237      */
       
   238     RPointerArray<CAiScutSettingsItem>  iSettings;
       
   239 
       
   240     /**
       
   241      * Array of keys for settings items
       
   242      * Own.
       
   243      */    
       
   244     RArray<TUint32>                     iKeys;
       
   245 
       
   246     /**
       
   247      * Central repository handler.
       
   248      * Own.
       
   249      */
       
   250     CRepository*                        iRepository;
       
   251 
       
   252     /**
       
   253      * Application architecture server session.
       
   254      * Own.
       
   255      */
       
   256     RApaLsSession                       iApaSession;
       
   257 
       
   258     /**
       
   259      * Bookmark database session.
       
   260      * Own.
       
   261      */
       
   262     RFavouritesSession                  iBookmarkSess;
       
   263 
       
   264     /**
       
   265      * Bookmark database.
       
   266      * Own.
       
   267      */
       
   268     RFavouritesDb                       iBookmarkDb;
       
   269 
       
   270     /**
       
   271      * Bookmark list.
       
   272      * Own.
       
   273      */
       
   274     CFavouritesItemList*                iFavItemList;
       
   275 
       
   276     /**
       
   277      * Settings plugin
       
   278      * Not own.
       
   279      */    
       
   280     CAiScutSettings&                    iPlugin;     
       
   281 
       
   282     /**
       
   283      * Coe environment.
       
   284      * Not own.
       
   285      */
       
   286     CCoeEnv*                            iEnv;
       
   287 
       
   288     /**
       
   289      * Application list.
       
   290      * Own.
       
   291      */
       
   292     CAiScutSettingsAppList*             iAppList;
       
   293 
       
   294     /**
       
   295      * Bookmark list.
       
   296      * Own.
       
   297      */
       
   298     CAiScutSettingsBkmList*             iBkmList;
       
   299 
       
   300     /**
       
   301      * Notifier for changes in the shortcut settings.
       
   302      * Own.
       
   303      */
       
   304     CAiScutRepositoryWatcher*           iSettingsNotifier;
       
   305 
       
   306     /**
       
   307      * Settings plugin container.
       
   308      * Not own.
       
   309      */
       
   310     CAiScutSettingsContainer*           iContainer;
       
   311 
       
   312     // Array of UIDs which are hidden from the TARM
       
   313     RArray<TUid>                        iHiddenApps;
       
   314 
       
   315     // Central repository object for Hidden Apps
       
   316     CRepository*                        iHiddenAppsRepository;
       
   317 
       
   318     // Central repository change handler for Hidden Apps
       
   319     CAiScutRepositoryWatcher*           iHiddenAppsNotifier;
       
   320 
       
   321 };
       
   322 
       
   323 #endif // CAISCUTSETTINGSMODEL_H
       
   324 
       
   325 // End of File.