email/imum/Utils/Inc/MuiuDynamicSettingsArray.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 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:  This file contains declearation of settings array handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MUIUDYNAMICSETTINGSARRAY_H
       
    21 #define MUIUDYNAMICSETTINGSARRAY_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>                // Base symbian include
       
    25 #include <e32debug.h>               // RDebug
       
    26 #include <bamdesca.h>                // MDesCArray
       
    27 #include <eikenv.h>                 // CEikonEnv
       
    28 #include "MuiuDynamicSettingsArray.hrh" // CMuiuSettingsType
       
    29 #include "MuiuDynamicSettingItemBase.h"      // CMuiuSettingBase
       
    30 #include "MuiuDynamicSettingItemEditValue.h" // CMuiuSettingEditValue
       
    31 #include "MuiuDynamicSettingItemEditText.h"  // CMuiuSettingEditText
       
    32 #include "MuiuDynamicSettingItemLink.h"      // CMuiuSettingLink
       
    33 #include "MuiuDynamicSettingItemExtLink.h"   // CMuiuSettingExtLink
       
    34 #include <ConeResLoader.h>              // RConeResourceLoader
       
    35 #include <muiuflags.h>
       
    36 #include "MuiuDynamicSettingsItemFinderInterface.h"
       
    37 
       
    38 // CONSTANTS
       
    39 enum TMuiuStackResult
       
    40     {
       
    41     EMuiuStackResultOk,
       
    42     EMuiuStackResultSubMenuOpen,
       
    43     EMuiuStackResultInvalid
       
    44     };
       
    45 
       
    46 // MACROS
       
    47 // DATA TYPES
       
    48 typedef RArray<TInt> RResourceStack;
       
    49 
       
    50 // FUNCTION PROTOTYPES
       
    51 // FORWARD DECLARATIONS
       
    52 class TResourceReader;
       
    53 class CMuiuSettingBase;
       
    54 class CMuiuDynamicSettingsItemFinder;
       
    55 class TMuiuFinderItem;
       
    56 
       
    57 // CLASS DECLARATION
       
    58 
       
    59 /**
       
    60 *  ?one_line_short_description.
       
    61 *  ?other_description_lines
       
    62 *
       
    63 *  @lib ?library
       
    64 *  @since S60 3.0
       
    65 */
       
    66 class CMuiuDynamicSettingsArray :
       
    67     public CBase, public MDesCArray,
       
    68     public MMuiuDynamicSettingsItemFinderInterface
       
    69     {
       
    70     public: // Constructors and destructor
       
    71 
       
    72         virtual ~CMuiuDynamicSettingsArray();
       
    73 
       
    74     public: // New functions
       
    75 
       
    76         /**
       
    77         * Forces the redraw
       
    78         * @since S60 3.0
       
    79         */
       
    80         void Refresh();
       
    81 
       
    82         /**
       
    83         * ?member_description
       
    84         * @since S60 3.0
       
    85         * @param aResource Resource to be used to add the objects to the array
       
    86         * @return Result of the operation
       
    87         */
       
    88         TInt AddItemsL(
       
    89             const TInt aResource );
       
    90 
       
    91         TInt AddItemsL(
       
    92             const TInt aResource,
       
    93             const TInt aIndex );
       
    94 
       
    95         TInt AddItemL(
       
    96             const CMuiuSettingBase& aBaseItem,
       
    97             const TInt aIndex = KErrNotFound );
       
    98 
       
    99         TInt DelItems( const TInt aResource );
       
   100         TInt DelItem( const TInt aIndex );
       
   101         TInt DelItem( const TUid& aId );
       
   102 
       
   103         void SetItemValue(
       
   104             const TUid& aId,
       
   105             const TInt aValue,
       
   106             const TBool aUpdate = EFalse );
       
   107 
       
   108         void SetItemValue(
       
   109             const TInt aIndex,
       
   110             const TInt aValue,
       
   111             const TBool aUpdate = EFalse );
       
   112 
       
   113         void SetItemValue(
       
   114             CMuiuSettingBase& aBaseItem,
       
   115             const TInt aValue,
       
   116             const TBool aUpdate = EFalse );
       
   117 
       
   118         void SetItemText(
       
   119             const TUid& aId,
       
   120             const TMuiuSettingsText& aText,
       
   121             const TBool aUpdate = EFalse );
       
   122 
       
   123         void SetItemText(
       
   124             const TInt aIndex,
       
   125             const TMuiuSettingsText& aText,
       
   126             const TBool aUpdate = EFalse );
       
   127 
       
   128         void SetItemText(
       
   129             CMuiuSettingBase& aBaseItem,
       
   130             const TMuiuSettingsText& aText,
       
   131             const TBool aUpdate = EFalse );
       
   132 
       
   133         const TMuiuSettingsText* ItemText(
       
   134             CMuiuSettingBase& aBaseItem );
       
   135 
       
   136         /**
       
   137         *
       
   138         * @since S60
       
   139         * @return
       
   140         */
       
   141         TMuiuStackResult HandleStackForwardL(
       
   142             const TInt aIndex = KErrNotFound );
       
   143         TMuiuStackResult HandleStackForwardL( const TUid& aId );
       
   144         TMuiuStackResult HandleStackForwardL( const CMuiuSettingBase& aBase );
       
   145         TMuiuStackResult HandleStackBackwardL( TInt aCount = 1 );
       
   146         TMuiuStackResult HandleStackChangeL(
       
   147             const TInt aForward,
       
   148             const TInt aResourceId = KErrNotFound );
       
   149 
       
   150         /**
       
   151         * Checks if item is hidden
       
   152         * @since S60
       
   153         * @param aIndex, index of the item
       
   154         * @param aId, id of the item
       
   155         * @param aItem, the item
       
   156         * @return KErrNone, if item is visible
       
   157         * @return KErrNotFound, if item is hidden
       
   158         * @return KErrNotSupported, if item is permanently hidden
       
   159         */
       
   160         TInt IsHidden( const TInt aIndex ) const;
       
   161         TInt IsHidden( const TUid& iId ) const;
       
   162         TInt IsHidden( const CMuiuSettingBase& aItem ) const;
       
   163 
       
   164         /**
       
   165         * Item hide functions
       
   166         */
       
   167         void SetHideAll(
       
   168             const TBool aHide,
       
   169             const TBool aUpdate = EFalse );
       
   170         void SetHideItem(
       
   171             const TBool aHide,
       
   172             const TInt aIndex,
       
   173             const TBool aUpdate = EFalse );
       
   174         void SetHideItem(
       
   175             const TBool aHide,
       
   176             const TUid& aId,
       
   177             const TBool aUpdate = EFalse );
       
   178         void SetHideItem(
       
   179             const TBool aHide,
       
   180             const CMuiuSettingBase& aItem,
       
   181             const TBool aUpdate = EFalse );
       
   182         void SetHideItems(
       
   183             const TBool aHide,
       
   184             const TInt aResource,
       
   185             const TBool aUpdate = EFalse );
       
   186         void SetHideItemsExcept(
       
   187             const TBool aHide,
       
   188             const TInt aIndex,
       
   189             const TBool aUpdate = EFalse );
       
   190         void SetHideItemsExcept(
       
   191             const TBool aHide,
       
   192             const TUid& aId,
       
   193             const TBool aUpdate = EFalse );
       
   194         void SetHideItemsExcept(
       
   195             const TBool aHide,
       
   196             const CMuiuSettingBase& aItem,
       
   197             const TBool aUpdate = EFalse );
       
   198         void SetHideItemsExceptIn(
       
   199             const TBool aHide,
       
   200             const TInt aResource,
       
   201             const TBool aUpdate = EFalse );
       
   202 
       
   203         CMuiuSettingBase* GetItem(
       
   204             const TUid& aId,
       
   205             const TBool aExcludeHidden = ETrue ) const;
       
   206 
       
   207         CMuiuSettingBase* GetItem(
       
   208             const TInt aIndex,
       
   209             const TBool aExcludeHidden = ETrue ) const;
       
   210 
       
   211     public: // Functions from base classes
       
   212     protected:  // Constructors
       
   213 
       
   214         CMuiuDynamicSettingsArray();
       
   215         void BaseConstructL( const TBool aLockedSettings );
       
   216         void BaseConstructL( 
       
   217             const TInt aResourceId, 
       
   218             const TBool aLockedSettings );
       
   219 
       
   220     protected:  // Data
       
   221 
       
   222         enum TMuiuArrayEvents
       
   223             {
       
   224             EMuiuDynArrayAdded = 0,
       
   225             EMuiuDynArrayRemoved,
       
   226             EMuiuDynArrayChanged,
       
   227             EMuiuDynArrayStackForward,
       
   228             EMuiuDynArrayStackBackward
       
   229             };
       
   230 
       
   231     protected:  // New virtual functions
       
   232 
       
   233         virtual TInt EventArrayChangedL(
       
   234             const TMuiuArrayEvents aEvent ) = 0;
       
   235 
       
   236         virtual TBool EventCustomMdcaPoint(
       
   237             const TUid& aId,
       
   238             TPtr& aString ) const = 0;
       
   239 
       
   240         /**
       
   241         *
       
   242         * @since S60 3.0
       
   243         */
       
   244         virtual CMuiuSettingBase* CreateCustomItemToArrayLC(
       
   245             const TUid& aId );
       
   246 
       
   247         /**
       
   248         *
       
   249         * @since S60 3.0
       
   250         */
       
   251         virtual void ListboxItemFillMultiLineLabel(
       
   252             const CMuiuSettingBase& aBaseItem,
       
   253             TMuiuSettingsText& aText ) const;
       
   254 
       
   255         /**
       
   256         *
       
   257         * @since S60 3.0
       
   258         */
       
   259         virtual void ListboxItemFillEditTextLabel(
       
   260             const CMuiuSettingBase& aBaseItem,
       
   261             TMuiuSettingsText& aText ) const;
       
   262 
       
   263         /**
       
   264         *
       
   265         * @since S60 3.0
       
   266         */
       
   267         virtual void ListboxItemFillEditValueLabel(
       
   268             const CMuiuSettingBase& aBaseItem,
       
   269             TMuiuSettingsText& aText ) const;
       
   270 
       
   271         /**
       
   272         *
       
   273         * @since S60 3.0
       
   274         */
       
   275         virtual void ListboxItemFillEditTimeLabel(
       
   276             const CMuiuSettingBase& aBaseItem,
       
   277             TMuiuSettingsText& aText ) const;
       
   278 
       
   279         /**
       
   280         *
       
   281         * @since S60 3.0
       
   282         */
       
   283         virtual void ListboxUndefinedFillLabel(
       
   284             const CMuiuSettingBase& aBaseItem,
       
   285             TMuiuSettingsText& aText ) const;
       
   286 
       
   287         /**
       
   288         *
       
   289         * @since S60 3.0
       
   290         */
       
   291         virtual void ListboxRadioButtonFillArrayLabel(
       
   292             const CMuiuSettingBase& aBaseItem,
       
   293             TMuiuSettingsText& aText ) const;
       
   294 
       
   295         /**
       
   296         *
       
   297         * @since S60 3.0
       
   298         */
       
   299         virtual void ListboxCheckboxFillArrayLabel(
       
   300             const CMuiuSettingBase& aBaseItem,
       
   301             TMuiuSettingsText& aText ) const;
       
   302 
       
   303     protected:  // New functions
       
   304 
       
   305         /**
       
   306         *
       
   307         * @since S60 3.0
       
   308         */
       
   309         CMuiuSettingBase* GetSubItem(
       
   310             const CMuiuSettingBase& aBaseItem,
       
   311             const TUid& aId,
       
   312             const TBool aExcludeHidden = ETrue ) const;
       
   313 
       
   314         /**
       
   315         *
       
   316         * @since S60 3.0
       
   317         */
       
   318         CMuiuSettingBase* GetSubItem(
       
   319             const CMuiuSettingBase& aBaseItem,
       
   320             const TInt aIndex,
       
   321             const TBool aExcludeHidden = ETrue ) const;
       
   322 
       
   323         /**
       
   324         *
       
   325         * @since S60 3.0
       
   326         */
       
   327         TInt GetSubItemIndex(
       
   328             const CMuiuSettingsLink& aLinkItem,
       
   329             const TUid& aId,
       
   330             const TBool aExcludeHidden = ETrue ) const;
       
   331 
       
   332         /**
       
   333         *
       
   334         * @since S60 3.0
       
   335         * @param aActualIndex
       
   336         *    ETrue  : aIndex is from visible list and index
       
   337         *             from the actual resource is required
       
   338         *    EFalse : aIndex is from resource and visible
       
   339         *             index is required
       
   340         */
       
   341         TInt GetSubItemIndex(
       
   342             const CMuiuSettingsLink& aLinkItem,
       
   343             const TInt aIndex,
       
   344             const TBool aActualIndex ) const;
       
   345 
       
   346         CMuiuDynFinderItemArray* GetResource(
       
   347             const TInt aResourceId,
       
   348             const TBool aExcludeHidden = ETrue ) const;
       
   349         CMuiuDynFinderItemArray* GetResourceLC(
       
   350             const TInt aResourceId,
       
   351             const TInt aExcludeHidden = ETrue ) const;
       
   352 
       
   353         TInt ItemIndex(
       
   354             const TUid& aId,
       
   355             const TBool aExcludeHidden = ETrue ) const;
       
   356 
       
   357         void SetBetweenValues(
       
   358             TInt& aValue,
       
   359             TInt aMin,
       
   360             TInt aMax ) const;
       
   361 
       
   362         TBool ItemSubArrayCheck(
       
   363             const CMuiuSettingBase& aBaseItem ) const;
       
   364 
       
   365         TBool ItemSubItemCheck(
       
   366             const CMuiuSettingBase& aBaseItem ) const;
       
   367 
       
   368         TInt StackActiveResource() const;
       
   369 
       
   370         /**
       
   371         *
       
   372         * @since S60 3.0
       
   373         */
       
   374         TBool IsVisibleCheck(
       
   375             const CMuiuSettingBase& aBaseItem,
       
   376             const TBool aExcludeHidden ) const;
       
   377 
       
   378     protected:  // Functions from base classes
       
   379 
       
   380         TInt MdcaCount() const;
       
   381 
       
   382         // From MMuiuDynamicSettingsItemFinderInterface
       
   383         virtual TBool SearchDoError();
       
   384 
       
   385         virtual TBool SearchDoContinuationCheck(
       
   386             const CMuiuSettingBase& aItem,
       
   387             const TInt aIndex );
       
   388 
       
   389         virtual TBool SearchDoItemCheck(
       
   390             CMuiuSettingBase& aItem );
       
   391 
       
   392     private:  // New virtual functions
       
   393     private:  // New functions
       
   394 
       
   395         /**
       
   396         *
       
   397         * @since S60 3.0
       
   398         */
       
   399         void CleanArrayItems();
       
   400 
       
   401         /**
       
   402         *
       
   403         * @since S60 3.0
       
   404         */
       
   405         void LoadSettingArrayFromResourceL( const TInt aResourceId );
       
   406 
       
   407         /**
       
   408         *
       
   409         * @since S60 3.0
       
   410         */
       
   411         TInt LoadSettingItemsToArrayL(
       
   412             const TInt aResourceId,
       
   413             CMuiuDynSetItemArray& aItemArray );
       
   414 
       
   415 
       
   416         void UpdateActiveItemsCount( const TInt aNewCount = KErrNotFound );
       
   417 
       
   418         /**
       
   419         *
       
   420         * @since S60
       
   421         */
       
   422         void HandleDynamicSettingsItemL(
       
   423             CMuiuSettingBase& aBaseItem,
       
   424             const TInt aMaxLength,
       
   425             const TMuiuDynSettingsType aSubType,
       
   426             const TInt aLinkResourceId,
       
   427             const TDesC* aEmptyText );
       
   428 
       
   429         /**
       
   430         *
       
   431         * @since S60
       
   432         */
       
   433         void LoadDynamicSettingItemL(
       
   434             TResourceReader& aReader,
       
   435             CMuiuSettingBase& aBaseItem );
       
   436 
       
   437         /**
       
   438         *
       
   439         * @since S60 3.0
       
   440         */
       
   441         TPtrC16 ListboxItemLabelFillL(
       
   442             CMuiuSettingBase& aBaseItem ) const;
       
   443 
       
   444         /**
       
   445         *
       
   446         * @since S60 3.0
       
   447         */
       
   448         CMuiuSettingBase* CreateItemToArrayL(
       
   449             const TMuiuDynSettingsType aType,
       
   450             const TUid& aId,
       
   451             CMuiuDynSetItemArray& aItemArray );
       
   452 
       
   453         /**
       
   454         * Functions to load special item settings
       
   455         * @since S60 3.0
       
   456         * @param aReader, Reader to be used to read the resource
       
   457         * @param aBaseItem, Item to be used as base to settings
       
   458         * @param aItemArray, Array that item should be stored
       
   459         */
       
   460         void LoadDynamicSettingsItemLinkItemL(
       
   461             CMuiuSettingBase& aBaseItem,
       
   462             const TMuiuDynSettingsType aSubType,
       
   463             const TInt aLinkResourceId );
       
   464 
       
   465         void LoadDynamicSettingsItemRadioButtonArrayL(
       
   466             CMuiuSettingBase& aBaseItem,
       
   467             CMuiuDynSetItemArray& aItemArray );
       
   468 
       
   469         void LoadDynamicSettingsItemCheckBoxArrayL(
       
   470             CMuiuSettingBase& aBaseItem,
       
   471             CMuiuDynSetItemArray& aItemArray );
       
   472 
       
   473         void UpdateItemEditTextL(
       
   474             CMuiuSettingBase& aBaseItem,
       
   475             const TInt aMaxLength,
       
   476             const TDesC* aEmptyText );
       
   477 
       
   478         void UpdateItemEditValueL(
       
   479             CMuiuSettingBase& aBaseItem,
       
   480             const TInt aMaxLength );
       
   481 
       
   482         void LoadDynamicSettingItemFlags(
       
   483             const TUint32 aFlags );
       
   484 
       
   485         // SEARCHING
       
   486 
       
   487         /**
       
   488         *
       
   489         * @since S60 3.0
       
   490         */
       
   491         void SearchResourceL(
       
   492             const TInt aResourceId,
       
   493             const TBool aExcludeHidden ) const;
       
   494 
       
   495         /**
       
   496         *
       
   497         * @since S60 3.0
       
   498         */
       
   499         void DoHideItems( const TBool aHide );
       
   500         void InitDefaultSearch(
       
   501             const TBool aExcludeHidden = ETrue ) const;
       
   502 
       
   503         /**
       
   504         *
       
   505         * @since S60 3.0
       
   506         */
       
   507         TInt StackCountItems(
       
   508             const TBool aExcludeHidden = ETrue ) const;
       
   509 
       
   510     private:  // Functions from base classes
       
   511 
       
   512         // from MDesCArray
       
   513         TPtrC16 MdcaPoint( TInt aIndex ) const;
       
   514 
       
   515     public:     // Data
       
   516     protected:  // Data
       
   517 
       
   518         // Flags to control the array behaviour
       
   519         enum TMuiuDynArrayFlags
       
   520             {
       
   521             // Allows updating of the array items
       
   522             EMuiuDynArrayAllowRefresh = 0,
       
   523             // Indicates if email settings are locked
       
   524             EMuiuEMailLockedSettings
       
   525             };
       
   526             
       
   527         // Text array for temporary usage, should be
       
   528         // deleted after the use
       
   529         HBufC*                  iTempText;
       
   530         // Flags for array handling
       
   531         TMuiuFlags              iArrayFlags;
       
   532         // String containing text from resource file
       
   533         HBufC*                  iResourceText;
       
   534 
       
   535     private:    // Data
       
   536 
       
   537         // Object to load resources
       
   538         RConeResourceLoader     iResourceLoader;
       
   539         // Item finder object
       
   540         CMuiuDynamicSettingsItemFinder* iFinder;
       
   541         // Stack to track the active resources
       
   542         RResourceStack*         iResourceStack;
       
   543         // Array of items to be shown
       
   544         CMuiuDynSetItemArray*   iItemArray;
       
   545         // String to fill empty compulsary fields
       
   546         HBufC*                  iCompulsoryText;
       
   547         // Char to replace character in password fields
       
   548         TUint16                 iPasswordFill;
       
   549         // Count of active items in array
       
   550         TInt                    iActiveCount;
       
   551         // Error state
       
   552         TInt                    iError;
       
   553         // Not own:
       
   554         CEikonEnv*              iEnv;
       
   555     };
       
   556 
       
   557 #endif      // MUIUDYNAMICSETTINGSARRAY_H
       
   558 
       
   559 // End of File