XDMSettingsUI/inc/XDMPluginSLContainer.h
changeset 26 04ca1926b01c
parent 20 76bddcd072ba
child 28 d9861ae9169c
child 32 32463a6c57b3
equal deleted inserted replaced
20:76bddcd072ba 26:04ca1926b01c
     1 /*
       
     2 * Copyright (c) 2005-2007 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:    XDM GS plugin Settings list container.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef GS_XDMPLUGIN_SL_CONTAINER_H
       
    22 #define GS_XDMPLUGIN_SL_CONTAINER_H
       
    23 
       
    24 // INCLUDES
       
    25 #include    <bldvariant.hrh>
       
    26 #include    <coeccntx.h>
       
    27 #include    <eikclb.h>
       
    28 
       
    29 #include    "XDMPlugin.hrh"
       
    30 
       
    31 // FORWARD DECLARATION
       
    32 class CGSListBoxItemTextArray;
       
    33 class CEikTextListBox;
       
    34 class CSettingsData;
       
    35 class CXDMPluginSettinglist;
       
    36 class CAknColumnListBox;
       
    37 class CAknViewAppUi;
       
    38 
       
    39 /**
       
    40 *  CXDMPluginSLContainer Settings list container class
       
    41 */
       
    42 class CXDMPluginSLContainer : public CCoeControl, MEikListBoxObserver
       
    43     {
       
    44     public:
       
    45     
       
    46         /**
       
    47         * C++ Constructor
       
    48         */
       
    49         CXDMPluginSLContainer(CAknView* aView);
       
    50         
       
    51         /**
       
    52         * Symbian OS constructor.
       
    53         * @param aRect Listbox's rect.
       
    54         */
       
    55         void ConstructL( const TRect& aRect);
       
    56 
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         ~CXDMPluginSLContainer();
       
    61     
       
    62     public: // From CCoeControl
       
    63     
       
    64         /**
       
    65         * See CCoeControl.
       
    66         */
       
    67         TInt CountComponentControls() const;
       
    68         
       
    69         /**
       
    70         * See CCoeControl.
       
    71         */
       
    72         CCoeControl* ComponentControl( TInt aIndex ) const;
       
    73         
       
    74         /**
       
    75         * See CCoeControl.
       
    76         */
       
    77         TKeyResponse OfferKeyEventL( 
       
    78             const TKeyEvent& aKeyEvent, TEventCode aType );
       
    79             
       
    80         /**
       
    81         * See CCoeControl.
       
    82         */
       
    83         void SizeChanged();
       
    84         
       
    85         /**
       
    86         * See CCoeControl.
       
    87         */
       
    88         void Draw(const TRect& aRect) const;
       
    89         
       
    90         /**
       
    91         * See CCoeControl
       
    92         */
       
    93         void HandleResourceChange( TInt aType );
       
    94 
       
    95         /**
       
    96          * Gets help context
       
    97          */
       
    98         void GetHelpContext( TCoeHelpContext& aContext ) const;
       
    99 
       
   100         /**
       
   101          * See CCoeControl
       
   102          */
       
   103         void FocusChanged(TDrawNow aDrawNow);
       
   104         
       
   105     public:
       
   106     
       
   107         /**
       
   108         * Edit currently focused item on settings list. called from UI
       
   109         */
       
   110         void EditCurrentItemL();
       
   111         
       
   112         /**
       
   113         * See MEikListBoxObserver
       
   114         */
       
   115         void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   116         
       
   117         /**
       
   118         * Prepare the XDM set with given name for editing
       
   119         * @param aXDMSetName reference to the XDM set name to be edited
       
   120         */
       
   121         void PrepareXDMSetForEditingL(TDesC& aXDMSetName);
       
   122         
       
   123         /**
       
   124         * Prepare the a new XDM set with default values
       
   125         * @param none
       
   126         */
       
   127         void PrepareXDMSetNewDefaultL();
       
   128         
       
   129         /**
       
   130         * Prepare the a new XDM set with values from an existing set
       
   131         * @param aXDMSetName reference to the new XDM set name
       
   132         */
       
   133         void PrepareNewXDMSetFromExistingL(TDesC& aXDMSetName);
       
   134         
       
   135         /**
       
   136         * Display the dialog to the user to select the creation of new set
       
   137         * from existing sets. Saves the selected name to iData
       
   138         * @return ETrue if user has choosen a set, return EFalse if user cancels
       
   139         */
       
   140         TBool DisplayNewXDMSetOptionsL();
       
   141         
       
   142         /**
       
   143         * Called by the UI when back button is pressed, to perform needed steps
       
   144         * @return ETrue if settings list is allowed to close
       
   145         */
       
   146         TBool IsExitProcessingOKL();
       
   147         
       
   148         /**
       
   149         * Handle manual resource change with its type
       
   150         * @param aType, type of resource
       
   151         */
       
   152         void HandleResourceChangeManual(TInt aType);
       
   153 
       
   154         /**
       
   155         * Save settings if possible, without any user interaction.
       
   156         * this is useful for force exit, e.g. when mmc taken out
       
   157         */
       
   158         void SaveSettingsIfPossibleL();
       
   159         
       
   160         /**
       
   161         * Return the name of current set in iData
       
   162         * @return TDes reference to current set
       
   163         */
       
   164         TDes& GetCurrentSetName();
       
   165         
       
   166         
       
   167     private: // Most of these methods perform operations using iData
       
   168     
       
   169         /**
       
   170         * Sets the title pane text with given discriptor
       
   171         * @param aTitleText text to be shown on title pane
       
   172         */
       
   173         void SetTitlePaneTextL( const TDesC& aTitleText ) const;
       
   174         
       
   175         /**
       
   176         * Finds out whether compulsory items are filled
       
   177         * @return ETrue if compulsory items are filled
       
   178         */
       
   179         TBool AreCompulsoryItemsFilled();
       
   180         
       
   181         /**
       
   182         * Display a query dialog to user that compulsory settings are not
       
   183         * filled, and if user wants to delete the settings
       
   184         * @return ETrue if user wants to delete the settings
       
   185         */
       
   186         TBool DisplayDeleteOrDontSaveDialogL();
       
   187         
       
   188         /**
       
   189         * Update an XDM set if it already exist or create it if it doesnt exist
       
   190         * @param aShowDialog whether dialog will be displayed or not
       
   191         * @return ETrue if save procedure goes ok
       
   192         */
       
   193         TBool SaveOrCreateAndSaveXDMSetL(TBool aShowDialog);
       
   194         
       
   195         /**
       
   196         * Deletes the XDM set if it exist in the XDM settings API
       
   197         */
       
   198         void DeleteXDMSetIfExistL();
       
   199         
       
   200         /**
       
   201         * Gets the setting id of the given set name
       
   202         * @param aXDMSetName reference to XDM set name
       
   203         * @return settingid of the given xdm set
       
   204         */
       
   205         TInt GetSettingIdL(TDesC& aXDMSetName);
       
   206         
       
   207         /**
       
   208         * If the given XDM set name with given ID is exist or not
       
   209         * @param aXDMSetName reference to XDM set name
       
   210         * aSettingId settings id of the XDM
       
   211         * @return ETrue of XDM set exist with given name
       
   212         */
       
   213         TBool IsXDMSetNameExistL(TDesC& aXDMSetName, TInt32& aSettingId);
       
   214         
       
   215         /**
       
   216         * Load XDM Collection names with trap, useful when list doesnt have anything
       
   217         * @param Reference to setting ids
       
   218         * @return CDesCArray collection names
       
   219         */
       
   220         CDesCArray* LoadCollectionNamesL(RArray<TInt>& aSettingIDs, TBool aDisp);
       
   221         
       
   222         /**
       
   223         * Check the given name and returns the possible altered name. NULL 
       
   224         * pointer is returned no change is needed in aName, so aName can be
       
   225         * used if NULL pointer is returned. If some valid pointer is returned
       
   226         * then that pointer is owned by client, and needed to be deleted after
       
   227         * usage. 
       
   228         * @param aName, the name from which to start suggestion.
       
   229         * @param aChanged, returns ETrue if an alternate name is returned.
       
   230         * @return HBufC* pointer to the new name, can be NULL if not needed.
       
   231         */
       
   232         HBufC* DoMakeValidNameL(HBufC* aName, TBool& aChanged);
       
   233         
       
   234         /**
       
   235         * Ensures that the passed name is valid, length > 0 & length < max.
       
   236         * If length == 0, leaves with KErrInvalidName
       
   237         * If name is only whitespace, leaves with KErrInvalidName
       
   238         * If name is longer than max, name is truncated
       
   239         * It copies the name, pushes it onto the CleanupStack and passes
       
   240         * ownership.
       
   241 
       
   242         * @param aName The name
       
   243         * @param aChanged A reference to a boolean to hold whether the name 
       
   244         *   had been changed or not.
       
   245         * @return The valid-length name
       
   246         */
       
   247         HBufC* EnsureMaxLengthLC( const TDesC* aName, TBool& aChanged);
       
   248         
       
   249         /**
       
   250         * Given aName in the format <prefix> or
       
   251         * <prefix><brace><integer><brace>, return a
       
   252         * pointer to the leading part. That is, if there is
       
   253         * trailing <space><integer>, then that is excluded;
       
   254         * if there is no trailing part, then the original
       
   255         * decriptor is returned.
       
   256         * Examples:
       
   257         *   - "Foo" returns "Foo";
       
   258         *   - "Foo 12" returns "Foo 12";
       
   259         *   - "Foo(12)" returns "Foo";
       
   260         *   - "Foo 12 (34)" returns "Foo 12 ";
       
   261         *   - "Foo bar" returns "Foo bar";
       
   262         *   - "Foo " returns "Foo ".
       
   263         * @param aName  The name to get the prefix from
       
   264         * @return The prefix
       
   265         */        
       
   266         TPtrC GetPrefix( const TDesC& aName );
       
   267         
       
   268         
       
   269         /**
       
   270         * If aName is constructed from aPrefix with a postfix, get the numeric
       
   271         * value of the postfix, e.g:
       
   272         *   - GetPostfix( "Foo (3)", "Foo" ) == 3
       
   273         *   - GetPostfix( "Foo 23 (45)", "Foo 23" ) == 45
       
   274         * If aName is the same as aPrefix, return 0, e.g.:
       
   275         *   - GetPostfix( "Foo", "Foo" ) == 0
       
   276         * If aName is not constructed from aPrefix, return -1, e.g.:
       
   277         *   - GetPostfix( "Foobar", "Foo" ) == -1
       
   278         *   - GetPostfix( "Fo 23 45", "Foo" ) == -1
       
   279         * @param aName  The name to get the postfix from
       
   280         * @param aPrefix The prefix
       
   281         * @return The postfix
       
   282         */
       
   283         TInt GetPostfix( const TDesC& aName, const TDesC& aPrefix );
       
   284 
       
   285         
       
   286    private: // data
       
   287         
       
   288         // CXDMPluginSettinglist owned
       
   289       CXDMPluginSettinglist* iSettingList;        
       
   290   
       
   291       // Pointer to settings data owned
       
   292       CSettingsData* iData;
       
   293 
       
   294       // Pointer to the application view, not owned
       
   295       CAknView* iView; // not owned
       
   296 
       
   297     };
       
   298 
       
   299 #endif //GS_XDMPLUGIN_SL_CONTAINER_H