idlefw/plugins/mcsplugin/settings/inc/mcspluginsettingsmodel.h
changeset 0 79c6a41cd166
child 11 bd874ee5e5e2
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2009 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:  MCS settings plug-in model.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMCSPLUGINSETTINGSMODEL_H
       
    20 #define CMCSPLUGINSETTINGSMODEL_H
       
    21 
       
    22 // External includes
       
    23 #include <e32base.h>
       
    24 #include <bamdesca.h>               // For MDesCArray
       
    25 #include <badesca.h>
       
    26 #include <mhomescreensettingsobserver.h>
       
    27 #include <hspluginsettings.h>
       
    28 #include <propertymap.h>
       
    29 
       
    30 // Internal includes
       
    31 #include "mcspluginsettingsapplist.h"
       
    32 #include "mcspluginsettingsbkmlist.h"
       
    33 
       
    34 // Forward declaration
       
    35 class CCoeEnv;
       
    36 class CMCSPluginSettingsContainer;
       
    37 class CMCSPluginSettings;
       
    38 class HSPluginSettingsIf::CItemMap;
       
    39 
       
    40 /**
       
    41  * TSettingType
       
    42  */
       
    43 enum TSettingType
       
    44     {
       
    45     EApplication,
       
    46     EBookmark
       
    47     };
       
    48 
       
    49 /**
       
    50  * TSettingItem
       
    51  */
       
    52 struct TSettingItem
       
    53     {
       
    54     TInt id;
       
    55     TSettingType type;
       
    56     TBool locked;
       
    57     };
       
    58 
       
    59 /**
       
    60  *  @ingroup group_mcsplugin
       
    61  *
       
    62  * MCS settings plug-in model
       
    63  *
       
    64  * @lib mcspluginsettings.lib
       
    65  * @since S60 9.1
       
    66  */
       
    67 class CMCSPluginSettingsModel : public CBase
       
    68     , public MDesCArray
       
    69     , public HSPluginSettingsIf::MHomeScreenSettingsObserver
       
    70 {
       
    71 
       
    72 public:
       
    73 
       
    74     /**
       
    75      * Two phase constructor
       
    76      * 
       
    77      * @param aPlugin
       
    78      * @param aEnv
       
    79      */
       
    80     static CMCSPluginSettingsModel* NewL( CMCSPluginSettings& aPlugin,
       
    81         CCoeEnv* aEnv);
       
    82 
       
    83     /**
       
    84      * Descructor
       
    85      */
       
    86     virtual ~CMCSPluginSettingsModel();
       
    87 
       
    88 public: // from MDesCArray
       
    89 
       
    90     /**
       
    91      * Returns the number of descriptor elements in a descriptor array.
       
    92      *
       
    93      * @since S60 v3.2
       
    94      * @return The number of descriptor elements in a descriptor array.
       
    95      */
       
    96     TInt MdcaCount() const;
       
    97 
       
    98     /**
       
    99      * Indexes into a descriptor array.
       
   100      *
       
   101      * @since S60 v3.2
       
   102      * @param aIndex The position of the descriptor element within 
       
   103      *               a descriptor array.
       
   104      * @return A 16 bit non-modifiable pointer descriptor representing the 
       
   105      *         descriptor element located at position aIndex within a descriptor 
       
   106      *         array.
       
   107      */
       
   108     TPtrC MdcaPoint(TInt aIndex) const;
       
   109 
       
   110 public:
       
   111 
       
   112     /**
       
   113      * Returns an ID of a setting item for the given index
       
   114      *
       
   115      * @since S60 v3.2
       
   116      * @param aIndex Index of the setting item
       
   117      * @return ID of a setting item
       
   118      */
       
   119     TInt ItemId( TInt aIndex ) const;
       
   120 
       
   121     /**
       
   122      * Returns a pointer to setting item for the given index
       
   123      *
       
   124      * @since S60 v9.1
       
   125      * @param aIndex Index of the setting item
       
   126      * @return setting item
       
   127      */
       
   128     const TSettingItem Item( TInt aIndex ) const;
       
   129 
       
   130     /**
       
   131      *
       
   132      */
       
   133     TBool ReplaceItemL( const TInt& aItemIndex, TInt aValue,
       
   134         TSettingType aType );
       
   135 
       
   136     /**
       
   137      * Sets pointer to settings plug-in container.
       
   138      *
       
   139      * @since S60 v3.2
       
   140      * @param aContainer Pointer to settings plug-in container.
       
   141      */
       
   142     void SetContainer(CMCSPluginSettingsContainer* aContainer);
       
   143 
       
   144 
       
   145     /**
       
   146      * Get application list
       
   147      */
       
   148     CMCSPluginSettingsAppList* AppList();
       
   149 
       
   150     /**
       
   151      * Get bookmark list
       
   152      */
       
   153     CMCSPluginSettingsBkmList* BkmList();
       
   154 
       
   155     /**
       
   156      * Update application list
       
   157      */
       
   158     void UpdateAppListL();
       
   159 
       
   160     /**
       
   161      * Update bookmark list
       
   162      */
       
   163     void UpdateBkmListL();
       
   164 
       
   165     /**
       
   166      * Update settings container
       
   167      * 
       
   168      * @param aPluginId
       
   169      */
       
   170     void UpdateSettingsContainerL( const TDesC8& aPluginId );
       
   171 
       
   172     // From MHomeScreenSettingsObserver
       
   173     /**
       
   174      * Settings changed
       
   175      * 
       
   176      * @param aEvent
       
   177      * @param aPluginName
       
   178      * @param aPluginUid
       
   179      * @param aPluginId
       
   180      * @return TInt
       
   181      */
       
   182     TInt SettingsChangedL( const TDesC8& aEvent,  const TDesC8& aPluginName,
       
   183         const TDesC8& aPluginUid, const TDesC8& aPluginId );
       
   184 
       
   185 private:
       
   186 
       
   187     /**
       
   188      * Private constructor
       
   189      * 
       
   190      * @param aPlugin
       
   191      * @param aEnv
       
   192      */
       
   193     CMCSPluginSettingsModel(CMCSPluginSettings& aPlugin, CCoeEnv* aEnv);
       
   194 
       
   195     /**
       
   196      * Leaving constructor
       
   197      */
       
   198     void ConstructL();
       
   199 
       
   200     /**
       
   201      * ListBoxLineL
       
   202      * 
       
   203      * @param aCaption
       
   204      * @param aIndex
       
   205      * @return TPtrC
       
   206      */
       
   207     TPtrC ListBoxLineL( const TDesC& aCaption, TInt aIndex ) const;
       
   208 
       
   209     /**
       
   210      * ItemL
       
   211      * 
       
   212      * @param aProperties
       
   213      * @return TSettingItem
       
   214      */
       
   215     TSettingItem ItemL( 
       
   216         RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties );
       
   217 
       
   218     /**
       
   219      * Setting type
       
   220      * 
       
   221      * @param aProperties
       
   222      * @return TSettingType
       
   223      */
       
   224     TSettingType SettingTypeL( 
       
   225        RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties );
       
   226 
       
   227     /**
       
   228      * Setting locked
       
   229      * 
       
   230      * @param aProperties
       
   231      * @return TBool
       
   232      */
       
   233     TBool SettingLockedL( 
       
   234         RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties );
       
   235 
       
   236     /**
       
   237      * Update settings
       
   238      * 
       
   239      * @param aPluginId
       
   240      */
       
   241     void UpdateSettingsL( const TDesC8& aPluginId );
       
   242 
       
   243     /**
       
   244      * Save settings
       
   245      * 
       
   246      * @param aIndex
       
   247      * @param aMenuItem
       
   248      */
       
   249     void SaveSettingsL( const TInt& aIndex, CMenuItem& aMenuItem );
       
   250 
       
   251 private: // data
       
   252 
       
   253     /**
       
   254      * Array of setting items.
       
   255      * Own.
       
   256      */
       
   257     RArray<TSettingItem> iSettings;
       
   258 
       
   259     // Homescreen settings API
       
   260     HSPluginSettingsIf::CHomescreenSettings* iPluginSettings;
       
   261 
       
   262     HBufC8* iPluginId;
       
   263 
       
   264     // Stores the text which is drawn by listbox
       
   265     // Listbox takes only reference
       
   266     mutable HBufC* iListBoxLine;
       
   267 
       
   268     /**
       
   269      * Settings plugin
       
   270      * Not own.
       
   271      */
       
   272     CMCSPluginSettings& iPlugin;
       
   273 
       
   274     /**
       
   275      * Coe environment.
       
   276      * Not own.
       
   277      */
       
   278     CCoeEnv* iEnv;
       
   279 
       
   280     /**
       
   281      * Application list.
       
   282      * Own.
       
   283      */
       
   284     CMCSPluginSettingsAppList* iAppList;
       
   285 
       
   286     /**
       
   287      * Bookmark list.
       
   288      * Own.
       
   289      */
       
   290     CMCSPluginSettingsBkmList* iBkmList;
       
   291 
       
   292     /**
       
   293      * Settings plugin container.
       
   294      * Not own.
       
   295      */
       
   296     CMCSPluginSettingsContainer* iContainer;
       
   297 };
       
   298 
       
   299 #endif // CMCSPLUGINSETTINGSMODEL_H
       
   300 
       
   301 // End of File.