cbs/CbsServer/ServerInc/CCbsDbImpSettings.H
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2003 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 the header file of the CCbsDbImpSettings class
       
    15 *    
       
    16 *                This class represents the settings stored in the database.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef     CCBSDBIMPSETTINGS_H
       
    23 #define     CCBSDBIMPSETTINGS_H
       
    24 
       
    25 // INCLUDES
       
    26 #include "CbsCommon.h"
       
    27 #include "CCbsDbImp.H"
       
    28 
       
    29 //  FORWARD DECLARATIONS
       
    30 class MCbsDbSettingsObserver;
       
    31 
       
    32 //  CLASS DECLARATION 
       
    33 
       
    34 /**
       
    35 *   CCbsDbImpSettings represents server persistent settings.
       
    36 *   These settings include receive mode, topic detection mode
       
    37 *   and user selected languages.
       
    38 *
       
    39 *   Receive mode controls whether any CB messages are received
       
    40 *   or not. If topic detection is enabled and a message belonging
       
    41 *   to a previously unknown topic (i.e., a topic not on topic list)
       
    42 *   is received, the topic of this message is added onto the topic
       
    43 *   list.
       
    44 *
       
    45 *   User selected languages determine which message are received.
       
    46 *   The language of an incoming message has to be on the array
       
    47 *   of these preferred languages. Selection "All" allows reception
       
    48 *   of all messages, regardless of language. 
       
    49 *
       
    50 *   Settings are modifiable only through UI client requests.
       
    51 *   MCN client requests have no effect on these settings,
       
    52 *   that is, the settings in the file store. MCN client requests
       
    53 *   are taken into account when a call to CCbsRecEtel::ApplyStateChangesL()
       
    54 *   is made.
       
    55 *   
       
    56 */
       
    57 class CCbsDbImpSettings : public CBase
       
    58 
       
    59     {        
       
    60     public:        // New functions
       
    61         /**
       
    62         *   Creates a new instance of the class. 
       
    63         *
       
    64         *   @param  aDatabase               Reference to the main DB instance.
       
    65         *   @return                         Returns a pointer to the created 
       
    66         *                                   instance of the class.
       
    67         */
       
    68         static CCbsDbImpSettings* NewL( CCbsDbImp& aDatabase );
       
    69 
       
    70         /**
       
    71         *   Destructor.
       
    72         */
       
    73         ~CCbsDbImpSettings();
       
    74 
       
    75         /**
       
    76         *   Changes the topic detection status.
       
    77         *
       
    78         *   @param aStatus                  New topic detection status.
       
    79         */
       
    80         void SetTopicDetectionStatusL( TBool aStatus );
       
    81 
       
    82         /**
       
    83         *   Returns the current value of the topic detection status.
       
    84         *
       
    85         *   @param aStatus                  The method will store to 
       
    86         *                                   the variable the current topic 
       
    87         *                                   detection status.
       
    88         */
       
    89         void GetTopicDetectionStatus( TBool& aStatus ) const;
       
    90 
       
    91         /**
       
    92         *   Changes the reception status.
       
    93         *
       
    94         *   @param aStatus                  New reception status.
       
    95         */
       
    96         void SetReceptionStatusL( TBool aStatus );
       
    97 
       
    98         /**
       
    99         *   Returns the current value of the topic reception status.
       
   100         *
       
   101         *   @param aStatus                  The method will store to 
       
   102         *                                   the variable 
       
   103         *                                   the current reception status.
       
   104         */                  
       
   105         void GetReceptionStatus( TBool& aStatus ) const;
       
   106     
       
   107         /**
       
   108         *   Changes the preferred languages.
       
   109         *
       
   110         *   @param aLanguages               New preferred languages.
       
   111         */
       
   112         void SetLanguagesL( const TCbsDbLanguages& aLanguages );
       
   113 
       
   114         /**
       
   115         *   Returns the preferred languages.
       
   116         *
       
   117         *   @param aLanguages               The method will store to the variable
       
   118         *                                   the current preferred languages.
       
   119         */
       
   120         void GetLanguages( TCbsDbLanguages& aLanguages ) const;
       
   121 
       
   122         /**
       
   123         *   Adds an observer to the settings. 
       
   124         *
       
   125         *   Observers are notified when an event occurs on the settings.
       
   126         *
       
   127         *   Panics if aObserver is null.
       
   128         *
       
   129         *   @param aObserver                Pointer to the observer that is 
       
   130         *                                   requested to be added.
       
   131         */
       
   132         void AddObserverL( MCbsDbSettingsObserver* aObserver );
       
   133     
       
   134         /**
       
   135         *   Removes database observer. 
       
   136         *
       
   137         *   The method will panic, if there is no such observer added
       
   138         *   or the given observer is null.
       
   139         *
       
   140         *   @param aObserver                Pointer to the observer that is 
       
   141         *                                   requested to be removed.
       
   142         */
       
   143         void RemoveObserver( const MCbsDbSettingsObserver* aObserver );
       
   144 
       
   145     private:
       
   146 
       
   147         // A structure that contains the settings.
       
   148         struct TCbsDbImpSettings
       
   149             {
       
   150             // Reception status. ETrue, if the reception is enabled.
       
   151             TBool iReceptionStatus;
       
   152 
       
   153             // Topic detection status. ETrue, if the topic detection is enabled.
       
   154             TBool iTopicDetectionStatus;
       
   155 
       
   156             // Language settings.
       
   157             TCbsDbLanguages iLanguageStatus;
       
   158             };
       
   159 
       
   160         /**
       
   161         *   Constructor.
       
   162         *
       
   163         *   @param aDatabase                Reference to the main database object.
       
   164         */
       
   165         CCbsDbImpSettings( CCbsDbImp& aDatabase );
       
   166 
       
   167         /**
       
   168         *   Creates the instances.
       
   169         *
       
   170         */
       
   171         void ConstructL();
       
   172   
       
   173         /**
       
   174         *   Saves the settings to the shared data. 
       
   175         *
       
   176         *   @return Boolean value indicating whether the saving succeeded.
       
   177         */
       
   178         TBool SaveSettings();
       
   179 
       
   180         /**
       
   181         *   Saves the settings to the shared data.
       
   182         *
       
   183         *   The method leaves in case the writing to the stream does not 
       
   184         *   succeed.
       
   185         */
       
   186         void DoSaveSettingsL();
       
   187 
       
   188         /**
       
   189         *   Loads the settings, i.e. values for reception status, 
       
   190         *   topic detection and language subscriptions.
       
   191         *
       
   192         *   These values are retrieved from Central Repository, associated with
       
   193         *   the UID of CbsServer.
       
   194         *
       
   195         */
       
   196         void LoadSettingsL();
       
   197 
       
   198         /**
       
   199         *   Determines whether the language settings are equal.
       
   200         *
       
   201         *   @param  aLanguage1              First language set.
       
   202         *   @param  aLanguage2              Second language set.
       
   203         *   @return                         ETrue, if the languages are equal.
       
   204         */
       
   205         TBool IsLanguagesEqual( const TCbsDbLanguages& aLanguage1, 
       
   206             const TCbsDbLanguages& aLanguage2 ) const;
       
   207 
       
   208         /**
       
   209         *   Sets default language settings.
       
   210         *
       
   211         *   @param  aLanguage               Place where to put the default 
       
   212         *                                   settings.
       
   213         */
       
   214         void SetDefaultLanguageSettings( TCbsDbLanguages& aLanguage ) const;
       
   215 
       
   216         /**
       
   217         *   Reads settings from shared data.
       
   218         *
       
   219         */
       
   220         //void ReadSettingsL( );
       
   221 
       
   222     private:    
       
   223 
       
   224         // The main database object.
       
   225         CCbsDbImp& iDatabase;
       
   226 
       
   227         // Cached CB settings.
       
   228         TCbsDbImpSettings iSettings;
       
   229 
       
   230         // Owns:   Array containing registered settings observers.
       
   231         CArrayFixFlat<MCbsDbSettingsObserver*>* iObservers;
       
   232 
       
   233         __DECLARE_TEST;
       
   234     };
       
   235 
       
   236 #endif      //  CCBSDBIMPSETTINGS_H   
       
   237             
       
   238 // End of File